public bool CreateVehicleHistory(VehicleHistoryCreate model) { var entity = new VehicleHistory() { VehicleHistoryOwnerId = _vehicleHistoryUserId, VehicleHistoryId = model.VehicleHistoryId, FirstName = model.FirstName, LastName = model.LastName, VehicleMake = model.VehicleMake, VehicleModel = model.VehicleModel, VehicleYear = model.VehicleYear, LicenseNo = model.LicenseNo, VinNo = model.VinNo, ServiceDate = model.ServiceDate, OdometerMileage = model.OdometerMileage, ServiceOne = model.ServiceOne, ServiceTwo = model.ServiceTwo, ServiceThree = model.ServiceThree, ServiceFour = model.ServiceFour, ServiceFive = model.ServiceFive, ServiceOneCost = model.ServiceOneCost, ServiceTwoCost = model.ServiceTwoCost, ServiceThreeCost = model.ServiceThreeCost, ServiceFourCost = model.ServiceFourCost, ServiceFiveCost = model.ServiceFiveCost }; using (var ctx = new ApplicationDbContext()) { ctx.VehicleHistorys.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(VehicleHistoryCreate model) { if (!ModelState.IsValid) { return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new VehicleHistoryService(userId); service.CreateVehicleHistory(model); return(RedirectToAction("Index")); }