Beispiel #1
0
        /// <summary>
        /// Model the price of each present cohort for a given breed
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public IEnumerable <AnimalPriceGroup> GetAnimalPrices(AnimalPricing parent)
        {
            List <AnimalPriceGroup> prices = new List <AnimalPriceGroup>();

            double sire_price = 0;
            int    row        = -1;

            foreach (string cohort in RumNumbers.RowNames)
            {
                row++;
                if (RumNumbers.GetData <double>(row, RumActiveID) != 0)
                {
                    if (!cohort.ToLower().Contains("sire"))
                    {
                        sire_price = RumPrices.GetData <double>(row, RumActiveID);
                    }

                    var group = new AnimalPriceGroup(parent)
                    {
                        Name  = cohort,
                        Value = RumPrices.GetData <double>(row, RumActiveID)
                    };

                    // Filter cohort based on gender
                    group.Add(new RuminantFilter(group)
                    {
                        Name      = "GenderFilter",
                        Parameter = 2,
                        Value     = cohort.ToLower().Contains("f") ? "Female" : "Male"
                    });

                    // Filter cohort based on age
                    group.Add(new RuminantFilter(group)
                    {
                        Name      = "AgeFilter",
                        Parameter = 3,
                        Operator  = 5,
                        Value     = RumAges.GetData <string>(row, RumActiveID)
                    });

                    prices.Add(group);
                }
            }
            parent.SirePrice = sire_price;

            return(prices);
        }
Beispiel #2
0
        public IEnumerable <AnimalPriceGroup> GetAnimalPrices(AnimalPricing pricing)
        {
            List <AnimalPriceGroup> prices = new List <AnimalPriceGroup>();

            int index = Breeds.IndexOf((pricing.Parent as RuminantType).Breed);

            // List of all the present cohorts
            var cohorts = pricing.Parent.Children.First().Children;

            foreach (var cohort in cohorts)
            {
                AnimalPriceGroup price = new AnimalPriceGroup(pricing)
                {
                    Name         = cohort.Name,
                    PricingStyle = 1,
                    Value        = GetValue <double>(Prices.Element(cohort.Name), index)
                };

                price.Add(new RuminantFilter(price)
                {
                    Name      = "GenderFilter",
                    Parameter = 2,
                    Value     = (((RuminantTypeCohort)cohort).Gender == 0) ? "Male" : "Female"
                });

                price.Add(new RuminantFilter(price)
                {
                    Name      = "AgeFilter",
                    Parameter = 3,
                    Operator  = 5,
                    Value     = ((RuminantTypeCohort)cohort).Age.ToString()
                });

                prices.Add(price);
            }

            return(prices.AsEnumerable());
        }