public async Task <ActionResult> Details(int id) { var cocktail = await this.cocktailService.GetCocktail(id); var reviews = await this.cocktailService.GetCocktailReviews(id); var cocktailDetails = new CocktailDetailsViewModel(); cocktailDetails.Cocktail = cocktail; cocktailDetails.CocktailReviews = reviews; return(View(cocktailDetails)); }
public static CocktailDetailsViewModel MapToViewModel(this CocktailDetailsDTO cocktail) { var vm = new CocktailDetailsViewModel { Id = cocktail.Id, Name = cocktail.Name, ImageURL = cocktail.ImagePath, Ingredients = cocktail.Ingredients.Select(i => i.MapToViewModel()), Bars = cocktail.Bars?.Select(b => b.MapToViewModel()) }; vm.ListedIngredients = string.Join(", ", vm.Ingredients.Select(i => i.Name)); return(vm); }