Example #1
0
        public static IngredientDetail FromIngredientDetail(IIngredientDetail ingredientDetail)
        {
            if (ingredientDetail == null)
            {
                return(null);
            }
            Sellars.Data.Model.ModelId <IRecipe> recipeId = ingredientDetail.Ingredient == null ? null : ingredientDetail.Ingredient.Id;
            IngredientDetail i = new IngredientDetail
            {
                Ingredient         = ingredientDetail.Ingredient == null ? "" : ingredientDetail.Ingredient.Name,
                IngredientRecipeId = recipeId == null ? Guid.Empty : recipeId.Id,
                Quantity           = ingredientDetail.Quantity.ToString(),
                Amount             = ingredientDetail.Amount.ToString(),
                AmountMax          = ingredientDetail.AmountMax.ToString(),
                Unit = ingredientDetail.Unit == null ? "" : ingredientDetail.Unit.Name,
            };

            if (ingredientDetail.Preparation == null)
            {
                i.Preparation = "";
            }
            else
            {
                i.Preparation = string.Join("|", ingredientDetail.Preparation.ToArray());
            }
            return(i);
        }
 public static IngredientDetail FromIngredientDetail(IIngredientDetail ingredientDetail)
 {
     if (ingredientDetail == null)
     return null;
      Sellars.Data.Model.ModelId<IRecipe> recipeId = ingredientDetail.Ingredient == null ? null : ingredientDetail.Ingredient.Id;
      IngredientDetail i = new IngredientDetail
      {
     Ingredient = ingredientDetail.Ingredient == null ? "" : ingredientDetail.Ingredient.Name,
     IngredientRecipeId = recipeId == null ? Guid.Empty : recipeId.Id,
     Quantity = ingredientDetail.Quantity.ToString (),
     Amount = ingredientDetail.Amount.ToString (),
     AmountMax = ingredientDetail.AmountMax.ToString (),
     Unit = ingredientDetail.Unit == null ? "" : ingredientDetail.Unit.Name,
      };
      if (ingredientDetail.Preparation == null)
     i.Preparation = "";
      else
     i.Preparation = string.Join ("|", ingredientDetail.Preparation.ToArray ());
      return i;
 }