public IActionResult Create(Make make) { if (ModelState.IsValid) { _db.Add(make); _db.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(make)); }
public IActionResult CreatePost() { if (!ModelState.IsValid) { return(View(ModelVM)); } _db.Add(ModelVM.Model); _db.SaveChanges(); return(RedirectToAction(nameof(Index))); }
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))); }