public IActionResult CreateItem(Guid basketId, CreateItemBasketRequest request)
        {
            var message = _mapper.Map <CreateItemBasketMessage>(request);

            message.BasketId = basketId;

            _mediator.Send <CreateItemBasketMessage, IItem>(message);

            return(CreatedAtAction(nameof(Get), new { basketId = message.BasketId }, null));
        }
Esempio n. 2
0
        public async Task Post_Should_Create_New_Item(string url)
        {
            // Arrange
            var client = _factory.CreateClient();
            // Act
            var request = new CreateItemBasketRequest {
                ItemDescription = "test", ItemCode = "Test", Quantity = 1
            };
            var response = await client.PostAsync(url, new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json"));

            // Assert
            response.EnsureSuccessStatusCode(); // Status Code 200-299
            response.StatusCode.ShouldBe(HttpStatusCode.Created);
        }
        public async Task <string> AddItem(Guid basketId, CreateItemBasketRequest request)
        {
            var uri = BuildUri(basketId, "item/");

            return(await _client.PostAsync(uri, request));
        }