public ActionResult Create(GarageDTO garage) { if (garage.TyreHotel && garage.TyreSlots == null) { ModelState.AddModelError(nameof(GarageDTO.TyreSlots), "Should be filled"); } if (ModelState.IsValid) { garageRepository.Insert(GarageAssembler.Create(garage)); return(RedirectToAction("Index")); } return(View(garage)); }
public ActionResult Edit(GarageDTO garageDTO) { if (garageDTO.TyreHotel && garageDTO.TyreSlots == null) { ModelState.AddModelError(nameof(GarageDTO.TyreSlots), "Should be filled"); } if (ModelState.IsValid) { var garage = garageRepository.FindById(garageDTO.Id); garageRepository.Update(GarageAssembler.Update(garage, garageDTO)); return(RedirectToAction("Index")); } return(View(garageDTO)); }