Example #1
0
        /// <summary>
        /// Updates the Order Data with respect to the desired shipping details.
        /// </summary>
        /// <param name="orderCL">OrderCL class containing Order Description and Status</param>
        /// <returns>OrderCL class returning all the fields in the updated Order.</returns>
        public OrderCL updateShippingDetails(OrderCL orderCL)
        {
            Order query = (from x in dbcontext.Orders where x.Id == orderCL.id && x.IsDeleted == false select x).FirstOrDefault();

            query.Description = orderCL.description;
            query.StatusId    = orderCL.statusId;
            dbcontext.SaveChanges();
            OrderCL newOrderCL = new OrderCL()
            {
                id             = query.Id,
                addressId      = query.AddressId,
                cartId         = query.CartId,
                dateCreated    = query.DateCreated,
                dateModified   = query.DateModified,
                description    = query.Description,
                isDeleted      = query.IsDeleted,
                shippingCharge = query.ShippingCharge.ToString(),
                statusId       = query.StatusId,
                taxAmount      = query.TaxAmount,
                totalAmount    = query.TotalAmount,
                orderNumber    = query.OrderNumber,
            };

            return(newOrderCL);
        }
        //private OrderGridCL ConvertOrderToGrid(OrderCL activeOrders)
        //{
        //    string addressType = "";
        //    int addressTypeId = addressBLL.getAddressById(activeOrders.addressId).addressTypeId;
        //    if(addressTypeId==0)
        //    {
        //        addressType = "Shipping Address";
        //    }
        //    if(addressTypeId==1)
        //    {
        //        addressType = "Billing Address";
        //    }
        //    if(addressTypeId==2)
        //    {
        //        addressType = "Permanent Address";
        //    }
        //    OrderGridCL activeOrderDetails = new OrderGridCL()
        //        {
        //            addressLine1 = addressBLL.getAddressById(activeOrders.addressId).addressLine1,
        //            addressLine2 = addressBLL.getAddressById(activeOrders.addressId).addressLine2,
        //            addressLine3 = addressBLL.getAddressById(activeOrders.addressId).addressLine3,
        //            address = addressBLL.getAddressById(activeOrders.addressId).addressLine1 + "," + addressBLL.getAddressById(activeOrders.addressId).addressLine2 + "," + addressBLL.getAddressById(activeOrders.addressId).addressLine3 + "," + addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).cityName + "," + addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).stateName + "," + addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).countryName + ",",
        //            addressType = addressType,
        //            cityId = addressBLL.getAddressById(activeOrders.addressId).cityId,
        //            country = addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).countryName,
        //            dateCreated = activeOrders.dateCreated,
        //            dateModified = activeOrders.dateModified,
        //            id = activeOrders.id,
        //            isDeleted = activeOrders.isDeleted,
        //            memberName = cartBLL.getMemberbyCartId(activeOrders.cartId).name,
        //            orderStatus = addressBLL.getStatusById(activeOrders.statusId).name,
        //            productName = cartBLL.getProductbyCartId(activeOrders.cartId).name,
        //            productQty = cartBLL.getCartProductByCartId(activeOrders.cartId).quantity.ToString(),
        //            shippingCharge = activeOrders.shippingCharge,
        //            shippingDescription = activeOrders.description,
        //            stateId = addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).stateId,
        //            taxAmt = activeOrders.taxAmount,
        //            totalAmt = activeOrders.totalAmount,
        //        };
        //    return activeOrderDetails;
        //}
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            OrderCL orderCL = new OrderCL();

            orderCL.id          = id;
            orderCL.description = txtShippingDescription.Text;
            orderCL.statusId    = Convert.ToInt32(ddlShippingStatus.SelectedValue);
            OrderBLL orderBLL   = new OrderBLL();
            OrderCL  newOrderCL = orderBLL.updateShippingDetails(orderCL);

            txtShippingDescription.Text     = newOrderCL.description;
            ddlShippingStatus.SelectedValue = newOrderCL.statusId.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int orderId = Convert.ToInt32(Request.QueryString["id"]);

            id = orderId;
            if (!IsPostBack)
            {
                OrderBLL          orderBLL      = new OrderBLL();
                OrderCL           orderCL       = orderBLL.getOrderById(orderId);
                UpdateOrderGridCL ordergridCL   = ConvertOrderToGrid(orderCL);
                string            memberIsGuest = ordergridCL.memberIsGuest ? "Is Guest" : "Member";;
                string            memberGender  = ordergridCL.memberGender ? "Is Male" : "Is Female";
                string            dateJoining   = ordergridCL.memberJoinDate.Date.ToString("d");
                string            dateModified  = ordergridCL.memberModifiedDate.Date.ToString("d");
                lblMemberDetails.Text           = ordergridCL.memberName + " , " + memberIsGuest + " , " + memberGender + " , " + ordergridCL.memberMobNo + Environment.NewLine + ordergridCL.memberAddress + "<br />" + "Member Joining Date" + " - " + dateJoining + "<br />" + "Member Update Date" + " - " + dateModified;
                lblPaymentDetails.Text          = "";
                ddlShippingStatus.SelectedValue = orderBLL.getOrderById(orderId).statusId.ToString();
                txtShippingDescription.Text     = orderBLL.getOrderById(orderId).description;
                string[] productName           = ordergridCL.productName.Split(';');
                string[] productDispatchTime   = ordergridCL.productDispatchTime.Split(';');
                string[] productQty            = ordergridCL.productQty.Split(';');
                string[] productPrice          = ordergridCL.productPrice.Split(';');
                string[] productShippingCharge = ordergridCL.productShippingCharge.Split(';');
                string[] productId             = ordergridCL.productId.Split(';');
                int      productCount          = ordergridCL.productCount;
                Collection <UpdateProductGridCL> productUpdateInGrid = new Collection <UpdateProductGridCL>();
                for (int i = 0; i < productCount; i++)
                {
                    productUpdateInGrid.Add(new UpdateProductGridCL
                    {
                        productDispatchTime   = productName[i],
                        productId             = productId[i],
                        productName           = productName[i],
                        productPrice          = productPrice[i],
                        productQty            = productQty[i],
                        productShippingCharge = productShippingCharge[i],
                    });
                }
                grdUpdateOrders.DataSource = productUpdateInGrid;
                grdUpdateOrders.DataBind();
            }
        }
