public async Task <IActionResult> Index() { ViewBag.Lang = Lng; ViewBag.Doctors = await _serviceSupplyService.GetSelectListAsync(CurrentBeautyCenter.Id, CurrentBeautyCenter.ServiceSupplyIds); ViewBag.HealthServices = await _healthServiceService.GetSelectListItemsAsync(CurrentBeautyCenter.Id, Lng); ViewBag.Patients = await _patientService.GetSelectListItemsAsync(CurrentBeautyCenter.Id, CurrentBeautyCenter.ServiceSupplyIds, Lng); var model = new BeautyCenterBookingViewModel { Date = DateTime.Now }; return(View(model)); }
public async Task <IActionResult> BookingTiems(BeautyCenterBookingViewModel bookingModel) { if (CurrentBeautyCenter.ServiceSupplyIds.Any() && !CurrentBeautyCenter.ServiceSupplyIds.Contains(bookingModel.ServiceSupplyId)) { throw new AccessDeniedException(); } var servicesSupply = await _serviceSupplyService.GetForShiftCenterAsync(bookingModel.ServiceSupplyId, CurrentBeautyCenter.Id); if (servicesSupply == null) { throw new AwroNoreException(Global.Err_DoctorNotFound); } var centerService = await _healthServiceService.GetShiftCenterServiceByIdAsync(bookingModel.CenterServiceId); if (centerService == null) { throw new AwroNoreException(Global.Err_HealthServiceNotFound); } var resultModel = new BeautyCenterBookableTimesViewModel { BookingModel = bookingModel }; var allTimePeriods = _doctorServiceManager.Calculate_All_TimePeriods(servicesSupply, bookingModel.Date, centerService); if (allTimePeriods != null && allTimePeriods.Any()) { resultModel.BokkableTimes = allTimePeriods.Select(x => new BookableTimesListModel { Type = x.Type, StartTime = x.StartDateTime, EndTime = x.EndDateTime, IsOutOfSchedule = false, }).ToList(); } return(PartialView(resultModel)); }