Exemplo n.º 1
0
        public HttpResponseMessage getCartByRetailerId([FromBody] AddToCartModel lstaddtocart)
        {
            var result = _order.getProductCartByUserId(lstaddtocart);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, result);

            return(response);
        }
Exemplo n.º 2
0
        private async void display(float number, MyViewHolder myViewHolder)
        {
            myViewHolder.txtQuan.Text = "" + number;

            AddToCartModel addToCartModel = new AddToCartModel();

            addToCartModel.UserId       = Convert.ToInt32(sessionManagement.getUserDetails().Get(BaseURL.KEY_ID).ToString());
            addToCartModel.ItemMasterId = Convert.ToInt32(list[myViewHolder.Position].ItemMasterId);
            var deleteURI = BaseURL.CartQuantityUpdate + "?userid=" + addToCartModel.UserId + "&itemMasterId=" + addToCartModel.ItemMasterId.ToString() + "&qty=" + number;

            using (var client = new HttpClient())
            {
                StringContent content  = new StringContent("");
                var           response = await client.PostAsync(deleteURI, content);

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var getDataUrl        = new System.Uri(BaseURL.Get_CartList + addToCartModel.UserId);
                    var storeCartResponse = await client.GetStringAsync(getDataUrl);

                    sessionManagement.SetStoreCart(storeCartResponse);
                }
            }
            updateintent();
            NotifyDataSetChanged();
        }
