public IActionResult EditLot(Lot lot)
 {
     if (ModelState.IsValid)
     {
         iLotRepo.EditLot(lot).Wait();
         return(RedirectToAction("ShowAllLots"));
     }
     else
     {
         return(View(lot));
     }
 }
        public IActionResult AssignPermit(AssignPermitViewModel viewModel)
        {
            string parkingEmployeeID = iApplicationUserRepo.FindUserID();
            //= User.FindFirst(ClaimTypes.NameIdentifier).Value;

            //bool assignPermit;

            string errorMessage = "None";

            bool employeeHasPermit = iPermitRepo.DoesWVUEmployeeHavePermit(viewModel.WVUEmployeeID);

            if (employeeHasPermit)
            {
                errorMessage = "Employee already has a permit";
                ModelState.AddModelError("EmployeePermit", errorMessage);
            }

            bool lotAvailable = iLotRepo.IsChosenLotAvailable(viewModel.LotID);

            if (!lotAvailable)
            {
                errorMessage = "Lot is not available";
                ModelState.AddModelError("LotAvailable", errorMessage);
            }

            if (!employeeHasPermit && lotAvailable)
            {
                int    lotTypeID    = 3;
                double permitAmount = iLotStatusRepo.FindPermitAmount(viewModel.LotID, lotTypeID);

                //DateTime startDate = DateTime.Today.Date;
                DateTime endDate = viewModel.StartDate.AddYears(1);

                Permit permit = new Permit(permitAmount, viewModel.StartDate, endDate, viewModel.WVUEmployeeID, parkingEmployeeID);
                iPermitRepo.AddPermit(permit).Wait();

                //lot CurrentOccupancy to +1
                Lot lot = iLotRepo.FindLot(viewModel.LotID);
                lot.CurrentOccupancy += 1;
                iLotRepo.EditLot(lot).Wait();
                return(RedirectToAction("ListAllPermits"));
            }
            else
            {
                ViewData["Lots"]         = new SelectList(iLotRepo.ListAllLots(), "LotID", "LocationName");
                ViewData["WVUEmployees"] = new SelectList(iApplicationUserRepo.ListAllWVUEmployees(), "Id", "Fullname");
                //This has to be mocked and injected into method
                //ViewData["Lots"] = new SelectList(iLotRepo.ListAllLots(), "LotID", "LocationName");
                return(View(viewModel));
            }
        }