Exemple #1
0
        public override async Task <ShoppingCartModel> GetShoppingCart(GetShoppingCartRequest request, ServerCallContext context)
        {
            var shoppingCart = await _shoppingCartContext.ShoppingCart.FirstOrDefaultAsync(p => p.UserName == request.Username);

            if (shoppingCart == null)
            {
                throw new RpcException(new Status(StatusCode.NotFound, $"ShoppingCart with UserName={request.Username}"));
            }

            return(_mapper.Map <ShoppingCartModel>(shoppingCart));
        }
        public override async Task <ShoppingCartModel> GetShoppingCart(GetShoppingCartRequest request, ServerCallContext context)
        {
            var shoppingCart = await _shoppingCartContext.ShoppingCart.FirstOrDefaultAsync(s => s.UserName == request.Username);

            _logger.LogInformation($"ShoppingCart: {shoppingCart}");
            if (shoppingCart == null)
            {
                _logger.LogError($"ShoppingCart with UserName = {request.Username} is not found.");
                throw new RpcException(new Status(StatusCode.NotFound, $"ShoppingCart with UserName = {request.Username} is not found."));
            }

            return(_mapper.Map <ShoppingCartModel>(shoppingCart));
        }
Exemple #3
0
        public override async Task <ShoppingCartModel> GetShoppingCart(GetShoppingCartRequest request
                                                                       , ServerCallContext context)
        {
            var shoppingCart = await _shoppingCartContext
                               .ShoppingCarts
                               .FirstOrDefaultAsync(r => r.UserName == request.Username);

            if (shoppingCart == null)
            {
                throw new RpcException(new Status(StatusCode.NotFound, "There is no shoppingCart"));
            }

            var shopingCartModel = _mapper.Map <ShoppingCartModel>(shoppingCart);

            return(shopingCartModel);
        }
 /// <remarks/>
 public void GetShoppingCartAsync(GetShoppingCartRequest GetShoppingCartRequest, object userState) {
     if ((this.GetShoppingCartOperationCompleted == null)) {
         this.GetShoppingCartOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetShoppingCartOperationCompleted);
     }
     this.InvokeAsync("GetShoppingCart", new object[] {
                 GetShoppingCartRequest}, this.GetShoppingCartOperationCompleted, userState);
 }
 /// <remarks/>
 public void GetShoppingCartAsync(GetShoppingCartRequest GetShoppingCartRequest) {
     this.GetShoppingCartAsync(GetShoppingCartRequest, null);
 }
 public ShoppingCart GetShoppingCartRequest(GetShoppingCartRequest GetShoppingCartRequest)
 {
     object[] results = this.Invoke("GetShoppingCartRequest", new object[] {
         GetShoppingCartRequest});
     return ((ShoppingCart)(results[0]));
 }
 public System.IAsyncResult BeginGetShoppingCartRequest(GetShoppingCartRequest GetShoppingCartRequest, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("GetShoppingCartRequest", new object[] {
         GetShoppingCartRequest}, callback, asyncState);
 }