Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
        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)));
        }