/// <summary>
        /// Метод для получения списка бронирований для данного пользователя
        /// </summary>
        /// <returns></returns>
        public ViewResult ManageAppointments()
        {
            var context = _serviceProvider.GetRequiredService <AppointmentJournalContext>();

            var userId = _userManager.GetUserId(User);

            var appointments = context.Appointments
                               .Include(x => x.Service)
                               .ThenInclude(x => x.Category)
                               .Include(x => x.WorkDayTimeSpan)
                               .ThenInclude(x => x.Address)
                               .Where(x => x.ConsumerId == userId).AsEnumerable().Select(async x =>
            {
                x.Service.Producer = await _userManager.FindByIdAsync(x.Service.ProducerId);
                return(x);
            })
                               .Select(x => x.Result).ToList();

            var model = new ManageAppointmentsViewModel()
            {
                Appointments = appointments
            };

            return(View(model));
        }
Exemple #2
0
        public ActionResult ManageAppointments()
        {
            List <ManageAppointmentsViewModel> vml = new List <ManageAppointmentsViewModel>();


            Patient patient = GetPatientInContext();

            patient.Appointments = GetPatientAppointments(patient);

            foreach (var item in patient.Appointments)
            {
                ManageAppointmentsViewModel vm = new ManageAppointmentsViewModel
                {
                    Appointment = item,
                    DoctorName  = (from d in context.Doctor where d.Id == item.DoctorId select d.FirstName).SingleOrDefault()
                };
                vml.Add(vm);
            }
            // because i would like to display the doctor name not just the id
            return(View(vml));
        }