コード例 #1
0
        public HttpResponseMessage GetCartItemCount(string userId)
        {
            var count = logic.GetCartItems(userId).Count;

            if (count == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, ""));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, count));
            }
        }
コード例 #2
0
        public void CreateUserSubscription()
        {
            CartLogic cartlogic = new CartLogic();

            if (usr != null)
            {
                var itemList = cartlogic.GetCartItems(usr.UserId);
                if (itemList.Count > 0)
                {
                    int i = 0;
                    foreach (var cartItem in itemList)
                    {
                        string           userId = usr.UserId;
                        UserSubscription subs   = new UserSubscription();
                        subs.SubscriptionTypeId = cartItem.SubscriptionTypeId;
                        subs.Quantity           = cartItem.Quantity;
                        subs.UserId             = userId;
                        subs.SubscriptionDate   = DateTime.Now;
                        var data = logic.CreateUserSubscription(subs, usr.OrganizationId);
                        i++;
                    }
                    Assert.IsTrue(i > 0);
                }
                else
                {
                    Assert.Fail("Specified User not EXist in the application");
                }
            }
            else
            {
                Assert.Fail("Specified User not EXist in the application");
            }
        }
コード例 #3
0
        async void getData(App app = null)
        {
            try
            {
                if (Application.Current.Properties.ContainsKey("user_id"))
                {
                    Config.ShowDialog();
                    var cartItems =
                        await CartLogic.GetCartItems(int.Parse(Application.Current.Properties["user_id"].ToString()));

                    if (cartItems.status == 200)
                    {
                        emptyContent.IsVisible = false;
                        mainContent.IsVisible  = true;
                        ViewModel.CartItems    = new ObservableCollection <Cart>(cartItems.data.cart_data);
                        decimal total        = 0;
                        int     itemQuantity = 0;
                        foreach (var item in cartItems.data.cart_data)
                        {
                            total        += decimal.Parse(item.total_without_tax);
                            itemQuantity += 1;
                        }
                        //t_total.Text = "Rs " + total;
                        decimal myTotal = (Convert.ToDecimal(cartItems.delivery_charges) + Convert.ToDecimal(total));
                        t_quantity.Text = (itemQuantity == 1) ? itemQuantity + " Item" : itemQuantity + " Items";
                        //t_delivery.Text = "Rs " + Convert.ToDecimal(cartItems.delivery_charges);
                        m_total.Text   = "Rs " + total;
                        b_total.Text   = "Rs " + total;
                        TotalLimit     = total;
                        minOrderAmount = cartItems.minimum_order_amount;
                        //t_total.Text = "Rs " + myTotal;
                        //l_grand_total.Text = "Grand Total";
                        //b_quantity.Text = itemQuantity + " Items";
                        if (cartItems.data.cart_data.Any())
                        {
                            b_cart.IsVisible = true;
                            //header.IsVisible = true;
                        }
                        Config.HideDialog();
                    }
                    else
                    {
                        EmptyCart();
                    }
                }
                else
                {
                    EmptyCart();
                }
            }
            catch (Exception ex)
            {
                Config.HideDialog();
                EmptyCart();
                Config.ErrorStore("CartPage-getData", ex.Message);
                Config.ErrorSnackbarMessage(Config.ApiErrorMessage);
                //await DisplayAlert("Alert", Config.ApiErrorMessage, "Ok");
            }
        }
