示例#1
0
        public async Task <ActionResult <OrderData> > PurchaseSliceAsync([FromBody] PurchaseSliceRequest data)
        {
            // Step 1: Get room by data.RoomId
            var room = await roomApiClient.GetAsync(data.RoomId);

            if (room == null)
            {
                return(new BadRequestResult());
            }

            // Step 2: Call purchase order on orderClient
            var orderDTO = await orderClient.PurchaseSliceAsync(data.RoomId, room.Name, room.SlicesPerPizza, data.Quantity);

            // Step 3: Get users list and set user's e-mail
            IEnumerable <UserDTO> users = await userClient.GetAllAsync();

            var result = OrderData.FromOrderDTO(orderDTO, users);

            return(new OkObjectResult(result));
        }