public IActionResult Add(AddTrailerViewModel addtrailerViewModel) { if (ModelState.IsValid) { Trailer newTrailer = new Trailer { SerialNumber = addtrailerViewModel.SerialNumber, Make = addtrailerViewModel.Make, Model = addtrailerViewModel.Model, DotInsp = addtrailerViewModel.DotInsp, Plate = addtrailerViewModel.Plate, RegDate = addtrailerViewModel.RegDate, Year = addtrailerViewModel.Year, TrailerNumber = addtrailerViewModel.TrailerNumber }; //add to tractorData context.Trailers.Add(newTrailer); //always save changes context.SaveChanges(); return(Redirect("/Trailer")); } ; return(View(addtrailerViewModel)); }
//displays form public IActionResult Add() { AddTrailerViewModel addtrailerViewModel = new AddTrailerViewModel(); return(View(addtrailerViewModel)); }