Пример #1
0
 public IActionResult Create(Make make)
 {
     if (ModelState.IsValid)
     {
         _db.Add(make);
         _db.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(make));
 }
Пример #2
0
 public IActionResult CreatePost()
 {
     if (!ModelState.IsValid)
     {
         return(View(ModelVM));
     }
     _db.Add(ModelVM.Model);
     _db.SaveChanges();
     return(RedirectToAction(nameof(Index)));
 }
Пример #3
0
 public IActionResult CreatePost()
 {
     if (!ModelState.IsValid)
     {
         BikeVM.Makes  = _db.Makes.ToList();
         BikeVM.Models = _db.Models.ToList();
         return(View(BikeVM));
     }
     _db.Add(BikeVM.Bike);
     _db.SaveChanges();
     UploadImageIfAvailable();
     _db.SaveChanges();
     return(RedirectToAction(nameof(Index)));
 }