// 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));
        }
        //METHOD TO USE FOR UPLOAD IMAGE WITH FILE SYSTEM
        //private void EditImageUpload(int? id, Doctor doctorToUpdate, Image image, DoctorEditViewModel viewModel)
        //{
        //    ImageManipulation imageManipulationHelper = new ImageManipulation();
        //    var validImageTypes = new string[]
        //    {
        //         "image/gif",
        //         "image/jpeg",
        //         "image/png"
        //    };
        //    if (viewModel.Image.ImgUpload != null && viewModel.Image.ImgUpload.ContentLength > 0)
        //    {
        //        var imgFileName = Guid.NewGuid().ToString() + imageManipulationHelper.GetExtension(viewModel.Image.ImgUpload.ContentType);

        //        if (image.ImgUrl != "~/Img/doc-img-default.png") {
        //            string fileToDelete = Server.MapPath(image.ImgUrl);
        //            if (System.IO.File.Exists(fileToDelete))
        //            {
        //                System.IO.File.Delete(fileToDelete);
        //            }
        //        }

        //        if (!validImageTypes.Contains(viewModel.Image.ImgUpload.ContentType))
        //        {
        //            ModelState.AddModelError("ImgUpload", "Please, choose either GIF, JPG, or PNG type of files.");
        //        }

        //        var uploadDir = "~/Uploads";
        //        var imagePath = System.IO.Path.Combine(Server.MapPath(uploadDir), imgFileName);
        //        var imageUrl = System.IO.Path.Combine(uploadDir, imgFileName);
        //        viewModel.Image.ImgUpload.SaveAs(imagePath);

        //        ImageResizer.ResizeSettings resizeSettings = new ImageResizer.ResizeSettings
        //        {
        //            Width = 200,
        //            Height = 200
        //        };
        //        ImageResizer.ImageBuilder.Current.Build(imagePath, imagePath, resizeSettings);

        //        viewModel.Image.ImgUrl = imageUrl;
        //        doctorToUpdate.Image = image;
        //        image.ImgUrl = viewModel.Image.ImgUrl;
        //    }
        //}

        // GET: Doctors/Delete/5
        public ActionResult Delete(int?id)
        {
            DoctorDeleteViewModel viewModel = new DoctorDeleteViewModel();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Doctor           doctor          = db.Doctors.Single(d => d.ID == id);
            File             image           = db.Files.Single(i => i.ID == doctor.ImageID);
            DoctorTranslator imageTranslator = new DoctorTranslator();

            viewModel.Image = imageTranslator.ToImageViewModel(image);

            viewModel.DoctorName = doctor.FirstName + " " + doctor.LastName;
            if (doctor == null)
            {
                return(HttpNotFound());
            }
            viewModel.Alert = "Are you sure you want to delete informations for doctor " + viewModel.DoctorName + " ?";
            return(View(viewModel));
        }
        // 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));
        }