//view Carts list public List <MyCart> GetCartBL(string username) { OrderIngredientDAL orderIngredientDAL = new OrderIngredientDAL(); List <MyCart> myCartList = orderIngredientDAL.GetMyCartDAL(username); return(myCartList); }
/*public bool DeleteCartBL(Cart cart) * { * bool cartDeleted = false; * try * { * if (ValidateCart(cart)) * { * OrderIngredientDAL orderIngredientDAL = new OrderIngredientDAL(); * cartDeleted = orderIngredientDAL.DeleteCartDAL(cart); * } * } * catch (RecipeIngredientSystemExceptions) * { * throw; * } * catch (Exception ex) * { * throw ex; * } * return cartDeleted; * }*/ //add order details public bool AddOrderBL(OrderCartIngredient orderadd, string username) { try { if (orderadd != null) { //validate order details before adding if (ValidateOrderDetails(orderadd)) { OrderIngredientDAL orderIngredientDAL = new OrderIngredientDAL(); if (orderIngredientDAL.AddOrderDAL(orderadd, username)) { return(true); } else { throw new RecipeIngredientSystemExceptions("Empty Fields"); } } } } catch (RecipeIngredientSystemExceptions) { throw; } catch (NullReferenceException) { MessageBox.Show("Details Incomplete"); } catch (Exception ex) { throw ex; } return(false); }
/*public bool AddOrderBL(OrderCartIngredient orderadd, string username) * { * bool orderAdded = false; * try * { * if (ValidateOrderDetails(orderadd)) * { * OrderIngredientDAL orderIngredientDAL = new OrderIngredientDAL(); * orderAdded = orderIngredientDAL.AddOrderDAL(orderadd, username); * } * } * catch (RecipeIngredientSystemExceptions) * { * throw; * } * catch (Exception ex) * { * throw ex; * } * return orderAdded; * }*/ //calculate total amount public decimal Totalamount(string username) { List <Cart> cartList = new List <Cart>(); decimal totalamount = 0; try { OrderIngredientDAL orderIngredientDAL = new OrderIngredientDAL(); cartList = orderIngredientDAL.TotalAmountDAL(username); //total amount calculation for (int i = 0; i < cartList.Count; i++) { totalamount += cartList[i].Amount; } } catch (RecipeIngredientSystemExceptions) { throw; } catch (Exception ex) { throw ex; } return(totalamount); }
/*public bool UpdateCartBL(Cart cart) * { * bool cartUpdated = false; * try * { * if (ValidateCart(cart)) * { * OrderIngredientDAL orderIngredientDAL = new OrderIngredientDAL(); * cartUpdated = orderIngredientDAL.UpdateCartDAL(cart); * } * } * catch (RecipeIngredientSystemExceptions) * { * throw; * } * catch (Exception ex) * { * throw ex; * } * return cartUpdated; * }*/ //delete cart details public bool DeleteCartBL(Cart cart) { try { //check cart is null or not if (cart != null) { OrderIngredientDAL orderIngredientDAL = new OrderIngredientDAL(); if (orderIngredientDAL.DeleteCartDAL(cart)) { return(true); } else { throw new RecipeIngredientSystemExceptions("Select Ingredient from List To Delete"); } } } catch (RecipeIngredientSystemExceptions) { throw; } catch (Exception ex) { throw ex; } return(false); }
//update cart details public bool UpdateCartBL(Cart cart) { try { if (cart != null) { //validate details before updating if (ValidateCart(cart)) { OrderIngredientDAL orderIngredientDAL = new OrderIngredientDAL(); if (orderIngredientDAL.UpdateCartDAL(cart)) { return(true); } } } } catch (Exception) { throw; } return(false); }