public IActionResult Create([Bind("Id,Name,HourlyCourtCost, Sport, HourlyIlluminationCost,HasRoof,Surface")] CourtViewModel courtViewModel) { if (ModelState.IsValid) { var court = courtViewModel.ToCourt(mapper); courtWork.CourtRepository.Add(court); courtWork.Save(); return(RedirectToAction(nameof(Index))); } return(View(courtViewModel)); }
public IActionResult Edit(long id, [Bind("Id,Name,HourlyCourtCost,HourlyIlluminationCost,HasRoof,Surface")] CourtViewModel courtViewModel) { if (id != courtViewModel.Id) { return(NotFound()); } if (!ModelState.IsValid) { return(View(courtViewModel)); } var court = courtViewModel.ToCourt(mapper); courtWork.CourtRepository.Update(court); courtWork.Save(); return(RedirectToAction(nameof(Index))); }