/// <summary> /// Convert a meal model to a response meal DTO. /// </summary> /// <param name="meal">The meal model.</param> /// <returns>The response meal DTO.</returns> public Meal ToDto(Domain.Meal meal) { return(new Meal { Id = meal.Id, Name = meal.Name.Name, Instructions = meal.Instructions.Text, FeedsNumPeople = meal.ServingSize.FeedsNumPeople, MealIngredients = ToDto(meal.Ingredients), }); }
public static Index.Model ToModel(this Domain.Meal meal) { return(new Index.Model { Id = meal.Id, Date = meal.Date.ToShortDateString(), Time = meal.Time.ToString(ResourceConstant.TimeFormat, CultureInfo.InvariantCulture), Text = meal.Text, Calories = meal.Calories, AccountEmail = meal.Account?.Email, CalorieStatus = meal.CalorieStatus }); }
/// <summary> /// Update a meal model with a meal update DTO. /// </summary> /// <param name="meal">The meal to update.</param> /// <param name="mealUpdate">The meal update DTO.</param> public void ToModel(ref Domain.Meal meal, MealUpdate mealUpdate) { if (null != mealUpdate.Name) { meal.ChangeName(mealUpdate.Name); } if (null != mealUpdate.Instructions) { meal.ChangeInstructions(mealUpdate.Instructions); } if (null != mealUpdate.MealIngredients) { var ingredients = ToModel(mealUpdate.MealIngredients); meal.SetIngredients(ingredients); } if (default(int) != mealUpdate.FeedsNumPeople) { meal.ChangeServingSize(mealUpdate.FeedsNumPeople); } }