Ejemplo n.º 1
0
        public async Task <SaveBasketResponse> Save(Guid sessionId, BasketItem item)
        {
            var policy = _pollyPolicyProvider.BasketStorePolicy();

            var result = await policy.ExecuteAndCaptureAsync(async() =>
            {
                await _basketStore.SaveOrUpdate(new BasketItemModel
                {
                    ProductId = Guid.Parse(item.ProductId),
                    Quantity  = item.Quantity,
                    SessionId = sessionId
                });
            });

            if (result.Outcome == OutcomeType.Failure)
            {
                //LOG
                var response = new SaveBasketResponse();
                response.AddError(result.FinalException.Message);
                return(response);
            }
            return(new SaveBasketResponse());
        }