public object Get(int id) { ParkingLotViewModel model = _parkingLotService.Get(id); if (model == null) { return(new ResponseDetails(false, $"Parking lot with Id : { id } not found.")); } return(new ResponseDetails(true, model)); }
public ActionResult EditParkingLot(int?id) { ParkingLotViewModel model = new ParkingLotViewModel(); if (id.HasValue && id != 0) { ParkingLot parkingLotEntity = parkingLotService.Get(id.Value); model.Address = parkingLotEntity.Address; model.CompanyName = parkingLotEntity.CompanyName; model.ZipCode = parkingLotEntity.ZipCode; } return(View("EditParkingLot", model)); }
public async Task <IActionResult> Get() { logger.LogTrace("Getting parking lot description."); var parkingLot = await parkingLotService.Get(); return(Ok(new { availableSpace = parkingLot.AvailableSpace })); }
public ActionResult AddParkingFloor(ParkingFloorViewModel model) { var parkingLot = parkingLotService.Get(model.ParkingLotId); if (parkingLot != null) { ParkingFloor parkingFloorEntity = new ParkingFloor { NumberOfSpots = model.NumberOfSpots, AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, ParkingLotId = model.ParkingLotId }; List <ParkingSpot> parkingSpots = new List <ParkingSpot>(); for (int j = 0; j < model.NumberOfSpots; j++) { ParkingSpot parkingSpot = new ParkingSpot { AddedDate = DateTime.UtcNow, ModifiedDate = DateTime.UtcNow, }; parkingFloorEntity.ParkingSpots = parkingSpots; parkingSpots.Add(parkingSpot); } parkingFloorEntity.ParkingSpots = parkingSpots; parkingFloorService.Insert(parkingFloorEntity); if (parkingFloorEntity.Id > 0) { return(RedirectToAction("index")); } return(View(model)); } else { TempData["NoLotMessage"] = "The Lot number does not exist"; return(RedirectToAction("Index")); } }