Example #1
0
        public async Task <IActionResult> Info(Guid id)
        {
            var doctor = await _polyclinicContext.Doctors.FindAsync(id);

            if (doctor is null)
            {
                ViewBag.Message = "Doctor not found.";
                return(View());
            }

            var doctorViewModel = new DoctorViewModel
            {
                Id         = doctor.Id,
                FName      = doctor.FName,
                LName      = doctor.LName,
                Position   = DoctorViewModel.GetPosition(doctor.Code),
                Department = doctor.DepartmentId,
                Area       = doctor.AreaId,
            };

            ViewBag.Areas =
                await _polyclinicContext.Areas
                .AsNoTracking()
                .ToListAsync();

            ViewBag.Deps =
                await _polyclinicContext.Departments
                .AsNoTracking()
                .ToListAsync();

            return(View(doctorViewModel));
        }