Exemplo n.º 1
0
        public ActionResult Edit(Driver driver)
        {
            if (ModelState.IsValid)
            {
                var pic    = string.Empty;
                var folder = "~/Content/Logos";

                if (driver.FixedPhoneFile != null)
                {
                    pic = FilesHelper.UploadPhoto(driver.FixedPhoneFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                    driver.FixedPhone = pic;
                }
                db.Entry(driver).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CarId        = new SelectList(CombosHelper.GetCars(), "CarId", "Plate", driver.CarId);
            ViewBag.CityId       = new SelectList(CombosHelper.GetCities(), "CityId", "Name", driver.CityId);
            ViewBag.DepartmentId = new SelectList(CombosHelper.GetDepartments(), "DepartmentId", "Name", driver.DepartmentId);
            return(View(driver));
        }