Ejemplo n.º 1
0
 public async Task <bool> Remove([FromBody] ShoppingCartUpdateRequest request)
 {
     using (var scope = _provider.CreateScope())
     {
         return(await _provider.GetService <IShoppingCartService>().Delete(request));
     }
 }
Ejemplo n.º 2
0
        public async Task <IShoppingCartUpdateFinishedProcessState> StartProcessAsync(ShoppingCartContent shoppingCart, CancellationToken cancellationToken = default)
        {
            ShoppingCartUpdateRequest request = this.CreateRequest(shoppingCart);

            ShoppingCartUpdateResponse response = await this.SendRequestAsync(request,
                                                                              () =>
            {
                return(this.Dialog.SendRequestAsync(request, cancellationToken));
            }).ConfigureAwait(continueOnCapturedContext: false);

            return(new ShoppingCartUpdateFinishedProcessState(request, response));
        }
Ejemplo n.º 3
0
        public IShoppingCartUpdateFinishedProcessState StartProcess(ShoppingCartContent shoppingCart)
        {
            ShoppingCartUpdateRequest request = this.CreateRequest(shoppingCart);

            ShoppingCartUpdateResponse response = this.SendRequest(request,
                                                                   () =>
            {
                return(this.Dialog.SendRequest(request));
            });

            return(new ShoppingCartUpdateFinishedProcessState(request, response));
        }
Ejemplo n.º 4
0
        private void Dialog_RequestReceived(Object sender, MessageReceivedEventArgs <ShoppingCartUpdateRequest> e)
        {
            ShoppingCartUpdateRequest request = e.Message;

            this.OnMessageReceived(request,
                                   () =>
            {
                IShoppingCartUpdateRequestedProcessState processState = new ShoppingCartUpdateRequestedProcessState(this, request);

                this.ProcessStarted?.Invoke(this, new ProcessStartedEventArgs <IShoppingCartUpdateRequestedProcessState>(processState));
            });
        }
Ejemplo n.º 5
0
        public void Update(ShoppingCartUpdateRequest model, int userId)
        {
            string procName = "dbo.ShoppingCart_UpdateV3";

            _data.ExecuteNonQuery(procName,
                                  inputParamMapper : delegate(SqlParameterCollection col)
            {
                AddCommonParams(model, col);
                col.AddWithValue("@cartId", model.Id);
                col.AddWithValue("@modifiedBy", userId);
            },
                                  returnParameters: null);
        }
        /// <summary>
        /// Processes an incomming shopping cart update request.
        /// </summary>
        /// <param name="request">The request to be processed.</param>
        private void ProcessShoppingCartUpdateRequest(ShoppingCartUpdateRequest request)
        {
            // Set the underlying XmlObjectStream to send the response on when request.Accept() or request.Reject() is called.
            lock (_syncLock)
            {
                if (_messageObjectStream == null)
                {
                    return;
                }

                request.MessageObjectStream = _messageObjectStream;
            }

            // Raise the corresponding event.
            base.Raise("ShoppingCartUpdateRequested", _shoppingCartUpdateRequested, this, request);
        }
Ejemplo n.º 7
0
        //Basket action- can be applied with a trashbin icon in basket next to item
        public async Task <bool> Delete(ShoppingCartUpdateRequest request)
        {
            var item = await GetProduct(request.ProductItem.Barcode);

            var existingCart = await Get(new ShoppingCartServiceRequest { CustomerId = request.Customer.CustomerId });

            int basketExistingItemCount = existingCart.ShoppingCartItems.Where(i => i.ProductItem.Barcode == request.ProductItem.Barcode).Sum(i => i.ItemBasketQuantity);

            ShoppingCartItem cartItem = new ShoppingCartItem
            {
                GiftPrice          = request.GiftPrice,
                ItemBasketQuantity = request.ItemBasketQuantity,
                ProductItem        = request.ProductItem
            };
            var result = await _provider.GetService <IShoppingCartRepository>().DeleteCartItem(cartItem, request.Customer.CustomerId, existingCart.Id);

            return(result);
        }
Ejemplo n.º 8
0
        //Basket action- Can be called for all operations-changes whhile the shopping cart screen is open. increase item count,decrease item count etc.
        public async Task <bool> Update(ShoppingCartUpdateRequest request)
        {
            CustomerShoppingCart shoppingCart = new CustomerShoppingCart();
            var item = await GetProduct(request.ProductItem.Barcode);

            var existingCart = await Get(new ShoppingCartServiceRequest { CustomerId = request.Customer.CustomerId });

            ShoppingCartItem cartItem = new ShoppingCartItem
            {
                GiftPrice          = request.GiftPrice,
                ItemBasketQuantity = request.ItemBasketQuantity,
                ProductItem        = item
            };

            //müşterinin sepeti yoksa sepet oluştur
            if (existingCart.ShoppingCartItems == null)
            {
                return(await CreateShoppingCart(cartItem, request.Customer.CustomerId));
            }

            int basketExistingItemCount = existingCart.ShoppingCartItems.Where(i => i.ProductItem.Barcode == request.ProductItem.Barcode).Sum(i => i.ItemBasketQuantity);

            if (item == null || item.StockQuantity < request.ItemBasketQuantity)
            {
                return(false);
            }

            //ürün sepette yoksa ve req edlen toplamı toplam ürün stoğunu geçmiyorsa
            if (basketExistingItemCount == 0)
            {
                shoppingCart = await _provider
                               .GetService <IShoppingCartRepository>()
                               .PushCartItem(cartItem, request.Customer.CustomerId, Guid.NewGuid());
            }

            //ürün sepette varsa stoğu güncellensin
            else
            {
                existingCart.ShoppingCartItems.Where(i => i.ProductItem.Barcode == request.ProductItem.Barcode).ToList().ForEach(i => i.ItemBasketQuantity = request.ItemBasketQuantity);
                shoppingCart = await UpdateBasketItemInfo(item, existingCart);
            }
            return(shoppingCart.ShoppingCartItems != null ? true : false);
        }
Ejemplo n.º 9
0
 protected void OnRequestReceived(ShoppingCartUpdateRequest request)
 {
     this.RequestReceived?.Invoke(this, new MessageReceivedEventArgs <ShoppingCartUpdateRequest>(request, this.DialogProvider));
 }
 public ShoppingCartUpdateRequestedProcessState(ShoppingCartUpdateWorkflow workflow, ShoppingCartUpdateRequest request)
 {
     this.Workflow = workflow;
     this.Request  = request;
 }
Ejemplo n.º 11
0
 public Task <ShoppingCartUpdateResponse> SendRequestAsync(ShoppingCartUpdateRequest request, CancellationToken cancellationToken = default)
 {
     return(base.SendRequestAsync <ShoppingCartUpdateRequest, ShoppingCartUpdateResponse>(request, cancellationToken));
 }
Ejemplo n.º 12
0
 public ShoppingCartUpdateResponse SendRequest(ShoppingCartUpdateRequest request)
 {
     return(base.SendRequest <ShoppingCartUpdateRequest, ShoppingCartUpdateResponse>(request));
 }
Ejemplo n.º 13
0
 public ShoppingCartUpdateFinishedProcessState(ShoppingCartUpdateRequest request, ShoppingCartUpdateResponse response)
 {
     this.Request  = request;
     this.Response = response;
 }