コード例 #1
0
ファイル: Recipe.cs プロジェクト: jeremyrsellars/recipe
        public static Recipe FromRecipe(IRecipe recipe)
        {
            Recipe r = new Recipe
            {
                Name      = recipe.Name,
                Servings  = recipe.Servings,
                Yield     = recipe.Yield,
                YieldUnit = Unit.FromUnit(recipe.YieldUnit),
                Parts     = new List <RecipePart> (recipe.Parts.Select <IRecipePart, RecipePart>(RecipePart.FromRecipePart)),
                Source    = Source.FromSource(recipe.Source),
                CreatedOn = recipe.CreatedOn,
                CreatedBy = recipe.CreatedBy,
            };

            if (recipe.Comments != null)
            {
                r.Comments = new List <Comment> (recipe.Comments.Select <IComment, Comment>(Comment.FromComment));
            }
            if (recipe.Ratings != null)
            {
                r.Ratings = new List <Rating> (recipe.Ratings.Select <IRating, Rating>(Rating.FromRating));
            }
            if (recipe.Tags != null)
            {
                r.Tags = new List <Tag> (recipe.Tags.Select <ITag, Tag>(Tag.FromTag));
            }
            r.m_key = recipe.Key;
            r.Id    = recipe.Id ?? new ModelId <IRecipe> (new Guid());

            return(r);
        }