Пример #1
0
 private static PurchaseResponse DoPurchase()
 {
     AddToCart.setShippingOptionInfoIfNeeded();
     // ***** NOTE *******
     // THIS WILL FAIL IF ITEM IS SHIPPABLE, WILL ENCOUNTER A NEEDINFO
     return(AddToCart.Purchase());
 }
Пример #2
0
        public ActionResult PaymentMethod()
        {
            Ecommerce.Models.Register.RegisterPro shippingdetails = null;
            try
            {
                shippingdetails =
                    ((Ecommerce.Models.Register.RegisterPro)Session["userId"]);
            }
            catch { }
            ViewBag.shippingDetails = shippingdetails;
            Ecommerce.Areas.admin.Models.ShopingContext shpoing = new Ecommerce.Areas.admin.Models.ShopingContext();
            List <AddToCartBean> cartList = AddToCart.getData();

            if (cartList != null)
            {
                foreach (AddToCartBean bean in cartList)
                {
                    int id = Convert.ToInt32(bean.pid);
                    Ecommerce.Areas.admin.Models.Product.Product prod = shpoing.product.Where(x => x.Id == id).FirstOrDefault();
                    bean.ProductName  = prod.p_name;
                    bean.ProductPrice = float.Parse(prod.p_price.ToString());
                    bean.ProductQty   = 1;
                    bean.TotalPrice   = 1 * bean.ProductPrice;
                    bean.ProductImage = shpoing.uploadImage.Where(x => x.p_id == id).FirstOrDefault().imageURL;
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
            Session["AddList"]  = cartList;
            ViewBag.cartAddItem = cartList;
            return(View());
        }
Пример #3
0
    private static void searchForItemAndAddItemToCart(string itemCategory)
    {
        string itemUrl = PurchaseCurrentOutfit.getItemUrl(itemCategory);

        //Debug.Log(itemUrl);
        AddToCart.AddItemToCart(itemUrl);
    }
Пример #4
0
 public async Task <IActionResult> Product(
     [FromBody] AddToCart.Request request,
     [FromServices] AddToCart addToCart)
 {
     request.UserMark = GetCartUserMark();
     return(Ok(addToCart.Do(request)));
 }
Пример #5
0
 public ShopListPresentationModel(CategoryManagement productTypeManagement, ProductManagement productManagement)
 {
     this._productTypeManagement = productTypeManagement;
     _productManagement          = productManagement;
     _cart    = new AddToCart();
     RowCount = 0;
 }
Пример #6
0
        public ActionResult CartItem()
        {
            Ecommerce.Areas.admin.Models.ShopingContext shpoing = new Ecommerce.Areas.admin.Models.ShopingContext();
            List <AddToCartBean> cartList = AddToCart.getData();

            if (cartList != null)
            {
                foreach (AddToCartBean bean in cartList)
                {
                    int id = Convert.ToInt32(bean.pid);
                    Ecommerce.Areas.admin.Models.Product.Product prod = shpoing.product.Where(x => x.Id == id).FirstOrDefault();
                    bean.ProductName  = prod.p_name;
                    bean.ProductPrice = float.Parse(prod.p_price.ToString());
                    bean.ProductQty   = 1;
                    bean.TotalPrice   = 1 * bean.ProductPrice;
                    bean.ProductImage = shpoing.uploadImage.Where(x => x.p_id == id).FirstOrDefault().imageURL;
                }
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
            Session["AddList"] = cartList;
            return(View(cartList));
        }
Пример #7
0
        public void Addtocart()
        {
            var addtocart = new AddToCart(driver);

            Thread.Sleep(3000);
            addtocart.NavigatoToCheckout();
        }
Пример #8
0
        public async Task <IHttpActionResult> Get(string CookeId, string UserId, string ProductId, string ProductName, string Color, string Size, int Quantity, double Price)
        {
            try
            {
                IRepository <AddToCart> reposity = new Repository <AddToCart>();

                AddToCart item = new AddToCart()
                {
                    CookeId = CookeId,
                    UserId  = UserId,
                    Product = new Product()
                    {
                        ProductId   = ProductId,
                        ProductName = ProductName,
                        Color       = Color,
                        Size        = Size,
                        Quantity    = Quantity,
                        Price       = Price
                    }
                };

                await reposity.CreateAsync(item);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }
Пример #9
0
        public AddToCart AddProductToCart(string id, Cart cart)
        {
            UserMDB    user    = _sportsShopDBContext.GetUser(id);
            ProductMDB product = _sportsShopDBContext.GetProduct(cart.ProductId);

            AddToCart cartAdd = _graphContext
                                .GetRelations <AddToCart>(user, product)
                                .Where(c => c.Status == AddToCart.CartStatus.InCart || c.Status == AddToCart.CartStatus.Deleted || c.Status == AddToCart.CartStatus.Bought)
                                .FirstOrDefault();

            bool itemInCart = cartAdd != null;

            if (itemInCart && (cartAdd.Status == AddToCart.CartStatus.InCart || cartAdd.Status == AddToCart.CartStatus.Deleted || cartAdd.Status == AddToCart.CartStatus.Bought))
            {
                cartAdd.Quantity += cart.Quantity;
                cartAdd.Date      = System.DateTime.Now;
                cartAdd.Status    = AddToCart.CartStatus.InCart;
                _graphContext.UpdateRelation(user, cartAdd, product);
            }
            else
            {
                cartAdd = new AddToCart(cart.Quantity);
                _graphContext.CreateRelation(user, cartAdd, product);
            }


            return(cartAdd);
        }
Пример #10
0
        //post addto cart details
        public int PostCartDetails(AddToCartDto dtls)
        {
            try
            {
                var result = (from r in appDbContext.AddToCart where (r.ProductId == dtls.ProductId && r.OrderDetailsId == dtls.OrderDetailsId && r.IsPurchased == false) select r).ToList();
                if (result.Count == 0)
                {
                    var product    = appDbContext.Product.Where(x => x.Id == dtls.ProductId).FirstOrDefault();
                    var price      = product.Price;
                    var qnty       = dtls.Quantity;
                    var totalPrice = Convert.ToDouble(price) * qnty;
                    var info       = new AddToCart
                    {
                        OrderDetailsId = dtls.OrderDetailsId,
                        ProductId      = dtls.ProductId,
                        Quantity       = dtls.Quantity,
                        TotalPrice     = Convert.ToString(totalPrice),
                    };
                    appDbContext.AddToCart.Add(info);
                    appDbContext.SaveChanges();
                    return(1);
                }


                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        private async void BtnAddToCart_Clicked(object sender, EventArgs e)
        {
            try
            {
                var addToCart = new AddToCart();
                addToCart.Price       = LblPrice.Text;
                addToCart.Qty         = LblQty.Text;
                addToCart.TotalAmount = LblTotalPrice.Text;
                addToCart.ProductId   = productId;
                addToCart.CustomerId  = Preferences.Get("userId", 0);
                var response = await ApiService.AddItemsInCart(addToCart);

                if (response)
                {
                    await DisplayAlert("Done", "Item added to the Cart", "Alright");
                }
                else
                {
                    await DisplayAlert("Oops", "Something gone Wrong", "Cancel");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("warning", ex.Message.ToString(), "Cancel");
            }

            await Navigation.PopModalAsync();
        }
Пример #12
0
        public async Task <bool> AddToCart(AddToCart cart)
        {
            Cart cart1 = new Cart();

            if (cart != null)
            {
                cart1.Cartid = cart.cartId;
                //cart1. = cart.categoryId;
                //cart1.Subid = cart.subCategoryId;
                cart1.Buyerid     = cart.buyerId;
                cart1.Itemid      = cart.itemId;
                cart1.Price       = cart.price;
                cart1.Itemname    = cart.itemName;
                cart1.Description = cart.description;
                cart1.Stockno     = cart.stockNo;
                cart1.Remarks     = cart.remarks;
                cart1.Imagename   = cart.imageName;
            }
            _buyerContext.Cart.Add(cart1);
            var buyercart = await _buyerContext.SaveChangesAsync();

            if (buyercart > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #13
0
        public async Task <AddToCart> GetCartItem(int cartId)
        {
            Cart cart = await _buyerContext.Cart.FindAsync(cartId);

            if (cart == null)
            {
                return(null);
            }
            else
            {
                AddToCart cart1 = new AddToCart();
                cart1.cartId = cart.Cartid;
                //  cart1.categoryId = cart.Categoryid;
                //  cart1.subCategoryId = cart.Subid;
                cart1.buyerId     = cart.Buyerid;
                cart1.itemId      = cart.Itemid;
                cart1.price       = cart.Price;
                cart1.itemName    = cart.Itemname;
                cart1.description = cart.Description;
                cart1.stockNo     = cart.Stockno;
                cart1.remarks     = cart.Remarks;
                cart1.imageName   = cart.Imagename;
                return(cart1);
            }
        }
Пример #14
0
        public async Task <IActionResult> Buy(Resources.Bought bought)
        {
            UserMDB user = _sportsShopDBContext.GetUser(bought.UserId);
            IEnumerable <CartModel> products = bought.Articles;

            foreach (var cart in products)
            {
                ProductMDB product = _sportsShopDBContext.GetProduct(cart.prodId);
                product.UnDisp = product.UnDisp - cart.quantity;
                _sportsShopDBContext.UpdateProduct(product.Id, product);

                AddToCart cartAdd = _graphContext
                                    .GetRelations <AddToCart>(user, product)
                                    .Where(c => c.Status == AddToCart.CartStatus.InCart)
                                    .FirstOrDefault();

                bool itemInCart = cartAdd != null;
                if (itemInCart && cartAdd.Status == AddToCart.CartStatus.InCart)
                {
                    cartAdd.Date   = System.DateTime.Now;
                    cartAdd.Status = AddToCart.CartStatus.Bought;
                }

                if (cartAdd != null)
                {
                    for (int i = 0; i < cartAdd.Quantity; i++)
                    {
                        _graphContext.CreateRelation(user, new Models.Bought(), product);
                    }
                }
                cartAdd.Quantity = 0;
                _graphContext.UpdateRelation(user, cartAdd, product);
            }
            return(Ok(_graphContext.GetRelatives <Models.Bought>(user)));
        }
Пример #15
0
        public async Task <IActionResult> Cart(
            int id,
            [FromServices] GetListsFull getListsFull,
            [FromServices] AddToCart addToCart,
            bool redirectToCheckout = false)
        {
            var mark = GetCartUserMark();
            var list = getListsFull.Do(mark.userId).FirstOrDefault(x => x.Id == id);

            foreach (var product in list.Products)
            {
                await addToCart.Do(new AddToCart.Request
                {
                    UserMark  = mark,
                    ProductId = product.Id,
                    Qty       = product.Qty == 0 ? 1 : product.Qty
                });
            }

            if (redirectToCheckout)
            {
                return(RedirectToPage("/Checkout/Index"));
            }

            return(Ok());
        }
Пример #16
0
        public ActionResult AddToCart(AddToCart model)
        {
            var cart  = db.Books.Find(model.cartId);
            var books = db.Books.Find(model.bookId);

            db.SaveChanges();
            return(View("Index"));
        }
Пример #17
0
        //GET: AddToCart
        public ActionResult AddToCart(int id)
        {
            var model = new AddToCart();

            model.cartId = id;
            model.books  = db.Books.ToList();
            return(View(model));
        }
Пример #18
0
        public JsonResult AddProduct(string pid)
        {
            AddToCartBean aBean = new AddToCartBean();

            aBean.pid = pid;
            AddToCart.AddCart(aBean);
            return(Json(AddToCart.getCartNumberofItem(), JsonRequestBehavior.AllowGet));
        }
Пример #19
0
        public void AddToCartTest()
        {
            AddToCart cart = new AddToCart(driver);

            cart.AddToCartPage();
            string actualResult = cart.validatePage();

            Assert.AreEqual("GO TO CART", actualResult);
        }
Пример #20
0
        //-----------------//



        public ActionResult overQtyCheck(string [] idarray_, string [] qtyarray_)
        {
            if (string.IsNullOrEmpty(Session["UserID"] as string))
            {
                Session["UserID"]      = null;
                Session["FullName"]    = null;
                Session["last_name"]   = null;
                Session["Role_ID"]     = null;
                Session["userDetails"] = null;

                Session.Clear();
                Session.Abandon();
                return(Redirect("~/Accounts/login_signup"));
            }
            else if (Session["Role_ID"].ToString() == "1" || Session["Role_ID"].ToString() == "1009")
            {
                Session["UserID"]      = null;
                Session["FullName"]    = null;
                Session["last_name"]   = null;
                Session["Role_ID"]     = null;
                Session["userDetails"] = null;

                Session.Clear();
                Session.Abandon();
                return(Redirect("~/Accounts/login_signup"));
            }
            else
            {
                AddToCart        addtocart_   = new AddToCart();
                List <AddToCart> filterbyid   = new List <AddToCart>();
                List <AddToCart> filterbyqty_ = new List <AddToCart>();

                var dbData = db.AddToCarts.ToList();

                for (int i = 0; i < idarray_.Length; i++)
                {
                    var idddd               = idarray_[i];
                    var iddddqtt            = qtyarray_[i] == "" ? "1" : qtyarray_[i];
                    List <AddToCart> sorted = dbData.Where(x => x.AddToCart_id == Convert.ToInt16(idddd) && x.stock < Convert.ToInt16(iddddqtt)).ToList();

                    foreach (var item in sorted)
                    {
                        AddToCart addtocart = new AddToCart();
                        addtocart.Product_name = item.Product_name;
                        addtocart.AddToCart_id = item.AddToCart_id;
                        addtocart.stock        = item.stock;
                        filterbyid.Add(addtocart);
                    }
                }

                var json = JsonConvert.SerializeObject(filterbyid);

                return(Json(json, JsonRequestBehavior.AllowGet));
            }
        }
Пример #21
0
        public ActionResult UpdateCart(FormCollection formcollection)
        {
            string[] qty = formcollection.GetValues("quantity");
            string[] pid = formcollection.GetValues("Id");

            RegisterUser sessionReg = (RegisterUser)Session["Registration"];

            if (sessionReg == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (sessionReg.Id == 0)
            {
                List <ViewCart> viewList = (List <ViewCart>)Session["ListofCartItems"];

                foreach (ViewCart v in viewList)
                {
                    //find [v.Product_Id] in array UI->pid[]
                    // and put UI->qty[] in v.Quantity
                    for (int p = 0; p < pid.Length; p++)
                    {
                        if (v.Product_Id == Int32.Parse(pid[p]))
                        {
                            v.Quantity = Int32.Parse(qty[p]);
                        }
                    }
                }

/*
 *              viewList.Clear();
 *              for (int p = 0; p < pid.Length; p++)
 *              {
 *                  ViewCart addCart = new ViewCart();
 *                  addCart.Product_Id = Int32.Parse(pid[p]);
 *                  addCart.Quantity = Int32.Parse(qty[p]);
 *                  //addCart.UserId = sessionReg.Id;
 *                  viewList.Add(addCart);
 *              }
 */
            }
            else
            {
                DBConn db = new DBConn();
                for (int v = 0; v < qty.Length; v++)
                {
                    AddToCart addCart = new AddToCart();
                    addCart.Product_Id = Int32.Parse(pid[v]);
                    addCart.Quantity   = Int32.Parse(qty[v]);
                    addCart.UserId     = sessionReg.Id;
                    db.UpdateCart(addCart);
                }
            }
            return(RedirectToAction("Cart", "Home"));
        }
Пример #22
0
        public async Task <IActionResult> OnPost([FromServices] AddToCart addToCart)
        {
            var stockAdded = await addToCart.ExecAsync(CartDto);

            if (stockAdded)
            {
                return(RedirectToPage("Cart"));
            }

            return(Page()); // TODO: add warning that stock is on hold
        }
        public ActionResult AddToCart(int?id)
        {
            if (Session["ACategory"] != null)
            {
                if (Session["ACategory"].ToString() == "Trading" && Session["ACategory"] != null)
                {
                    var good = db.TradingGoods.Find(id);

                    AddToCart add       = new AddToCart();
                    var       sesssonid = Session["userEmail"].ToString();

                    var cartitem = db.addToCarts.FirstOrDefault(t => t.ProductId == id && t.SessonId == sesssonid);

                    if (cartitem == null)
                    {
                        if (good.Quantity > 0)
                        {
                            add.GoodName  = good.GoodName;
                            add.price     = good.RetailRate;
                            add.Quantity  = good.Quantity;
                            add.Subtotal  = Convert.ToDecimal(good.Quantity * good.RetailRate);
                            add.ProductId = good.Id;
                            add.SessonId  = Session["userEmail"].ToString();
                            if (good.Vat == true)
                            {
                                var vat = db.vat.Where(t => t.Id == 1).FirstOrDefault();
                                add.VatAmount = vat.VatPercent;
                                add.vat       = vat.VatPercent * add.Subtotal / 100;
                            }
                            else
                            {
                                add.VatAmount = 0;
                                add.vat       = 0;
                            }
                            db.addToCarts.Add(add);
                            db.SaveChanges();
                            TempData["Message"] = "Added to cart Successfully";
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            TempData["Message"] = " Please update quantity and try again";
                            return(RedirectToAction("Index"));
                        }
                    }
                    else
                    {
                        TempData["Message"] = "Already exist in cart";
                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
        }
Пример #24
0
        public ActionResult PaymentMethod_Post()
        {
            Ecommerce.Areas.admin.Models.ShopingContext shpoing =
                new Ecommerce.Areas.admin.Models.ShopingContext();
            int c_id = ((Ecommerce.Models.Register.RegisterPro)Session["userId"]).Id;
            List <AddToCartBean> cartList = AddToCart.getData();

            if (cartList != null)
            {
                int   qty    = 0;
                float tprice = 0;
                foreach (AddToCartBean bean in cartList)
                {
                    qty    = 1 + qty;
                    tprice = tprice + bean.ProductPrice;
                }
                OrderDetails OD = new OrderDetails();
                OD.c_id       = c_id;
                OD.datetime   = DateTime.Now;
                OD.status     = 1;
                OD.totalPrice = tprice;
                OD.totalQty   = qty;
                shpoing.OrderDetails.Add(OD);
                shpoing.SaveChanges();
                Order ord;
                foreach (AddToCartBean bean in cartList)
                {
                    int id = Convert.ToInt32(bean.pid);
                    Ecommerce.Areas.admin.Models.Product.Product prod = shpoing.product.Where(x => x.Id == id).FirstOrDefault();
                    ord                = new Order();
                    ord.c_id           = c_id;
                    ord.OrderDetailsID = OD.Id;
                    ord.date           = DateTime.Now;
                    ord.order_status   = 1;
                    ord.p_id           = Convert.ToInt32(bean.pid);
                    ord.price          = bean.ProductPrice * 1;
                    ord.qty            = 1;
                    shpoing.Order.Add(ord);
                    shpoing.SaveChanges();
                }
                // Session.Remove("AddList");
            }
            Ecommerce.Models.Register.RegisterPro shippingdetails = null;
            try
            {
                shippingdetails =
                    ((Ecommerce.Models.Register.RegisterPro)Session["userId"]);
            }
            catch { }
            ViewBag.shippingDetails = shippingdetails;
            ViewBag.cartAddItem     = (List <AddToCartBean>)Session["AddList"];
            return(RedirectToAction("ThankYou", "Confirm"));
        }
Пример #25
0
        public async Task <IActionResult> AddToCart(AddToCart cart)
        {
            bool cart1 = await _iitemManager.AddToCart(cart);

            if (cart1)
            {
                return(Ok());
            }
            else
            {
                return(Ok("Item not added"));
            }
        }
Пример #26
0
        public async Task <IActionResult> OnPost([FromServices] AddToCart addToCart)
        {
            var stockAdded = await addToCart.Do(CartViewModel);

            if (stockAdded)
            {
                return(RedirectToPage("Index"));
            }
            else
            {
                return(Page());
            }
        }
Пример #27
0
        public async Task <IActionResult> GetCartItem(int cartid)
        {
            AddToCart cart1 = await _iitemManager.GetCartItem(cartid);

            if (cart1 != null)
            {
                return(Ok(cart1));
            }
            else
            {
                return(Ok("Cart is Null"));
            }
        }
Пример #28
0
        public async Task <bool> AddToCart(AddToCart cart)
        {
            bool buyercart = await _iitemRepository.AddToCart(cart);

            if (buyercart)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #29
0
        public async Task <AddToCart> GetCartItem(int cartid)
        {
            AddToCart cart = await _iitemRepository.GetCartItem(cartid);

            if (cart != null)
            {
                return(cart);
            }
            else
            {
                return(null);
            }
        }
Пример #30
0
        public ActionResult addCart(FormCollection form, int Id)
        {
            DBConn        db            = new DBConn();
            RegisterUser  sessionReg    = (RegisterUser)Session["Registration"];
            CartViewModel cartViewModel = null;

            if (sessionReg == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            else
            {
                if (sessionReg.Id == 0)
                {
                    //Its guest user.
                    //Get cart from session.
                    if (cartViewModel == null)
                    {
                        //If its not in session already, create and put new one.
                        cartViewModel = new CartViewModel();
                        cartViewModel.ListofCartItems = (List <ViewCart>)Session["ListofCartItems"];
                        if (cartViewModel.ListofCartItems == null)
                        {
                            cartViewModel.ListofCartItems = new List <ViewCart>();
                            Session["ListofCartItems"]    = cartViewModel.ListofCartItems;
                        }
                    }

                    Product product = db.getProduct(Id);

                    ViewCart addCart = new ViewCart();
                    addCart.Quantity    = Convert.ToInt32(form["QUANTITY"].ToString());
                    addCart.Product_Id  = Id;
                    addCart.Id          = sessionReg.Id;
                    addCart.Photo       = product.Photo;
                    addCart.ProductName = product.ProductName;
                    addCart.Price       = product.Price;
                    addCart.Total       = product.Price * addCart.Quantity;
                    cartViewModel.ListofCartItems.Add(addCart);
                }
                else
                {
                    AddToCart addCart = new AddToCart();
                    addCart.Quantity   = Convert.ToInt32(form["QUANTITY"].ToString());
                    addCart.Product_Id = Id;
                    addCart.UserId     = sessionReg.Id;
                    db.SaveToCart(addCart);
                }
                return(RedirectToAction("Cart", "Home"));
            }
        }