private Recipe ParseRecipe(XElement xElement) { var recipe = new Recipe { Id = int.Parse(xElement.Attribute("id").Value), Title = xElement.Attribute("title").Value, Image = xElement.Attribute("image").Value, PreparationTime = TimeSpan.FromMinutes(int.Parse(xElement.Attribute("preparationtime").Value)), CookTime = TimeSpan.FromMinutes(int.Parse(xElement.Attribute("cooktime").Value)), Language = xElement.Attribute("lang").Value, Spiciness = (Spicy)int.Parse(xElement.Attribute("spiciness").Value), Week = int.Parse(xElement.Attribute("week").Value), Year = int.Parse(xElement.Attribute("year").Value), ForNumberOfPersons = int.Parse(xElement.Attribute("fornumberofpersons").Value), }; recipe.Ingredients = new List<string>(); foreach (var ingredient in xElement.Descendants("item")) { recipe.Ingredients.Add(ingredient.Value); } foreach (var directionParagraph in xElement.Descendants("paragraph")) { recipe.Directions += directionParagraph.Value + "\n\n"; } return recipe; }
public RecipeViewModel(Recipe recipe) { this.recipe = recipe; }