public IActionResult AddLevel(ParkingAddLevelViewModel viewModel) { if (!ModelState.IsValid) { return(BadRequest()); } var parking = _parkingRepository.FindById(viewModel.ParkingId); if (parking == null) { return(NotFound()); } var level = new ParkingLevel(viewModel.Floor); var result = parking.AddParkingLevel(level); if (!result.IsSuccess) { return(BadRequest(result.ErrorMessage)); } _context.SaveChanges(); return(RedirectToAction(nameof(Edit), new { id = viewModel.ParkingId })); }
public IActionResult AddLevel(int parkingId) { var viewModel = new ParkingAddLevelViewModel { ParkingId = parkingId }; return(View(viewModel)); }