public object RemoveProductFromCart(ShoppingCart cartObj)
        {
            OperationsStatusViewModel OperationsStatusViewModelObj = null;

            try
            {
                OperationsStatusViewModelObj = Mapper.Map <OperationsStatus, OperationsStatusViewModel>(_cart_WishlistBusiness.RemoveProductFromCart(cartObj.ID));
                return(JsonConvert.SerializeObject(new { Result = true, Records = OperationsStatusViewModelObj }));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(new { Result = false, Message = ex.Message }));
            }
        }
Exemple #2
0
        public OperationsStatus InsertOrderForApp(Order orderObj)
        {
            OperationsStatus operationsStatusObj = null;

            try
            {
                ShoppingCart cartObj = new ShoppingCart();
                cartObj.CustomerID             = orderObj.CustomerID;
                cartObj.LocationID             = orderObj.shippingLocationID;
                cartObj.logDetails             = new LogDetails();
                cartObj.logDetails.CreatedDate = orderObj.commonObj.CreatedDate;

                List <OrderDetail>  OrderDetaillist = new List <OrderDetail>();
                List <ShoppingCart> cartlist        = null;
                cartlist = _Cart_WishlistBusiness.GetCustomerShoppingCart(cartObj);
                for (int i = 0; i < cartlist.Count; i++)
                {
                    if (cartlist[i].FreeDeliveryYN == true)
                    {
                        cartlist[i].ShippingCharge = 0;
                    }
                }


                foreach (var i in cartlist)
                {
                    OrderDetail orderDetailObj = new OrderDetail();

                    orderDetailObj.ItemID         = i.ItemID;
                    orderDetailObj.ProductID      = i.ProductID;
                    orderDetailObj.ProductSpecXML = i.ProductSpecXML;//check if the value passed is correct
                    orderDetailObj.ItemStatus     = "1";
                    orderDetailObj.Qty            = i.Qty;
                    orderDetailObj.Price          = i.CurrentPrice;
                    orderDetailObj.TaxAmt         = orderDetailObj.TaxAmt;
                    orderDetailObj.DiscountAmt    = i.Discount;
                    orderDetailObj.CartId         = i.ID;//For Cart Status Update
                    if (i.StockAvailableYN == true)
                    {
                        OrderDetaillist.Add(orderDetailObj);
                    }
                    else
                    {
                        _Cart_WishlistBusiness.RemoveProductFromCart(i.ID);//Updating Shopping Cart Status as DisCard.
                    }
                }
                if (OrderDetaillist.Count > 0)
                {
                    orderObj.OrderDetailsList = OrderDetaillist;
                    orderObj.OrderStatus      = "1";
                    orderObj.CurrencyCode     = "QAR";
                    operationsStatusObj       = InsertOrderHeaderForApp(orderObj);
                    if (operationsStatusObj.StatusCode == 1)
                    {
                        if (orderObj.OrderDetailsList != null)
                        {
                            foreach (var i in orderObj.OrderDetailsList)
                            {
                                i.OrderID   = int.Parse(operationsStatusObj.ReturnValues.ToString());
                                i.commonObj = orderObj.commonObj;
                                InsertOrderDetail(i);
                                _Cart_WishlistBusiness.UpdateShoppingCartStatus(i.CartId);//Updating Shopping Cart Status as Purchased.
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(operationsStatusObj);
        }