public async Task <ActionResult <Order> > Add(OrderRequest order) { var lotFound = await parkingLotService.GetParkingLotByName(order.ParkingLotName); if (lotFound == null) { return(BadRequest("no parkingLot match the name")); } var orderFound = orderService.GetOrders().Result .FirstOrDefault(orderEntity => orderEntity.PlateNumber == order.PlateNumber && orderEntity.Status == Status.Open); if (orderFound != null) { return(BadRequest("car in the lot")); } var emptyPosition = await parkingLotService.GetParkingLotEmptyPositionByName(order.ParkingLotName); if (emptyPosition == 0) { return(BadRequest("The parking lot is full")); } var orderReturn = await orderService.AddOrder(order); return(CreatedAtAction(nameof(GetByNumber), new { number = orderReturn.OrderNumber }, orderReturn)); }