Esempio n. 1
0
        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"));
            }
        }