Esempio n. 1
0
        /// <summary>
        /// Sets the yeasts on the recipe
        /// </summary>
        void SetYeasts(Recipe recipe, XElement entryPoint)
        {
            var allYeasts = this.BrewDataService.GetUsableIngredients <Yeast>(this.UserId);

            recipe.Yeasts = new List <RecipeYeast>();
            if (entryPoint.Element("YEASTS") != null)
            {
                foreach (var yeastElement in entryPoint.Element("YEASTS").Elements("YEAST"))
                {
                    var yeast = new RecipeYeast();

                    var matchingYeast = allYeasts.FirstOrDefault(x => x.Name.Trim().ToLower() == yeastElement.Element("NAME").Value.Trim().ToLower());
                    if (matchingYeast != null)
                    {
                        yeast.IngredientId = matchingYeast.IngredientId;
                        yeast.Yeast        = matchingYeast;
                    }
                    else
                    {
                        yeast.IngredientId = 0;
                        yeast.Yeast        = new Yeast();
                        yeast.Yeast.Name   = yeastElement.Element("NAME").Value;
                    }

                    yeast.Attenuation = .75d;
                    var attenuation = yeastElement.Element("ATTENUATION") != null?Convert.ToDouble(yeastElement.Element("ATTENUATION").Value) : (double?)null;

                    if (attenuation != null)
                    {
                        yeast.Attenuation = Math.Round(Convert.ToDouble(yeastElement.Element("ATTENUATION").Value)) / 100;
                    }

                    recipe.Yeasts.Add(yeast);
                }
            }
        }
		/// <summary>
		/// Sets the yeasts on the recipe
		/// </summary>
		void SetYeasts(Recipe recipe, XElement entryPoint)
		{
			var allYeasts = this.BrewDataService.GetUsableIngredients<Yeast>(this.UserId);
			recipe.Yeasts = new List<RecipeYeast>();
			if (entryPoint.Element("YEASTS") != null)
			{
				foreach (var yeastElement in entryPoint.Element("YEASTS").Elements("YEAST"))
				{
					var yeast = new RecipeYeast();

					var matchingYeast = allYeasts.FirstOrDefault(x => x.Name.Trim().ToLower() == yeastElement.Element("NAME").Value.Trim().ToLower());
					if (matchingYeast != null)
					{
						yeast.IngredientId = matchingYeast.IngredientId;
						yeast.Yeast = matchingYeast;
					}
					else
					{
						yeast.IngredientId = 0;
						yeast.Yeast = new Yeast();
						yeast.Yeast.Name = yeastElement.Element("NAME").Value;
					}

					yeast.Attenuation = .75d;
					var attenuation = yeastElement.Element("ATTENUATION") != null ? Convert.ToDouble(yeastElement.Element("ATTENUATION").Value) : (double?)null;
					if (attenuation != null)
					{
						yeast.Attenuation = Math.Round(Convert.ToDouble(yeastElement.Element("ATTENUATION").Value)) / 100;
					}

					recipe.Yeasts.Add(yeast);
				}
			}
		}