Esempio n. 1
0
        protected async override Task <bool> Validate(Return entityObject)
        {
            StringBuilder sb    = new StringBuilder();
            bool          valid = await base.Validate(entityObject);

            OrderBL iorderBL       = new OrderBL();
            var     existingObject = await iorderBL.GetOrderByOrderIDBL(entityObject.OrderID);

            if (existingObject == null)
            {
                valid = false;
                sb.Append(Environment.NewLine + $"OrderID {entityObject.OrderID} does not exists");
            }

            ////productID is unique
            //ProductBL iproductBL = new ProductBL();

            //var existingObject2 = await iproductBL.GetProductByProductIDBL(entityObject.ProductID);
            //if (existingObject2 == null)
            //{
            //    valid = false;
            //    sb.Append(Environment.NewLine + $"ProductID {entityObject.ProductID} already exists");
            //}

            if (valid == false)
            {
                throw new EcommerceException(sb.ToString());
            }
            return(valid);
        }
Esempio n. 2
0
        public async Task <CustomerReport> GetCustomerReportByRetailIDBL(Guid CustomerID)
        {
            CustomerReport customerReport = new CustomerReport
            {
                CustomerID = CustomerID
            };
            CustomerBL customerBL = new CustomerBL();
            Customer   customer   = await customerBL.GetCustomerByCustomerIDBL(customerReport.CustomerID);

            customerReport.CustomerName = customer.CustomerName;
            OrderBL      order     = new OrderBL();
            List <Order> orderList = await order.GetOrdersByCustomerIDBL(CustomerID);

            foreach (Order item in orderList)
            {
                customerReport.CustomerSalesCount++;
                customerReport.CustomerSalesAmount += item.OrderAmount;
            }
            return(customerReport);
        }