コード例 #1
0
        public async Task <IActionResult> GetCartItemsAsync()
        {
            DC.ShoppingCartResponse result = await _laptopProvider.GetCartItemsAsync();

            if (result == null)
            {
                return(this.NotFound(result));
            }
            return(this.Ok(await Task.FromResult(result)));
        }
コード例 #2
0
        public async Task <IActionResult> AddLaptopToCartAsync([FromBody] DC.ShoppingCart shoppingCart)
        {
            DC.ShoppingCartResponse result = null;
            result = await _laptopProvider.AddLaptopToCartAsync(shoppingCart);

            if (result == null)
            {
                return(this.StatusCode(StatusCodes.Status400BadRequest, "Unable to add."));
            }
            return(Ok(result));
        }
コード例 #3
0
        public async Task <ShoppingCartResponse> AddLaptopToCartAsync(ShoppingCart shoppingCart)
        {
            DC.ShoppingCartResponse _shoppingCartResponse = new DC.ShoppingCartResponse();
            try
            {
                Model.ShoppingCartResponse shoppingCartResponse = await _laptopDAL.AddLaptopToCartAsync(_mapper.Map <Model.ShoppingCart>(shoppingCart));

                _shoppingCartResponse = _mapper.Map <DC.ShoppingCartResponse>(shoppingCartResponse);
            }
            catch (Exception)
            {
            }
            return(_shoppingCartResponse);
        }