コード例 #1
0
ファイル: CocktailController.cs プロジェクト: akg1852/miksd
        public ActionResult Data(Cocktails id)
        {
            var cocktail = cocktailService.Cocktail(id);

            return(JsonContent(new
            {
                cocktail.Id,
                cocktail.Name,
                recipe = cocktail.Recipe.Select(ingredient => {
                    var quantity = ingredient.Quantity.ToString("0.#") + (ingredient.IsDiscrete ? "" : " ml");
                    return new
                    {
                        id = ingredient.Ingredient,
                        ingredient.Name,
                        ingredient.IsOptional,
                        quantity,
                        quantityWords = ingredient.QuantityWords(),
                    };
                }),
                description = cocktail.Description(),
                image = ImageService.CocktailImage(cocktail, 200, "cocktail-image"),
                similar = cocktail.Similar.Select(CocktailSummary),
            }));
        }