コード例 #1
0
        /// <summary>
        /// Adds new Offline Order to OfflineOrderDetail collection.
        /// </summary>
        /// <param name="newOfflineOrderDetail">Contains the Offline Orders Detail to be added.</param>
        /// <returns>Determinates whether the new Offline Order is added.</returns>
        public bool AddOfflineOrderDetailDAL(OfflineOrderDetail newOfflineOrderDetail)
        {
            bool OfflineOrderDetailAdded = false;

            try
            {
                newOfflineOrderDetail.OfflineOrderDetailID = Guid.NewGuid();
                OfflineOrderDetailList1.Add(newOfflineOrderDetail);
                OfflineOrderDetailAdded = true;
            }
            catch (SystemException ex)
            {
                throw new OfflineOrderException(ex.Message);
            }
            return(OfflineOrderDetailAdded);
        }
コード例 #2
0
        /// <summary>
        /// Gets Offline Order based on OfflineOrderDetailID.
        /// </summary>
        /// <param name="searchOfflineOrderDetailID">Represents OfflineOrderDetailID to search.</param>
        /// <returns>Returns SystemUser object.</returns>
        public OfflineOrderDetail GetOfflineOrderDetailByOfflineOrderDetailIDDAL(Guid searchOfflineOrderDetailID)
        {
            OfflineOrderDetail matchingOfflineOrderDetail = null;

            try
            {
                //Find SystemUser based on searchSystemUserID
                matchingOfflineOrderDetail = OfflineOrderDetailList1.Find(
                    (item) => { return(item.OfflineOrderDetailID == searchOfflineOrderDetailID); }
                    );
            }
            catch (Exception)
            {
                throw;
            }
            return(matchingOfflineOrderDetail);
        }
コード例 #3
0
        public bool UpdateOfflineOrderDetailDAL(OfflineOrderDetail updateOfflineOrderDetail)
        {
            bool OfflineOrderDetailUpdated = false;

            try
            {
                for (int i = 0; i < OfflineOrderDetailList1.Count; i++)
                {
                    if (OfflineOrderDetailList1[i].OfflineOrderDetailID == updateOfflineOrderDetail.OfflineOrderDetailID)
                    {
                        OfflineOrderDetailList1[i] = updateOfflineOrderDetail;

                        OfflineOrderDetailUpdated = true;
                    }
                }
            }
            catch (SystemException ex)
            {
                throw new OfflineOrderException(ex.Message);
            }
            return(OfflineOrderDetailUpdated);
        }
