Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }