public async Task <int> CopySiteCalendar(PutSiteCalendarRequest model) { var admSiteIds = model .ToAdmSiteIds .Where(id => id != model.FromAdmSiteId) .ToList(); foreach (int toSite in admSiteIds) { var timeZoneName = _repo.GetSchoolTimeZoneName(); _repo.ExecuteStoredProc(StoredProcs.usp_AdmOperationalCalendars_Copy, new { fromSiteId = model.FromAdmSiteId, toSiteId = toSite, startDate = model.StartDate.ParseUsDate(), endDate = model.EndDate.ParseUsDate() }); var s = await _repo.FindAsync <AdmSitesOption>(toSite); if (s == null) { s = new AdmSitesOption { AdmSiteID = toSite }; s = await _repo.CreateAsync <AdmSitesOption>(s); } if (!string.IsNullOrWhiteSpace(model.SchoolStartDate)) { s.SchoolStartDate = model.SchoolStartDate.ParseUsDate().AdjustTimeZone(timeZoneName, false); } if (!string.IsNullOrWhiteSpace(model.SchoolEndDate)) { s.SchoolEndDate = model.SchoolEndDate.ParseUsDate().AdjustTimeZone(timeZoneName, false); } await _repo.UpdateAsync <AdmSitesOption>(s); } return(model.FromAdmSiteId); }
public async Task <ActionResult <int> > PutSiteCalendar(PutSiteCalendarRequest request) //OLD CopySiteCalendar { return(await _logic.CopySiteCalendar(request)); }