コード例 #4
0
        /// <summary>
        /// Deletes OfflineOrderDetail based on OfflineOrderDetailID.
        /// </summary>
        /// <param name="deleteOfflineOrderDetailID">Represents OfflineOrderDetailID to delete.</param>
        /// <returns>Determinates whether the existing OfflineOrderDetail is deleted.</returns>
        public bool DeleteOfflineOrderDetailDAL(Guid deleteOfflineOrderDetailID)
        {
            bool OfflineOrderDetailDeleted = false;

            try
            {
                //Find SystemUser based on searchSystemUserID
                OfflineOrderDetail matchingOfflineOrderDetail = OfflineOrderDetailList1.Find(
                    (item) => { return(item.OfflineOrderDetailID == deleteOfflineOrderDetailID); }
                    );

                if (matchingOfflineOrderDetail != null)
                {
                    //Delete SystemUser from the collection
                    OfflineOrderDetailList1.Remove(matchingOfflineOrderDetail);
                    OfflineOrderDetailDeleted = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(OfflineOrderDetailDeleted);
        }
コード例 #5
0
        public static async Task UploadOfflineOrder()
        {
            try
            {
                //Read inputs
                OfflineOrder   offlineOrder    = new OfflineOrder();
                OfflineOrderBL offlineOrderBL1 = new OfflineOrderBL();
                offlineOrder.TotalOrderAmount = 10;
                offlineOrder.TotalQuantity    = 10;

                using (IRetailerBL retailerBL = new RetailerBL())
                {
                    int serial = 0;


                    //Get and display list of Retailer.
                    List <Retailer> retailers = await retailerBL.GetAllRetailersBL();

                    WriteLine("Retailers:");
                    if (retailers != null && retailers?.Count > 0)
                    {
                        WriteLine("#\tName\tEmail\tRetailerID\t");

                        foreach (var retailer in retailers)
                        {
                            serial++;
                            WriteLine($"{serial}\t{retailer.RetailerName}\t{retailer.Email}\t{retailer.RetailerID}");
                        }
                    }

                    Write("Select Retailer #: ");
                    bool isNumberValid = int.TryParse(ReadLine(), out serial);
                    if (isNumberValid)
                    {
                        serial--;
                        if (serial <= retailers.Count - 1)
                        {
                            Retailer retailer1 = retailers[serial];

                            offlineOrder.RetailerID = retailer1.RetailerID;
                        }
                        else
                        {
                            WriteLine("INVALID ENTRY");
                        }
                    }
                    SalesPersonBL salespersonBL = new SalesPersonBL();
                    SalesPerson   salesPerson   = await salespersonBL.GetSalesPersonByEmailBL(CommonData.CurrentUser.Email);

                    offlineOrder.SalesPersonID = salesPerson.SalesPersonID;
                }


                using (IProductBL productBL = new ProductBL())
                {
                    int serial1 = 0;

                    //Get and display list of Product.
                    List <Product> products = await productBL.GetAllProductsBL();

                    WriteLine("Select Products from following List");
                    WriteLine("Products:");
                    if (products != null && products?.Count > 0)
                    {
                        WriteLine("#\tProductName\tPrice\t\tDescription\t");

                        foreach (var product in products)
                        {
                            serial1++;
                            WriteLine($"{serial1}\t{product.ProductName}\t{product.ProductPrice}\t{product.ProductColor}\t{product.ProductSize}\t{product.ProductMaterial}");
                        }
                    }
                    //Add Product Details
                    char c;
                    WriteLine("Add product(Y/N):");
                    c = Char.Parse(ReadLine());

                    while ((c == 'Y') || (c == 'y'))
                    {
                        OfflineOrderDetail offlineOrderDetail = new OfflineOrderDetail();
                        offlineOrderDetail.OfflineOrderID = offlineOrder.OfflineOrderID;

                        Write("Select Product #: ");
                        bool isNumberValid1 = int.TryParse(ReadLine(), out serial1);
                        if (isNumberValid1)
                        {
                            serial1--;
                            if (serial1 <= products.Count - 1)
                            {
                                Product product1 = products[serial1];

                                offlineOrderDetail.ProductID   = product1.ProductID;
                                offlineOrderDetail.UnitPrice   = product1.ProductPrice;
                                offlineOrderDetail.ProductName = product1.ProductName;
                                WriteLine("Enter Quantity:");

                                double quantity = Double.Parse(ReadLine());
                                offlineOrderDetail.Quantity   = quantity;
                                offlineOrderDetail.TotalPrice = offlineOrderDetail.UnitPrice * quantity;
                                using (IOfflineOrderDetailBL offlineOrderDetailBL = new OfflineOrderDetailBL())
                                {
                                    bool isAdded = await offlineOrderDetailBL.AddOfflineOrderDetailBL(offlineOrderDetail);

                                    if (isAdded)
                                    {
                                        WriteLine("Offline Order Detail Added");
                                    }
                                }
                            }
                            else
                            {
                                WriteLine("Invalid Serial Number");
                            }
                        }
                        else
                        {
                            WriteLine("Invalid choice");
                        }

                        WriteLine("Add product(Y/N)");
                        c = Char.Parse(ReadLine());
                    }
                    if (!(c == 'y') || (c == 'Y') || (c == 'n') || (c == 'N'))
                    {
                        WriteLine("Invalid Choice");
                    }
                }

                using (IOfflineOrderBL offlineOrderBL = new OfflineOrderBL())
                {
                    bool isAdded;

                    isAdded = await offlineOrderBL.AddOfflineOrderBL(offlineOrder);

                    if (isAdded)
                    {
                        // WriteLine("Offline Order Added");
                    }

                    using (IOfflineOrderDetailBL offlineOrderDetailBL = new OfflineOrderDetailBL())
                    {
                        //Get and display list of offline order details using order ID .
                        List <OfflineOrderDetail> offlineOrderDetails = await offlineOrderDetailBL.GetAllOfflineOrderDetailBL();

                        WriteLine("OfflineOrderDetails:");
                        if (offlineOrderDetails != null && offlineOrderDetails?.Count > 0)
                        {
                            WriteLine("#\tProductName\tUnitPrice\tQuantity\tTotal Price");
                            int serial2 = 0;
                            foreach (var offlineOrderDetail in offlineOrderDetails)
                            {
                                serial2++;
                                WriteLine($"{serial2}\t{offlineOrderDetail.ProductName}\t\t {offlineOrderDetail.UnitPrice}\t\t {offlineOrderDetail.Quantity}\t\t {offlineOrderDetail.TotalPrice}");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }