public bool ProcessOrder(string OrderId) { WarehouseService WarehouseS = new WarehouseService(); Order TargetedOrder = GetOrder(OrderId); if (TargetedOrder == null) { return(false); } if (!WarehouseS.WarehouseExists(TargetedOrder.StorageId)) { return(false); } if (!TargetedOrder.ProductList.All(SingleProduct => WarehouseS.CheckProductQuantity(TargetedOrder.StorageId, SingleProduct.ProductId, SingleProduct.ProductQuantity))) { return(false); } foreach (ProductListElement SingleProduct in TargetedOrder.ProductList) { WarehouseS.DeleteProduct(TargetedOrder.StorageId, SingleProduct.ProductId, SingleProduct.ProductQuantity); } try { TargetedOrder.State = StateEnum.Shipped; UpdateDefinition <Order> UpdateOrderRequest = Builders <Order> .Update .Set("State", TargetedOrder.State); _orderCollection.UpdateOne(Builders <Order> .Filter.Eq("Id", TargetedOrder.Id), UpdateOrderRequest); return(true); } catch { return(false); } }