Exemple #1
0
        public async Task GivenCreateProductCommand_ReturnsNewProductId()
        {
            var command = new CreateNorthwindProductCommand
            {
                ProductName  = "Coffee",
                SupplierId   = 1,
                CategoryId   = 1,
                UnitPrice    = 19.00m,
                Discontinued = false
            };

            var content = Utilities.GetRequestContent(command);

            var response = await _client.PostAsync($"/api/products/create", content);

            response.EnsureSuccessStatusCode();

            var productId = await Utilities.GetResponseContent <int>(response);

            Assert.NotEqual(0, productId);
        }
        public async Task <ActionResult <int> > Create([FromBody] CreateNorthwindProductCommand command)
        {
            var productId = await Mediator.Send(command);

            return(Ok(productId));
        }