Example #1
0
        public IActionResult AddItems([FromBody] ShoppingCartItemModel itemToAdd)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            AddItemToShoppingCartCommand command = new AddItemToShoppingCartCommand
            {
                ProductId = itemToAdd.Product.Id,
                Quantity  = itemToAdd.Quantity,
                UserId    = MockConstants.CurrentUserId
            };

            serviceProcessor.Process(command);
            return(CreatedAtAction(nameof(BasketController.Get), MapShoppingCartToModel(command.Result)));
        }
Example #2
0
        public IActionResult GetAll()
        {
            GetAllProductsCommand command = new GetAllProductsCommand();

            serviceProcessor.Process(command);
            IEnumerable <ProductViewModel> models = ModelMapper.MapCollection <Product, ProductViewModel>(command.Result);

            return(Ok(models));
        }