예제 #1
0
 public async Task <HttpMessage <BasketData> > DeliveryTariff(BasketQuery pq)
 => await TryCatchResponseAsync(async() =>
 {
     return(await Task.Run(() =>
     {
         SetBaskeDeliveryTariffID(pq.uid, pq.deliveryTariffID, pq.deliveryRouteID);
         return View(pq);
     }));
 });
예제 #2
0
 public async Task <HttpMessage <BasketData> > PromoCode(BasketQuery pq)
 => await TryCatchResponseAsync(async() =>
 {
     return(await Task.Run(() =>
     {
         SetBaskePromoCode(pq.uid, pq.promoCode);
         return View(pq);
     }));
 });
예제 #3
0
 public async Task <HttpMessage <BasketData> > Delete(BasketQuery pq)
 => await TryCatchResponseAsync(async() =>
 {
     return(await Task.Run(() =>
     {
         DeletePartBasket(pq);
         int result = GetCount(pq.uid);
         return View(pq);
     }));
 });
예제 #4
0
 public async Task <HttpMessage <int> > Add(BasketQuery pq)
 => await TryCatchResponseAsync(async() =>
 {
     return(await Task.Run(() =>
     {
         UpdatePartBasket(pq, true);
         int result = GetCount(pq.uid);
         return CreateResponseOk(result);
     }));
 });
예제 #5
0
 public BasketController(CreateBasketCommand createBasketCommand,
                         BasketQuery basketQuery,
                         DeleteBasketCommand deleteBasketCommand,
                         AddItemToBasketCommand addItemToBasketCommand,
                         UpdateItemQuantityCommand updateItemQuantityCommand)
 {
     _createBasketCommand       = createBasketCommand;
     _basketQuery               = basketQuery;
     _deleteBasketCommand       = deleteBasketCommand;
     _addItemToBasketCommand    = addItemToBasketCommand;
     _updateItemQuantityCommand = updateItemQuantityCommand;
 }
예제 #6
0
        public async Task <HttpMessage <BasketData> > View(BasketQuery pq)
        => await TryCatchResponseAsync(async() =>
        {
            return(await Task.Run(() =>
            {
                Principal principal = Core.Http.HttpContext.Current.User as Principal;
                int userId = principal == null || principal.User == null ? 0 : principal.User.Id;

                BasketData result = GetBasketData(pq.uid);
                pq.promoCode = result.Header.PromoCode = GetBaskePromoCode(pq.uid);
                List <GoodsSearch> goodsSearch = GetBasketGoods(result.Positions);
                FillBasketData(result, goodsSearch, userId, pq);

                if (result.Positions.Count == 0)
                {
                    DeleteHeaderBasket(pq);
                }
                else if (result.Header.DeliveryTariffID == 0 && result.Deliveries.Count > 0)
                {
                    result.Header.DeliveryTariffID = result.Deliveries[0].Id;
                    SetBaskeDeliveryTariffID(pq.uid, result.Header.DeliveryTariffID, result.Header.DeliveryRouteID);
                }


                if (!string.IsNullOrEmpty(result.Header.PromoCode))
                {
                    if (!(GetCouponId(result.Header.PromoCode) > 0))
                    {
                        result.Header.PromoCode = string.Empty;
                        SetBaskePromoCode(pq.uid, string.Empty);
                    }
                }

                return CreateResponseOk(result);
            }));
        });
예제 #7
0
        public async Task <IActionResult> Get([FromRoute] BasketQuery query)
        {
            var basket = await _dispatcher.QueryAsync <BasketDto>(query);

            return(Ok(basket));
        }
예제 #8
0
        private void GetBasket()
        {
            BasketQuery query = new BasketQuery(_basketRepository);

            _returnedBasket = query.Get(new BasketId(_basketId, _consumerId));
        }