public IActionResult Session(int doctorId, DateTime dateTime) { try { var userId = 0; if (User.Identity.IsAuthenticated) { userId = int.Parse(User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value); } var modelView = new SessionView { Doctor = new DoctorWithScheduleAndProfessionViewModel ( _commonServices.GetDoctorById(doctorId), _commonServices.GetProfessionByDoctorId(doctorId), _commonServices.ExtractWorkDayFromSchedule( _commonServices.GetScheduleOnDate(doctorId, dateTime), dateTime) ), DateTime = dateTime, Sessions = _commonServices.GetSessionsByDoctorIdAndDate(doctorId, dateTime) .ToDictionary(kvp => kvp.Key, kvp => SessionViewModel.ConvertToSessionViewModel(kvp.Value)), UserId = userId }; return(View(modelView)); } catch (Exception ex) { return(View("Error")); } }
public ControllerResponse <IEnumerable <KeyValuePair <TimeSpan, SessionViewModel> > > GetSessionsByDoctorAndDate(int doctorId, DateTime dateTime) { if (!UserValidator.ValidateDoctorAndDateToGetting(doctorId, dateTime)) { return(ControllerResponse <IEnumerable <KeyValuePair <TimeSpan, SessionViewModel> > > .Warning( "Доктор или дата приема не указаны или указаны неверно, повторите запрос")); } return(ControllerResponse <IEnumerable <KeyValuePair <TimeSpan, SessionViewModel> > > .Ok(_commonServices .GetSessionsByDoctorIdAndDate(doctorId, dateTime) .Select(kvp => new KeyValuePair <TimeSpan, SessionViewModel>(kvp.Key, SessionViewModel.ConvertToSessionViewModel(kvp.Value))))); }