Esempio n. 1
0
        public async Task <IActionResult> Details(string Id)
        {
            var barDTO = await this.barService.GetBarAsync(Id);

            var barViewModel   = this.barDetailsMapper.MapFromDTO(barDTO);
            var barCommentDTOs = await this.barService.GetAllCommentsForBar(Id);

            var barCocktailDTOs = await cocktailService.GetAllContainedCocktailsDTO(Id);

            barViewModel.Comments  = barCommentDTOs.Select(c => this.commentMapper.MapFromDTO(c));
            barViewModel.Cocktails = barCocktailDTOs.Select(bc => cocktailsForBarMapper.MapFromDTO(bc)).ToList();

            return(View(barViewModel));
        }
Esempio n. 2
0
        public async Task <IActionResult> Index()
        {
            var barsDto = await this.barService.GetBarsAsync();

            var viewModel = this.collectionMapper.MapFromDTO(barsDto);

            var barsViewModel = new List <DisplayBarsViewModel>();

            foreach (var bar in barsDto)
            {
                barsViewModel.Add(barViewModelMapper.MapFromDTO(bar));
            }
            viewModel.Bars = viewModel.Bars.OrderByDescending(b => b.Rating).ToList();

            return(View(viewModel));
        }
        public async Task <IActionResult> Index()
        {
            var cocktails = await this.cocktailService.GetAllCocktailsDTO();

            var cocktailsViewModel = collectionMapper.MapFromDTO(cocktails);

            ////new List<DisplayCocktailViewModel>();

            //foreach (var cocktailsVM in cocktails)
            //{
            //    cocktailsViewModel.Add(displayCocktailMapper.MapFromDTO(cocktailsVM));
            //}
            cocktailsViewModel.Cocktails = cocktailsViewModel.Cocktails.OrderByDescending(c => c.Rating).ToList();

            return(View(cocktailsViewModel));
        }