예제 #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);
        }