Пример #1
0
 public BikeModelController(BikeDbContext context)
 {
     _context = context;
     ModelVM  = new BikeModelVM()
     {
         Makes     = _context.Makes.ToList(),
         BikeModel = new Models.BikeModel()
     };
 }
Пример #2
0
 public IActionResult EditPost(BikeModelVM bikeModelVM)
 {
     if (!ModelState.IsValid)
     {
         return(View(ModelVM));
     }
     _context.Update(bikeModelVM.BikeModel);
     _context.SaveChanges();
     return(RedirectToAction(nameof(Index)));
 }
Пример #3
0
 public IActionResult CreatePost(BikeModelVM bikeModelVM)
 {
     if (!ModelState.IsValid)
     {
         return(View(ModelVM));
     }
     _context.BikeModels.Add(bikeModelVM.BikeModel);
     _context.SaveChanges();
     return(RedirectToAction("Index"));
 }