コード例 #4
0
        public PurchaseOrder OfflinePayment(string userId)
        {
            CartLogic          cartLogic  = new CartLogic();
            PurchaseOrderLogic orderLogic = new PurchaseOrderLogic();
            PurchaseOrder      order      = new PurchaseOrder();

            try
            {
                var items = cartLogic.GetCartItems(userId);
                if (items.Count == 0)
                {
                    return(null);
                }

                order.UserId          = userId;
                order.CreatedDate     = DateTime.Now.Date;
                order.PurchaseOrderNo = orderLogic.CreatePONumber();
                List <PurchaseOrderItem> poItemList = new List <PurchaseOrderItem>();
                var total = 0.0;
                foreach (var item in items)
                {
                    PurchaseOrderItem poItem = new PurchaseOrderItem()
                    {
                        Quantity       = item.Quantity,
                        SubscriptionId = item.SubscriptionTypeId
                    };
                    poItemList.Add(poItem);
                    total += item.Price;
                }
                order.Total = total;
                var obj = orderLogic.CreatePurchaseOrder(order);
                if (obj != null && poItemList.Count > 0)
                {
                    POItemLogic itemLogic = new POItemLogic();
                    itemLogic.CreateItem(poItemList, obj.Id);

                    foreach (var item in items)
                    {
                        item.IsPurchased = true;
                        cartLogic.UpdateCartItem(item);
                    }
                }
                return(obj);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
            return(null);
        }
コード例 #5
0
        public SubscriptionList OnlinePayment(string userId)
        {
            List <UserSubscription> subsList = new List <UserSubscription>();
            CartLogic cartLogic = new CartLogic()
            {
                UserManager = UserManager,
                RoleManager = RoleManager
            };
            UserSubscriptionLogic userSubLogic = new UserSubscriptionLogic()
            {
                UserManager = UserManager,
                RoleManager = RoleManager
            };
            var cartItems = cartLogic.GetCartItems(userId);

            if (cartItems.Count > 0)
            {
                foreach (CartItem item in cartItems)
                {
                    UserSubscription usersubs = new UserSubscription()
                    {
                        UserId             = userId,
                        SubscriptionTypeId = item.SubscriptionTypeId,
                        ActivationDate     = DateTime.Now.Date,
                        Quantity           = item.Quantity
                    };
                    usersubs.ExpireDate = usersubs.ActivationDate.AddDays(item.SubType.ActiveDays).Date;
                    subsList.Add(usersubs);
                }
                var dataList = userSubLogic.CreateUserSubscriptionList(subsList, userId);
                foreach (var item in cartItems)
                {
                    item.IsPurchased = true;
                    cartLogic.UpdateCartItem(item);
                }
                return(dataList);
            }
            else
            {
                ErrorMessage = cartLogic.ErrorMessage;
                return(null);
            }
        }
コード例 #6
0
        public ActionResult remove_from_cart(string id)
        {
            var item = cart_Service.GetCartItems().FirstOrDefault(x => x.cart_item_id == id);

            if (item != null)
            {
                cart_Service.RemoveItemFromCart(id: id);
                return(RedirectToAction("ShoppingCart"));
            }
            else
            {
                return(RedirectToAction("Not_Found", "Error"));
            }
        }
コード例 #7
0
        async void getData()
        {
            try
            {
                if (Application.Current.Properties.ContainsKey("user_id"))
                {
                    Config.ShowDialog();
                    var cartItems =
                        await CartLogic.GetCartItems(int.Parse(Application.Current.Properties["user_id"].ToString()));

                    if (cartItems.status == 200)
                    {
                        if (!string.IsNullOrEmpty(cartItems.coupon_code_id))
                        {
                            CouponCodeId = cartItems.coupon_code_id;
                        }
                        if (string.IsNullOrEmpty(cartItems.coupon_code_id))
                        {
                            IsCodeVisible.IsVisible  = false;
                            IsApplyVisible.IsVisible = true;
                        }
                        else
                        {
                            IsCodeVisible.IsVisible  = true;
                            IsApplyVisible.IsVisible = false;
                            Code.Text = cartItems.coupon_code;
                        }
                        _cart = cartItems;
                        listProducts.ItemsSource = cartItems.data.cart_data;

                        if (_cart.data.user_address == null && _address_id == 0)
                        {
                            addAddress.IsVisible = false;
                        }
                        else
                        {
                            addAddress.IsVisible = true;
                            if (_address_id == 0)
                            {
                                _address_id      = cartItems.data.user_address.id;
                                _full_address    = cartItems.data.user_address.full_address;
                                _address_type    = cartItems.data.user_address.address_type;
                                _default_address = cartItems.data.user_address.default_address == 0 ? "" : " (Default)";
                            }
                            addAddress.Text = _address_id != 0 ? _full_address : cartItems.data.user_address.full_address;
                        }
                        item_total.Text     = "Rs " + cartItems.total_amount;
                        delivery_fee.Text   = "Rs " + Convert.ToDecimal(cartItems.delivery_charges);
                        to_pay.Text         = "Rs " + cartItems.cost;
                        total_discount.Text = "- Rs " + cartItems.promo_amount;
                        Config.HideDialog();
                        if (string.IsNullOrEmpty(cartItems.coupon_code_id))
                        {
                            discount_layout.IsVisible = false;
                        }
                        else
                        {
                            discount_layout.IsVisible = true;
                        }
                    }
                    else
                    {
                        EmptyCart();
                    }
                }
                else
                {
                    EmptyCart();
                }
                Config.HideDialog();
            }
            catch (Exception ex)
            {
                Config.ErrorStore("CheckoutPage-getData", ex.Message);
                Config.HideDialog();
                EmptyCart();
                Config.ErrorSnackbarMessage(Config.ApiErrorMessage);
            }
        }
コード例 #8
0
        public void GetCartDetails()
        {
            var obj = cartLogic.GetCartItems(usr.UserId);

            Assert.IsTrue(obj.Count > 0);
        }