Beispiel #1
0
        public IHttpActionResult Get()
        {
            IHttpActionResult    result;
            IEnumerable <Coffee> coffeeList = repository.Get();

            result = Json <IEnumerable <Coffee> >(coffeeList);

            return(result);
        }
Beispiel #2
0
        public IActionResult Get(int id)
        {
            var coffee = _coffeeRepository.Get(id);

            if (coffee == null)
            {
                return(NotFound());
            }
            return(Ok(coffee));
        }
        public IActionResult Get(int id)
        {
            var variety = _coffeeRepository.Get(id);

            if (variety == null)
            {
                return(NotFound());
            }
            return(Ok(variety));
        }
Beispiel #4
0
        public async Task Consume(ConsumeContext <ICoffeeCompletedEvent> context)
        {
            await Console.Out.WriteLineAsync($"Marking coffee {context.Message.Id} complete for {context.Message.OrderId}");

            var coffees = await _repository.Get();

            var coffee = coffees.FirstOrDefault(c => c.Id == context.Message.Id);

            coffee.IsComplete = true;
            await _repository.Update(coffee);
        }
Beispiel #5
0
        public IActionResult Get(int id)
        {
            var coffee = _coffeeRepository.Get(id);

            coffee.beanVariety = _beanVarietyRepository.Get(coffee.BeanVarietyId);
            if (coffee == null)
            {
                return(NotFound());
            }
            return(Ok(coffee));
        }
Beispiel #6
0
        private async Task <string> GetInvalidCoffeesMessage(
            OrderContainedInvalidCoffeesException ex, CancellationToken cancellationToken)
        {
            var joinedInvalidCoffeeNames = (await _coffeeRepository.Get(ex.Coffees, cancellationToken))
                                           .Select(c => c.Name.ToString())
                                           .Aggregate((a, b) => $"{a}, {b}");

            var message = $"Sorry, the following coffees aren't being offered in this roasting event: {joinedInvalidCoffeeNames}. " +
                          "Please include only the listed coffees when placing an order.";

            return(message);
        }
 public Coffee GetCoffee(int id)
 {
     return(_coffeeRepository.Get(id));
 }