public ViewResult ManageService(long serviceId) { try { var context = _serviceProvider.GetRequiredService <AppointmentJournalContext>(); var service = context.Services.SingleOrDefault(s => s.Id == serviceId); var serviceProducerWorkDays = context.WorkDays .Where(wd => wd.ProducerId == service.ProducerId && wd.WorkDaysTimeSpans .Select(x => x.Service).Contains(service)).ToList(); var dates = DateTimePicker.CreateFourWeeksCalendar(serviceProducerWorkDays); var bookViewModel = new BookAppointmentViewModel() { Dates = dates, ServiceId = serviceId, ServiceName = service.Name }; return(View(bookViewModel)); } catch { // TODO конкретизировать ошибку return(View("Error", "Ошибка")); } }
/// <summary> /// Метод для выбора дня для записи /// </summary> /// <param name="serviceId">ID услуги</param> /// <returns></returns> public ViewResult ChooseDay(long serviceId) { var context = _serviceProvider.GetRequiredService <AppointmentJournalContext>(); var service = context.Services.SingleOrDefault(s => s.Id == serviceId); var serviceProducerWorkDays = context.WorkDays .Where(wd => wd.ProducerId == service.ProducerId && wd.WorkDaysTimeSpans .Select(x => x.Service).Contains(service)).ToList(); var dates = DateTimePicker.CreateFourWeeksCalendar(serviceProducerWorkDays); var bookViewModel = new BookAppointmentViewModel() { Dates = dates, ServiceId = serviceId, ServiceName = service.Name }; return(View(bookViewModel)); }