public ViewResult UpdateMilage(Guid id) { CarUpdateMilageViewModel model = new CarUpdateMilageViewModel { CarId = id, CarReg = _carsrepository.GetCar(id).RegistrationNumber }; return(View(model)); }
public IActionResult UpdateMilage(CarUpdateMilageViewModel model) { if (ModelState.IsValid) { MilageRecord record = new MilageRecord { CarId = model.CarId, Milage = model.Milage, Date = model.Date, Id = new Guid() }; _milageRecordsRepository.Add(record); Car car = _carsrepository.GetCar(model.CarId); car.Milage = model.Milage; _carsrepository.Update(car); return(RedirectToAction("details", "cars", new { id = model.CarId })); } return(RedirectToAction("Updatemilage", new { id = model.CarId })); }