Exemplo n.º 1
0
        public async Task <IActionResult> PlaceOrder(int wholesalerId, [FromBody] DTOs.Order order)
        {
            var wholesaler = await _repository.ReadAsync(wholesalerId);

            if (wholesaler == null)
            {
                return(NotFound());
            }

            await BusinessRequirements.EnsureAllRequirementsAsync(wholesalerId, order, _repository);

            var beers = await _beerRepository.ReadAllFromListAsync(order.OrderDetails.Select(od => od.BeerId));

            return(Ok(new DTOs.Quote(order, beers)));
        }
Exemplo n.º 2
0
        public async Task ApplyPercentPromo(int quantity, decimal cost, string percentMsg)
        {
            var beerRepo = new BeerRepository(_context, null);
            var order    = new Order
            {
                OrderDetails = new List <Stock>
                {
                    new Stock {
                        BeerId = 1, Quantity = quantity
                    }
                }
            };
            var beers = await beerRepo.ReadAllFromListAsync(order.OrderDetails.Select(od => od.BeerId));

            var sut = new Quote(order, beers);

            Assert.That(sut.Cost, Is.EqualTo(cost));
            Assert.That(sut.Summary, Has.Exactly(1).Matches <string>(s => s.Contains(percentMsg)));
        }