public ActionResult CreationCar(Car car, HttpPostedFileBase image)
 {
     //if (ModelState.IsValid)
     //{
     try
     {
         if (image != null)
         {
             Picture pic = new Picture();
             pic.ImageData = new byte[image.ContentLength];
             pic.ImageMimeType = image.ContentType;
             image.InputStream.Read(pic.ImageData,0,image.ContentLength);
             car.Picture = pic;
         }
         CarRepository.Create(car);
         CarRepository.Save();
         //TempData["message"] = string.Format("Изменения в игре \"{0}\" были сохранены", car.CarNumber);
         return RedirectToAction("ListOfCars");
     }
     catch
     {
         // Что-то не так со значениями данных
         return View(car);
     }
 }
 public ActionResult EditCar(Car car, HttpPostedFileBase img = null)
 {
     if (img != null)
     {
         Picture pic;
         if (car.PictureId == null)
         {
             pic = new Picture();
         }
         else
         {
             pic = PictureRepository.Find(car.PictureId);
         }
         pic.ImageData = new byte[img.ContentLength];
         pic.ImageMimeType = img.ContentType;
         img.InputStream.Read(pic.ImageData, 0, img.ContentLength);
         car.Picture = pic;
     }
     else
     {
         Picture pic = PictureRepository.Find(car.PictureId);
         car.Picture = pic;
     }
     car.DateOfChange = DateTime.Now;
     CarRepository.Update(car);
     CarRepository.Save();
     return RedirectToAction("ListOfCars");
 }
Exemple #3
0
 public ActionResult ConfirmCar(Car car)
 {
     return View(car);
 }