Exemplo n.º 3
0
        public HttpResponseMessage addProductTocart([FromBody] AddToCartModel lstaddtocart)
        {
            var result = _order.AddToCart(lstaddtocart);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, result);

            return(response);
        }
        public async Task <ActionResult <AddToCartModel> > PostAddToCartModel([FromForm] AddToCartModel addToCartModel)
        {
            _context.addToCarts.Add(addToCartModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAddToCartModel", new { id = addToCartModel.Id }, addToCartModel));
        }
        //______________________________________________________________________________________

        /// <summary>
        /// This method is used to get all the products details present in the cart of a particular user.
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>

        public static List <AddToCartModel> GetFromCart(string userid)
        {
            List <AddToCartModel> listCartModel = new List <AddToCartModel>();

            Database  _db    = EnterpriseLibraryContainer.Current.GetInstance <Database>("LetsShopConnString");
            DbCommand cmdObj = _db.GetStoredProcCommand("GetFromCart");

            _db.AddInParameter(cmdObj, "@UserId", DbType.String, userid);

            using (IDataReader dataReader = _db.ExecuteReader(cmdObj))
            {
                while (dataReader.Read())
                {
                    AddToCartModel cartmodel = new AddToCartModel();
                    Product        prod      = new Product();
                    Cart           cart      = new Cart();
                    prod.ProductId          = Convert.ToInt32(dataReader["ProductId"]);
                    prod.ProductName        = dataReader["ProductName"].ToString();
                    prod.ProductDescription = dataReader["ProductDescription"].ToString();
                    prod.Price        = Double.Parse(dataReader["Price"].ToString());
                    cart.Quantity     = Convert.ToInt32(dataReader["Quantity"]);
                    cartmodel.Product = prod;
                    cartmodel.Cart    = cart;
                    listCartModel.Add(cartmodel);
                }
            }
            return(listCartModel);
        }
Exemplo n.º 6
0
        public JsonResult RemoveQtyToCartFun(AddToCartModel objmodel, HttpContextBase httpContext)
        {
            List <AddToCartModel> ListAddtoCart        = new List <AddToCartModel>();
            List <AddToCartModel> CookiesListAddtoCart = null;

            if (Services.GetCookie(httpContext, "addtocart") != null)
            {
                CookiesListAddtoCart = Services.GetMyCart(httpContext, _JwtTokenManager);
                //  ListAddtoCart.Add(objmodel);
                List <AddToCartModel> ListuniqueValues = uniqueValues(CookiesListAddtoCart, objmodel, true);
                // CookiesListAddtoCart.AddRange(ListAddtoCart);

                // var jsonList = JsonConvert.SerializeObject(CookiesListAddtoCart);
                var jsonList = JsonConvert.SerializeObject(ListuniqueValues);
                Services.SetCookie(httpContext, "addtocart", _JwtTokenManager.GenerateToken(jsonList));
                return(Json(jsonList));
            }
            else
            {
                ListAddtoCart.Add(objmodel);
                var jsonList = JsonConvert.SerializeObject(ListAddtoCart);
                Services.SetCookie(httpContext, "addtocart", _JwtTokenManager.GenerateToken(jsonList));
                return(Json(jsonList));
            }
        }
        public async Task <IActionResult> PutAddToCartModel(int id, AddToCartModel addToCartModel)
        {
            if (id != addToCartModel.Id)
            {
                return(BadRequest());
            }

            _context.Entry(addToCartModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AddToCartModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 8
0
        public IActionResult RemoveFromCart([FromForm] AddToCartModel model)
        {
            ResponseModel responseModel = new ResponseModel();

            if (ModelState.IsValid)
            {
                string authorizeTokenKey = _httpContextAccessor.HttpContext.Request.Headers["AuthorizeTokenKey"];
                var    singleUser        = _context.Users.Where(x => x.AuthorizeTokenKey == authorizeTokenKey).AsNoTracking();
                if (singleUser.Any())
                {
                    var user    = singleUser.FirstOrDefault();
                    var message = _classBookService.RemoveShoppingCart(user, model);
                    responseModel.Message = message;
                    return(StatusCode((int)HttpStatusCode.OK, responseModel));
                }
                else
                {
                    return(StatusCode((int)HttpStatusCode.Unauthorized, responseModel));
                }
            }
            else
            {
                return(StatusCode((int)HttpStatusCode.BadRequest, ModelState));
            }
        }
Exemplo n.º 9
0
        public void Add(string userId, AddToCartModel model)
        {
            var order = context.Orders.FirstOrDefault(x => x.UserId == userId && x.IsProcessed == false);

            if (order != null)
            {
                if (CheckProduct(order.Id, model.ProductId))
                {
                    var orderProduct = context.OrderProducts.First(x => x.OrderId == order.Id && x.ProductId == model.ProductId);
                    orderProduct.Count += model.Count;
                    context.OrderProducts.Update(orderProduct);
                }
                else
                {
                    var orderProduct = mapper.Map <OrderProduct>(model);
                    orderProduct.OrderId = order.Id;
                    context.OrderProducts.Add(orderProduct);
                }
            }
            else
            {
                order = Create(userId);
                var orderProduct = mapper.Map <OrderProduct>(model);
                orderProduct.OrderId = order.Id;
                context.OrderProducts.Add(orderProduct);
            }

            context.SaveChanges();
        }
Exemplo n.º 10
0
 public ActionResult AddToCart(AddToCartModel model)
 {
     try
     {
         if (Session["cart"] == null)
         {
             List <AddToCartModel> li = new List <AddToCartModel>();
             li.Add(model);
             Session["cart"]  = li;
             Session["count"] = 1;
         }
         else
         {
             List <AddToCartModel> li = (List <AddToCartModel>)Session["cart"];
             //List<Mobiles> li = (List<Mobiles>)Session["cart"];
             li.Add(model);
             Session["cart"]  = li;
             Session["count"] = Convert.ToInt32(Session["count"]) + 1;
         }
         int count = Convert.ToInt32(Session["count"]);
         return(Json(new { Type = "success", Count = count, }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { Type = "error", Count = 0, }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 11
0
        public void AddToCart(AddToCartModel model)
        {
            int            quantity       = model.Quantity;
            ProductVariant productVariant = model.ProductVariant;
            var            data           = model.Data;

            var      cart     = _cartBuilder.BuildCart();
            CartItem cartItem = _getExistingCartItem.GetExistingItem(cart, productVariant, data);

            if (cartItem != null)
            {
                cartItem.Quantity += quantity;
                _session.Transact(session => session.Update(cartItem));
            }
            else
            {
                cartItem = new CartItem
                {
                    Item     = productVariant,
                    Quantity = quantity,
                    UserGuid = _getUserGuid.UserGuid,
                    Data     = data
                };
                _session.Transact(session => session.Save(cartItem));
                var cartItemData = cartItem.GetCartItemData();
                cart.Items.Add(cartItemData);
            }
        }
Exemplo n.º 12
0
 public IActionResult AddToUserCart(AddToCartModel addToCartModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             UserCartDetails cartModel = CartHelper.BindUserCartDetails(addToCartModel);
             cartModel.CreatedOn = DateTime.Now;
             long cartId = iCart.AddToCart(cartModel);
             if (cartId > 0)
             {
                 //return Ok(ResponseHelper.Success(MessageConstants.AddedToCart));
                 return(Ok(ResponseHelper.Success(cartId)));
             }
             else if (cartId == ReturnCode.AlreadyExist.GetHashCode())
             {
                 return(Ok(ResponseHelper.Error(MessageConstants.ExistInCart)));
             }
             else
             {
                 return(Ok(ResponseHelper.Error(MessageConstants.NotAddedToCart)));
             }
         }
         else
         {
             return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
         return(Ok(ResponseHelper.Error(ex.Message)));
     }
 }
Exemplo n.º 13
0
 public ProductVariantModel()
 {
     GiftCard                 = new GiftCardModel();
     ProductVariantPrice      = new ProductVariantPriceModel();
     PictureModel             = new PictureModel();
     AddToCart                = new AddToCartModel();
     ProductVariantAttributes = new List <ProductVariantAttributeModel>();
 }
Exemplo n.º 14
0
 public ItemDetailsModel()
 {
     DefaultPictureModel = new PictureModel();
     PictureModels       = new List <PictureModel>();
     ItemPrice           = new ItemOverviewModel.ItemPriceModel();
     AddToCart           = new AddToCartModel();
     PlaceBid            = new PlaceBidModel();
 }
Exemplo n.º 15
0
        public string SaveWishlist(AddToCartModel objmodel)
        {

            var _request = JsonConvert.SerializeObject(objmodel);
            ResponseModel ObjResponse = CommonFile.GetApiResponse(Constant.ApiSaveWishlist, _request);

            return ObjResponse.Response;
        }
Exemplo n.º 16
0
        public async Task <IActionResult> AddToCart(long customerId, [FromBody] AddToCartModel model)
        {
            var currentUser = await _workContext.GetCurrentUser();

            await _cartService.AddToCart(customerId, currentUser.Id, model.ProductId, model.Quantity);

            return(Accepted());
        }
Exemplo n.º 17
0
        public async Task <IActionResult> AddToCart([FromBody] AddToCartModel model)
        {
            var currentUser = await _workContext.GetCurrentUser();

            _cartService.AddToCart(currentUser.Id, model.ProductId, model.Quantity);

            return(RedirectToAction("AddToCartResult", new { productId = model.ProductId }));
        }
Exemplo n.º 18
0
        public JsonResult CanAddQuantity(AddToCartModel model)
        {
            CanAddQuantityValidationResult result = _cartValidationService.CanAddQuantity(model);

            return(result.Valid
                ? Json(true, JsonRequestBehavior.AllowGet)
                : Json(result.Message, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 19
0
        public JsonResult AddToCart(AddToCartModel objmodel)
        {
            AddToCart objAddToCart = new AddToCart();


            return objAddToCart.AddToCartFun(objmodel, this.ControllerContext.HttpContext);

        }
Exemplo n.º 20
0
        public async Task <IActionResult> AddToCart([FromBody] AddToCartModel model)
        {
            var currentUser = await _repository.GetCurrentUser();

            CartItem cartItem = _cartService.AddToCart(currentUser.Id, model.ProductId, model.VariationName, model.Quantity);


            return(Ok());
        }
Exemplo n.º 21
0
        public ResponseModel GetWishlist(AddToCartModel objModel)
        {
            var _result = _instance.GetWishlist(objModel);

            return(new ResponseModel()
            {
                Response = JsonConvert.SerializeObject(_result), Success = true
            });
        }
Exemplo n.º 22
0
        public ResponseModel SaveWishlist(AddToCartModel objModel)
        {
            var _result = _instance.SaveWishlist(objModel);

            return(new ResponseModel()
            {
                Response = _result.Response, Success = _result.Success.Value
            });
        }
Exemplo n.º 23
0
        public IActionResult AddToCart(AddToCartModel model)
        {
            Product product = _productProvider.GetProduct(model.Id);
            IShoppingCartProvider provider = (IShoppingCartProvider)HttpContext.RequestServices.GetService(typeof(IShoppingCartProvider));

            provider.AddToCart(GetUserSession(), GetCartSummary(), product, model.Quantity);

            return(RedirectToAction("Product", "Product", new { id = model.Id, productName = BaseModel.RouteFriendlyName(product.Name) }));
        }
Exemplo n.º 24
0
 public ActionResult <ProductModel> RemoveCartItem(AddToCartModel model)
 {
     if (model.Username == null)
     {
         return(NotFound());
     }
     cartService.RemoveFromCart(model.Id, model.Username);
     return(RedirectToAction("GetShopppingCartByUser"));
 }
Exemplo n.º 25
0
 public ProductDetailsModel()
 {
     DefaultPictureModel = new PictureModel();
     PictureModels = new List<PictureModel>();
     GiftCard = new GiftCardModel();
     ProductPrice = new ProductPriceModel();
     AddToCart = new AddToCartModel();
     ProductVariantAttributes = new List<ProductVariantAttributeModel>();
     AssociatedProducts = new List<ProductDetailsModel>();
 }
Exemplo n.º 26
0
        private string GetAddToCartScript(AddToCartModel model)
        {
            var trackingScript = _facebookPixelSettings.AddToCartScript + "\n";

            trackingScript = trackingScript.Replace("{PRODUCTID}", model.ProductId);
            trackingScript = trackingScript.Replace("{QTY}", model.Quantity.ToString("N0"));
            trackingScript = trackingScript.Replace("{AMOUNT}", model.DecimalPrice.ToString("F2", CultureInfo.InvariantCulture));
            trackingScript = trackingScript.Replace("{CURRENCY}", _workContext.WorkingCurrency.CurrencyCode);
            return(trackingScript);
        }
Exemplo n.º 27
0
 public ProductDetailsModel()
 {
     DefaultPictureModel      = new PictureModel();
     PictureModels            = new List <PictureModel>();
     GiftCard                 = new GiftCardModel();
     ProductPrice             = new ProductPriceModel();
     AddToCart                = new AddToCartModel();
     ProductVariantAttributes = new List <ProductVariantAttributeModel>();
     AssociatedProducts       = new List <ProductDetailsModel>();
 }
Exemplo n.º 28
0
        public void CartItemManager_AddToCart_AddsAnItemToTheCart()
        {
            var addToCartModel = new AddToCartModel {
                ProductVariant = _productVariant, Quantity = 1
            };

            _cartItemManager.AddToCart(addToCartModel);

            _cartModel.Items.Should().HaveCount(1);
        }
Exemplo n.º 29
0
        public void CartItemManager_AddToCart_ShouldPersistToDb()
        {
            var addToCartModel = new AddToCartModel {
                ProductVariant = _productVariant, Quantity = 1
            };

            _cartItemManager.AddToCart(addToCartModel);

            Session.QueryOver <CartItem>().RowCount().Should().Be(1);
        }
Exemplo n.º 30
0
        public async Task <IActionResult> AddToCart([FromBody] AddToCartModel model)
        {
            var currentUser = await _workContext.GetCurrentUser();

            //   var result = await _cartService.AddToCart(currentUser.Id, model.ProductId, model.Quantity);
            var result2 = AddLineaCarrito(GetIP(), GetSession(), model.ProductId, model.Quantity);

            if (result2.status == "OK")
            {
                return(RedirectToAction("AddToCartResult", new { productId = model.ProductId }));
            }
            else
            {
                return(Ok(new { Error = true, Message = result2.explained }));
            }
            //         function CRGDSPApigetBasketLine2($nIdentifier, $nCant, $nLong, $nWidth, $nThick) // add new basket line with data structure json
            //         {
            //$formData = array(
            //          "codeidentifier"    => (string)$nIdentifier,
            //          "cant"          => (string)$nCant,
            //          "long"      => (string)$nLong,
            //          "width"         => (string)$nWidth,
            //          "thick"         => (string)$nThick,
            //          "token"         => unserializeObj($_SESSION["_ObjSession"])->ActualToken,
            //          "ipbase64"  => $_SESSION["_IpAddressSession"]
            //         );
            //$response = getPromisePost($_SESSION["CRGlobalUrl"]. "/RIEWS/webapi/PrivateServices/basketline2W", $formData);
            //             if ($response->status == "OK")
            //   {
            //    $this->explained = $response->explained;
            //    $this->ActualLineNumber = parseInt($response->newlinenumber);
            //    $this->statusNewLine = 1;  //0-original, 1-live, 2-fault, 3-dont auctorization
            //         }
            //else
            //         {
            //    $this->explained = $response->explained;
            //             if ($response->status == "1001")
            //       {
            // $this->statusNewLine = 2;  //0-original, 1-live, 2-fault, 3-dont auctorization
            //             }
            //    else
            //             {
            //                 if ($response->status == "999")
            //           {
            //     $this->statusNewLine = 3;  //0-original, 1-live, 2-fault, 3-dont auctorization
            //                 }
            //        else
            //                 {
            //     $this->explained = "error response";
            //     $this->statusNewLine = 2;  //0-original, 1-live, 2-fault, 3-dont auctorization
            //                 }
            //             }
            //         }
            //     }
        }
Exemplo n.º 31
0
        public async Task <IActionResult> Add(AddToCartModel addToCart, CancellationToken cancellationToken)
        {
            await _serviceClient.ProcessAsync(
                new AddOrUpdateProductInCart(
                    Guid.NewGuid(),
                    addToCart.ProductId,
                    HttpContext.Session.Id, 1),
                CancellationToken.None);

            return(Redirect(addToCart.ReturnUrl));
        }
Exemplo n.º 32
0
 public ProductDetailsModel()
 {
     Manufacturers = new List<ManufacturerOverviewModel>();
     GiftCard = new GiftCardModel();
     ProductPrice = new ProductPriceModel();
     AddToCart = new AddToCartModel();
     ProductVariantAttributes = new List<ProductVariantAttributeModel>();
     AssociatedProducts = new List<ProductDetailsModel>();
     BundledItems = new List<ProductDetailsModel>();
     BundleItem = new ProductBundleItemModel();
     IsAvailable = true;
 }
 public ProductDetailsModel()
 {
     //codehint: sm-edit
     //Manufacturers = new List<ProductManufacturer>();
     Manufacturers = new List<ManufacturerOverviewModel>();
     GiftCard = new GiftCardModel();
     ProductPrice = new ProductPriceModel();
     AddToCart = new AddToCartModel();
     ProductVariantAttributes = new List<ProductVariantAttributeModel>();
     Combinations = new List<ProductVariantAttributeCombination>();
     AssociatedProducts = new List<ProductDetailsModel>();
     BundledItems = new List<ProductDetailsModel>();
     BundleItem = new ProductBundleItemModel();
     IsAvailable = true;
 }
Exemplo n.º 34
0
 public ProductDetailsModel()
 {
     DefaultPictureModel = new PictureModel();
     PictureModels = new List<PictureModel>();
     GiftCard = new GiftCardModel();
     ProductPrice = new ProductPriceModel();
     AddToCart = new AddToCartModel();
     ProductAttributes = new List<ProductAttributeModel>();
     AssociatedProducts = new List<ProductDetailsModel>();
     VendorModel = new VendorBriefInfoModel();
     Breadcrumb = new ProductBreadcrumbModel();
     ProductTags = new List<ProductTagModel>();
     ProductSpecifications= new List<ProductSpecificationModel>();
     ProductManufacturers = new List<ManufacturerModel>();
     ProductReviewOverview = new ProductReviewOverviewModel();
     TierPrices = new List<TierPriceModel>();
 }
Exemplo n.º 35
0
 public ProductVariantModel()
 {
     GiftCard = new GiftCardModel();
     ProductVariantPrice = new ProductVariantPriceModel();
     PictureModel = new PictureModel();
     AddToCart = new AddToCartModel();
     ProductVariantAttributes = new List<ProductVariantAttributeModel>();
 }