コード例 #1
0
        // GET: Doctors/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var doctor = db.Doctors
                         .Include(d => d.Image)
                         .SingleOrDefault(d => d.ID == id);

            if (doctor == null)
            {
                return(HttpNotFound());
            }
            var doctorName = doctor.FirstName + " " + doctor.LastName;
            DoctorTranslator    editDoctorTranslator = new DoctorTranslator();
            DoctorEditViewModel viewModel            = new DoctorEditViewModel();

            viewModel.DoctorsName = doctorName;
            viewModel.Doctor      = editDoctorTranslator.ToDoctorViewModel(doctor);


            File image = db.Files.Single(i => i.ID == doctor.ImageID);

            viewModel.Image = editDoctorTranslator.ToImageViewModel(image, doctor);

            return(View(viewModel));
        }
コード例 #2
0
        // GET: Doctors/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Doctor doctor = db.Doctors.SingleOrDefault(d => d.ID == id);

            if (doctor == null)
            {
                return(HttpNotFound());
            }
            DoctorEditViewModel viewModel        = new DoctorEditViewModel();
            DoctorTranslator    doctorTranslator = new DoctorTranslator();

            viewModel.Doctor = doctorTranslator.ToDoctorViewModel(doctor);

            File image = db.Files.Single(i => i.ID == doctor.ImageID);

            viewModel.Image = doctorTranslator.ToImageViewModel(image, doctor);

            return(View(viewModel));
        }