public async Task <ActionResult <ParkingLot> > Add(ParkingLot parkingLot) { if (parkingLot.Location == null || parkingLot.Name == null) { return(BadRequest("location or name can not be empty")); } if (parkingLot.Capacity < 0) { return(BadRequest("capacity can not be negative")); } var lotFound = service.GetAllParkingLots().Result.FirstOrDefault(lot => lot.Name == parkingLot.Name); if (lotFound != null) { return(BadRequest("lot with same name exists")); } var name = await service.AddParkingLot(parkingLot); return(CreatedAtAction(nameof(GetByName), new { name = name }, parkingLot)); }
public async Task <ActionResult <IEnumerable <ParkingLotDto> > > List() { var parkingLotDtos = await parkingLotService.GetAllParkingLots(); return(Ok(parkingLotDtos)); }