コード例 #1
0
        public async Task <IActionResult> OnPostAsync(
            [FromServices] UpdateCart updateCart)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var userId = User?.Claims?.FirstOrDefault(x => x.Type.Equals(ClaimTypes.NameIdentifier))?.Value;
            await updateCart.Do(userId, cart =>
            {
                cart.Name     = Form.Name;
                cart.Email    = Form.Email;
                cart.Phone    = Form.Phone;
                cart.Address1 = Form.Address1;
                cart.Address2 = Form.Address2;
                cart.City     = Form.City;
                cart.Country  = Form.Country;
                cart.PostCode = Form.PostCode;
                cart.State    = Form.State;
                cart.DeliveryInformationComplete = true;
            });

            return(RedirectToPage("/Checkout/Payment"));
        }
コード例 #2
0
        //this action method is used to insert products into a shopping cart, update quantities and make new shopping carts as necessary
        public void UpdateCart([FromBody] JObject data)
        {
            UpdateCart updatecart = data["UpdateData"].ToObject <UpdateCart>();
            var        SqlQuery   = "Update CartLineItem set ProdQty = '" + updatecart.qty + "' " +
                                    "where SessionID = '" + updatecart.SessionID + "' " +
                                    "and ProdID = '" + updatecart.ItmID + "'";

            _context.Database.ExecuteSqlCommand(SqlQuery);
        }
コード例 #3
0
        public void UpdateProductQuantity(int productNumber, int newQuantity)
        {
            if (productNumber >= QuantityBoxes.Count())
            {
                throw new ArgumentException("There are less added items in the cart. Please specify smaller product number.");
            }

            QuantityBoxes[productNumber].SetNumber(0);
            QuantityBoxes[productNumber].SetNumber(newQuantity);
            UpdateCart.Click();
        }
コード例 #4
0
        public void UpdateProductQuantity(int productNumber, int newQuantity)
        {
            if (productNumber > QuantityBoxes.Count())
            {
                throw new ArgumentException("There are less added items in the cart. Please specify smaller product number.");
            }

            BrowserService.WaitUntilReady();
            QuantityBoxes[productNumber - 1].SetNumber(newQuantity);
            UpdateCart.Click();
            BrowserService.WaitUntilReady();
        }
コード例 #5
0
        // 4. Another method that we can add here is the one for updating the quantity of a product.
        // This is an excellent place to put validations in your code. Here we make sure that the specified number of products that we want to update exists.
        public void UpdateProductQuantity(int productNumber, int newQuantity)
        {
            if (productNumber > QuantityBoxes.Count())
            {
                throw new ArgumentException("There are less added items in the cart. Please specify smaller product number.");
            }

            // 5. CreateAll method returns a special BELLATRIX collection called ElementsList<TComponentType> in this case ElementList<Number>
            // The collection has a couple of useful methods- Count, implements index which we use here.
            App.Browser.WaitForAjax();
            QuantityBoxes[productNumber - 1].SetNumber(newQuantity);
            UpdateCart.Click();
            App.Browser.WaitForAjax();
        }
コード例 #6
0
        public void UpdateAllProductsQuantity(int newQuantity)
        {
            if (QuantityBoxes.Any())
            {
                throw new ArgumentException("There are no items to be updated.");
            }

            foreach (var currentQuantityBox in QuantityBoxes)
            {
                currentQuantityBox.SetNumber(0);
                currentQuantityBox.SetNumber(newQuantity);
            }

            UpdateCart.Click();
        }
コード例 #7
0
        public void UpdateAllProductsQuantity(int newQuantity)
        {
            if (QuantityBoxes.Any())
            {
                throw new ArgumentException("There are no items to be updated.");
            }

            // 6. Also, you can use ComponentsList<T> directly in foreach statements since it implements IEnumerator interface.
            foreach (var currentQuantityBox in QuantityBoxes)
            {
                currentQuantityBox.SetNumber(0);
                currentQuantityBox.SetNumber(newQuantity);
            }

            UpdateCart.Click();
        }
コード例 #8
0
        public async Task <IActionResult> UpdateCart(
            [FromBody] UpdateCart.Form request,
            [FromServices] UpdateCart updateCart)
        {
            var userId = User?.Claims?.FirstOrDefault(x => x.Type.Equals(ClaimTypes.NameIdentifier))?.Value;

            if (string.IsNullOrEmpty(userId))
            {
                return(BadRequest("Cookie Policy not accepted"));
            }

            request.UserId = userId;
            var result = await updateCart.Do(request);

            if (result.Success)
            {
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }