Ejemplo n.º 1
0
            public async Task <Basket.API.Domain.Basket> Handle(Query request, CancellationToken cancellationToken)
            {
                var userId = httpContext.Request.Headers["claims_userId"];
                var basket = await cacheContext.GetAsync <Domain.Basket>(userId);

                if (basket == null)
                {
                    basket = new Domain.Basket();
                }

                return(basket);
            }
Ejemplo n.º 2
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var userId = httpContext.Request.Headers["claims_userId"];
                var basket = await cacheContext.GetAsync <Domain.Basket>(userId);

                if (basket == null)
                {
                    basket = new Domain.Basket();
                }

                basket.Items.Add(request.Item);

                var result = await cacheContext.SetAsync(userId, basket);

                if (result)
                {
                    return(Unit.Value);
                }
                throw new Exception("Problem saving data");
            }