public async Task <int> CreateMissingSchoolCalendar(PostMissingSchoolCalendarRequest request) { var site = await _repo.FindAsync <AdmSite>(request.AdmSiteId); request.Calendars.ForEach(m => { var operationalDate = m.OperationalDateString.ParseUsDate(); if (operationalDate.HasValue) { var day = site.AdmOperationalCalendars.FirstOrDefault(c => c.OperationalDate == operationalDate); if (day == null) { day = new AdmOperationalCalendar { AdmSiteID = site.AdmSiteID, OperationalDate = operationalDate.Value, OperationalStatus = m.OperationalStatus }; site.AdmOperationalCalendars.Add(day); } if (m.OperationalStatus == 0) { day.DayDescription = "Non School Day"; day.CreatedBySite = false; day.OperationalStatus = 0; } else if (m.OperationalStatus == 2) { day.DayDescription = "Holiday"; day.CreatedBySite = true; day.OperationalStatus = 2; } else { day.DayDescription = "School Day"; day.CreatedBySite = true; day.OperationalStatus = 1; } } }); await _repo.UpdateAsync <AdmSite>(site); return(site.AdmSiteID); }
public async Task <ActionResult <int> > PostMissingSchoolCalendar(PostMissingSchoolCalendarRequest request) //OLD CreateMissingSchoolCalendar { return(await _logic.CreateMissingSchoolCalendar(request)); }