Esempio n. 1
0
        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 }));
        }
Esempio n. 2
0
        public IActionResult AddLevel(int parkingId)
        {
            var viewModel = new ParkingAddLevelViewModel
            {
                ParkingId = parkingId
            };

            return(View(viewModel));
        }