public bool DeleteDiscountDAL(int deleteRetailerID, int deleteOrderID) { bool discountDeleted = false; try { Discount_Entities deleteDiscount = null; foreach (Discount_Entities item in discountList) { if ((item.OrderID == deleteOrderID) && (item.RetailerID == deleteRetailerID)) { deleteDiscount = item; } } if (deleteDiscount != null) { discountList.Remove(deleteDiscount); discountDeleted = true; } } catch (Exception ex) { throw new Discount_Exception(ex.Message); } return(discountDeleted); }
private static bool ValidateDiscount(Discount_Entities discount) { StringBuilder sb = new StringBuilder(); bool validDiscount = true; if (discount.OrderID == 0) { validDiscount = false; sb.Append(Environment.NewLine + "OrderID Required"); } if (discount.RetailerID == 0) { validDiscount = false; sb.Append(Environment.NewLine + "RetailerID Required"); } if (discount.CategoryDiscount == 0) { validDiscount = false; sb.Append(Environment.NewLine + "Category Discount Required"); } if (discount.RetailerDiscount == 0) { validDiscount = false; sb.Append(Environment.NewLine + "Retailer Discount Required"); } if (validDiscount == false) { throw new GOException(sb.ToString()); } return(validDiscount); }
public bool AddDiscountDAL(Discount_Entities discount) { bool discountAdded; try { discountList.Add(discount); discountAdded = true; } catch (SystemException ex) { throw new Discount_Exception(ex.Message); } return(discountAdded); }
public static Discount_Entities SearchDiscountBL(int searchRetailerID, int searchOrderID) { Discount_Entities searchDiscount = null; try { Discount_DAL discountDAL = new Discount_DAL(); searchDiscount = discountDAL.SearchDiscountDAL(searchRetailerID, searchOrderID); } catch (GOException ex) { throw ex; } catch (Exception ex) { throw ex; } return(searchDiscount); }
public Discount_Entities SearchDiscountDAL(int searchRetailerID, int searchOrderID) { Discount_Entities searchDiscount = null; try { foreach (Discount_Entities discount in discountList) { if ((discount.OrderID == searchOrderID) && (discount.RetailerID == searchRetailerID)) { searchDiscount = discount; } } } catch (SystemException ex) { throw new Discount_Exception(ex.Message); } return(searchDiscount); }
public bool UpdatedDiscountDAL(Discount_Entities updateDiscount) { bool DiscountUpdated = false; try { for (int i = 0; i < discountList.Count; i++) { if ((discountList[i].RetailerID == updateDiscount.RetailerID) && (discountList[i].OrderID == updateDiscount.OrderID)) { discountList[i].RetailerDiscount = updateDiscount.RetailerDiscount; discountList[i].CategoryDiscount = updateDiscount.CategoryDiscount; DiscountUpdated = true; } } } catch (SystemException ex) { throw new Discount_Exception(ex.Message); } return(DiscountUpdated); }
public static bool UpdateDiscountBL(Discount_Entities updateDiscount) { bool discountUpdated = false; try { if (ValidateDiscount(updateDiscount)) { Discount_DAL discountDAL = new Discount_DAL(); discountUpdated = discountDAL.UpdatedDiscountDAL(updateDiscount); } } catch (GOException) { throw; } catch (Exception ex) { throw ex; } return(discountUpdated); }
public static bool AddDiscountBL(Discount_Entities newDiscount) { bool DiscountAdded = false; try { if (ValidateDiscount(newDiscount)) { Discount_DAL discountDAL = new Discount_DAL(); DiscountAdded = discountDAL.AddDiscountDAL(newDiscount); } } catch (GOException) { throw; } catch (Exception ex) { throw ex; } return(DiscountAdded); }