Example #4
0
        /// <summary>
        /// Fetchs the all the orders containing Order CL class by Cart Id.
        /// </summary>
        /// <param name="cartId">Cart Id provided to get Order CL class for it.</param>
        /// <returns>Order CL class having orderId provided.</returns>
        public OrderCL getOrderByCartId(int cartId)
        {
            Order   query   = (from x in dbcontext.Orders where x.CartId == cartId select x).FirstOrDefault();
            OrderCL orderCL = new OrderCL()
            {
                addressId      = query.AddressId,
                cartId         = query.CartId,
                dateCreated    = query.DateCreated,
                dateModified   = query.DateModified,
                description    = query.Description,
                id             = query.Id,
                isDeleted      = query.IsDeleted,
                shippingCharge = query.ShippingCharge.ToString(),
                statusId       = query.StatusId,
                taxAmount      = query.TaxAmount,
                totalAmount    = query.TotalAmount,
                orderNumber    = query.OrderNumber,
            };

            return(orderCL);
        }
        private UpdateOrderGridCL ConvertOrderToGrid(OrderCL activeOrders)
        {
            Collection <ProductCL>     products     = cartBLL.getProductCollectionByCartId(activeOrders.cartId);
            Collection <CartProductCL> cartProducts = cartBLL.getCartProductCollectionByCartId(activeOrders.cartId);
            string addressType   = "";
            int    addressTypeId = addressBLL.getAddressById(activeOrders.addressId).addressTypeId;

            if (addressTypeId == 0)
            {
                addressType = "Shipping Address";
            }
            if (addressTypeId == 1)
            {
                addressType = "Billing Address";
            }
            if (addressTypeId == 2)
            {
                addressType = "Permanent Address";
            }
            StringBuilder productQty            = new StringBuilder();
            StringBuilder productId             = new StringBuilder();
            StringBuilder productName           = new StringBuilder();
            StringBuilder productDispatchTime   = new StringBuilder();
            StringBuilder productPrice          = new StringBuilder();
            StringBuilder productShippingCharge = new StringBuilder();

            foreach (ProductCL item in products)           // Loop through all strings
            {
                productName.Append(item.name).Append(";"); // Append string to StringBuilder
                productDispatchTime.Append(item.dispatchTime).Append(";");
                productId.Append(item.Id).Append(";");
                productPrice.Append(item.price).Append(";");
                productShippingCharge.Append(item.shippingCharge).Append(";");
            }
            foreach (CartProductCL item in cartProducts)
            {
                productQty.Append(item.quantity).Append(";");
            }
            UpdateOrderGridCL updateOrderDetails = new UpdateOrderGridCL()
            {
                id                       = activeOrders.id,
                memberName               = cartBLL.getMemberbyCartId(activeOrders.cartId).name,
                memberAddress            = addressBLL.getAddressById(activeOrders.addressId).addressLine1 + "," + addressBLL.getAddressById(activeOrders.addressId).addressLine2 + "," + addressBLL.getAddressById(activeOrders.addressId).addressLine3 + "," + addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).cityName + "," + addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).stateName + "," + addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).countryName,
                memberAddressType        = addressType,
                memberCityId             = addressBLL.getAddressById(activeOrders.addressId).cityId,
                memberCountryName        = addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).countryName,
                memberGender             = cartBLL.getMemberbyCartId(activeOrders.cartId).gender,
                memberIsGuest            = cartBLL.getMemberbyCartId(activeOrders.cartId).isGuest,
                memberModifiedDate       = cartBLL.getMemberbyCartId(activeOrders.cartId).dateModified,
                memberJoinDate           = cartBLL.getMemberbyCartId(activeOrders.cartId).dateCreated,
                memberMobNo              = cartBLL.getMemberbyCartId(activeOrders.cartId).mobNo,
                memberStateId            = addressBLL.getCityById(addressBLL.getAddressById(activeOrders.addressId).cityId).stateId,
                orderShippingDescription = activeOrders.description,
                orderStatusId            = activeOrders.statusId,
                orderTaxAmt              = activeOrders.taxAmount,
                orderTotalAmt            = activeOrders.totalAmount,
                orderTotalShippingCharge = activeOrders.shippingCharge,
                productName              = productName.ToString(),
                productDispatchTime      = productDispatchTime.ToString(),
                productId                = productId.ToString(),
                productPrice             = productPrice.ToString(),
                productShippingCharge    = productShippingCharge.ToString(),
                productQty               = productQty.ToString(),
                productCount             = cartProducts.Count(),
            };

            return(updateOrderDetails);
        }