public void SaveOfficeHours([FromBody] OfficeHoursVm[] officehoursList) { var manager = new OfficeHoursIt2Manager(); var helper = new Helper(); string pid = officehoursList[0].PracticeLocationId; var hours = (from item in officehoursList where item.IsOperatingDay select new OfficeHours { Id = item.Id, PracticeLocationId = item.PracticeLocationId, OpenFrom = helper.StringToIntegerTimeConversion(item.OpenFrom, item.OpenFromAmPm), OpenTo = helper.StringToIntegerTimeConversion(item.OpenTo, item.OpenToAmPm), OperatingDay = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), item.OperatingDay) }).ToList(); manager.SaveOfficeHours(pid, hours); }
public List <OfficeHoursVm> GetOfficeHours(string practiceLocationId) { List <OfficeHoursVm> result = this.CreateEmptyViewModel(practiceLocationId); var manager = new OfficeHoursIt2Manager(); var helper = new Helper(); List <OfficeHours> tmp = manager.GetOfficeHours(practiceLocationId); foreach (OfficeHoursVm item in result) { OfficeHours a = tmp.Find(x => x.OperatingDay.ToString() == item.OperatingDay); if (a == null) { continue; } item.Id = a.Id; item.PracticeLocationId = a.PracticeLocationId; item.IsOperatingDay = true; if (a.OpenFrom == null) { continue; } string[] d = helper.IntegerToTimeDisplay((int)a.OpenFrom); item.OpenFrom = d[0]; item.OpenFromAmPm = d[1]; if (a.OpenTo == null) { continue; } string[] dd = helper.IntegerToTimeDisplay((int)a.OpenTo); item.OpenTo = dd[0]; item.OpenToAmPm = dd[1]; } return(result); }