public async Task <IActionResult> Record()
        {
            if (User.Identity.IsAuthenticated)
            {
                PatientRecordViewModel model = new PatientRecordViewModel();

                var user = await userManager.FindByNameAsync(User.Identity.Name);

                var patient = repository.GetPatientByUser(user);

                if (patient != null)
                {
                    List <AppointmentViewModel> appointments = new List <AppointmentViewModel>();
                    foreach (var a in patient.Record.Appointments)
                    {
                        appointments.Add(mapper.Map <Appointment, AppointmentViewModel>(repository.GetAppointmentById(a.Id)));
                    }
                    model.Appointments = appointments;
                    model.Patient      = mapper.Map <Patient, PatientViewModel>(patient);

                    return(View(model));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                TempData["NeedLogin"] = "******";
                return(RedirectToAction("Login", "Account"));
            }
        }
Exemple #2
0
        public IActionResult UpdateAppointment(int id, int patientId)
        {
            if (!CheckAuthorization())
            {
                return(AuthorizeSendBack());
            }

            UpdateAppointmentViewModel model = new UpdateAppointmentViewModel();
            var appointment = repository.GetAppointmentById(id);

            if (appointment != null)
            {
                model.Appointment = mapper.Map <Appointment, AppointmentViewModel>(appointment);
            }

            var procedures = repository.GetAllProcedures();

            model.Procedures = mapper.Map <IEnumerable <Procedure>, IEnumerable <ProcedureViewModel> >(procedures).ToList();
            model.PatientId  = patientId;

            return(View(model));
        }