I have this following code which will return all the current semesters. How do I identify if there is “Summer” semester in the collection and replace it with “Summer I” dynamically?
return activeSemester.Select(c => new ActiveSemester
{
id = c.SemesterId,
name = c.Name, // Here I want to check if it is Summer
}).ToList();
Update:
Summer semesters hold 3 Summer names but the dates are different. I just want to name it in order. Also each one has unique SemesterId.
So you can accurately account for your 3 different summer sessions, I think a conditional approach would make more sense. If you implement any kind of incrementing method and pass data to this method that is not sorted correctly, you could tag an
ActiveSemsteras"Summer I"when the dates or semester id match"Summer II"You could either include the condition directly in a LINQ query or create a method that will identify the summer based on date or semster id