Esempio n. 1
0
        public ActionResult Update(HttpPostedFileBase upload, AppCar newModel)
        {
            if (upload != null)
            {
                string fileName = Path.GetFileName(upload.FileName);
                string ext      = Path.GetExtension(fileName);
                upload.SaveAs(Server.MapPath("~/Files/" + newModel.Name + ext));
                newModel.ExtencionName = newModel.Name + ext;
            }

            unit.Update_Car(newModel.FromRepoCarToDomainCar());
            return(View(newModel));
        }
Esempio n. 2
0
        public ActionResult UpdateCar(HttpPostedFileBase upload, AppCar ViewCar)
        {
            AppCar car = unit.GetCar(ViewCar.Id).FromDomainCarToRepoCar();

            if (upload != null)
            {
                string fileName      = Path.GetFileName(upload.FileName);
                string ext           = Path.GetExtension(fileName);
                string ExtencionName = ViewCar.Name + ext;
                upload.SaveAs(Server.MapPath("~/Files/" + ViewCar.Name + ext));
                byte[] avatar = new byte[upload.ContentLength];
                upload.InputStream.Read(avatar, 0, upload.ContentLength);
                car.ExtencionName = ExtencionName;
            }
            car.Price    = ViewCar.Price;
            car.Name     = ViewCar.Name;
            car.Info     = ViewCar.Info;
            car.BrandId  = ViewCar.BrandId;
            car.CarBrand = ViewCar.CarBrand;
            unit.Update_Car(car.FromRepoCarToDomainCar());
            ViewBag.Message = "Обновление сохранено в базе данных";
            return(View("~/Views/Buyer/Buy.cshtml"));
        }