Example #1
0
 public RecipeModel(Domain.Entities.Recipe r)
 {
     Id               = r.Id;
     Name             = r.Name;
     Description      = r.Description;
     CookingTimeInMin = r.CookingTimeInMin;
     Image            = r.Image;
     AddToGroupPool   = r.AddToGroupPool;
     IngredientNames  = r.Ingredients.Select(i => i.Name).ToArray();
     Username         = r.User?.Email;
 }
Example #2
0
        public async Task <Domain.Entities.Recipe> ToUserRecipe(IUnitOfWork uow, ApplicationUser user)
        {
            var userRecipe = new Domain.Entities.Recipe
            {
                Name             = Name,
                Description      = Description,
                CookingTimeInMin = CookingTimeInMin,
                AddToGroupPool   = AddToGroupPool,
                Image            = Image,
                User             = user
            };

            if (IngredientNames != null)
            {
                userRecipe.Ingredients = await uow.Ingredients.GetListByNamesAsync(IngredientNames);
            }
            return(userRecipe);
        }