Ejemplo n.º 1
0
        public async Task <IActionResult> GetAllConsumedBeers()
        {
            Task <IEnumerable <ConsumedBeer> > taskConsumed = _consumedBeersService.GetConsumedBeers();
            Task <IEnumerable <Beer> >         taskBeers    = _beersService.GetAll();

            var consumed = await taskConsumed;
            var beers    = await taskBeers;

            if (consumed != null)
            {
                var joinedData = (from con in consumed
                                  join b in beers on con.BeerId equals b.Id
                                  select new ConsumedBeersDto
                {
                    Id = con.Id,
                    BeerId = con.BeerId,
                    Title = b.Title,
                    NonAlcohol = b.NonAlcohol,
                    Quantity = con.Quantity,
                    Volume = b.Volume
                });

                return(new OkObjectResult(joinedData));
            }

            return(NoContent());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetAllConsumedBeers()
        {
            Task <IEnumerable <ConsumedBeer> > taskConsumed = _consumedBeersService.GetConsumedBeers();

            var consumed = await taskConsumed;

            if (consumed != null)
            {
                return(new OkObjectResult(consumed));
            }

            return(NoContent());
        }