예제 #1
0
        public async void When_Put_Expect_DbChange()
        {
            // Arrange
            long id = 1;

            var orderDetailRequest = new OrderDetailEditRequest
            {
                Quantity = 10
            };

            var orderDetailRequestJson = new StringContent(
                System.Text.Json.JsonSerializer.Serialize(orderDetailRequest),
                Encoding.UTF8,
                "application/json");

            var user = new UserInfo // Change with real email and password from db
            {
                Email    = "*****@*****.**",
                Password = "******"
            };

            // Act
            await SetJwtToken(user);

            var httpResponse = await client.PutAsync($"/api/orders/{id}", orderDetailRequestJson);

            httpResponse.EnsureSuccessStatusCode();

            // Assert (check db)
        }
예제 #2
0
        public async Task <ActionResult> Put(long id, [FromBody] OrderDetailEditRequest orderDetailEditRequest)
        {
            try
            {
                var orderDetail = mapper.Map <OrderDetailDataContext>(orderDetailEditRequest);
                await orderService.UpdateDetailAsync(orderDetail, id);

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }