Exemplo n.º 1
0
        /// <summary>
        /// Validate model
        /// </summary>
        /// <param name="validationContext"></param>
        /// <returns></returns>
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var results = new List <ValidationResult>();

            switch ((this.Parent as RuminantActivityFeed).FeedStyle)
            {
            case RuminantFeedActivityTypes.ProportionOfWeight:
            case RuminantFeedActivityTypes.ProportionOfPotentialIntake:
            case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired:
                if (MonthlyValues.Max() > 1)
                {
                    string[] memberNames = new string[] { "Monthly values" };
                    results.Add(new ValidationResult("Invalid monthly value provided [v" + MonthlyValues.Max().ToString() + "] for [" + this.Name + "] Feed Group for [" + this.Parent.Name + "] given the style of feeding selected requires a proportion.", memberNames));
                }
                break;

            default:
                break;
            }
            if (MonthlyValues.Count() > 0)
            {
                if (MonthlyValues.Max() == 0)
                {
                    Summary.WriteWarning(this, $"No feed values were defined for any month in [{this.Name}]. No feeding will be performed for [a={this.Parent.Name}]");
                }
            }
            return(results);
        }
        /// <summary>
        /// Validate model
        /// </summary>
        /// <param name="validationContext"></param>
        /// <returns></returns>
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var results = new List <ValidationResult>();

            if (MonthlyValues.Count() > 0)
            {
                if (MonthlyValues.Max() == 0)
                {
                    Summary.WriteWarning(this, $"No feed values were defined for any month in [{this.Name}]. No feeding will be performed for [a={this.Parent.Name}]");
                }
            }
            return(results);
        }
        /// <summary>
        /// Validate model
        /// </summary>
        /// <param name="validationContext"></param>
        /// <returns></returns>
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var results = new List <ValidationResult>();

            switch ((this.Parent as RuminantActivityFeed).FeedStyle)
            {
            case RuminantFeedActivityTypes.ProportionOfWeight:
            case RuminantFeedActivityTypes.ProportionOfPotentialIntake:
            case RuminantFeedActivityTypes.ProportionOfRemainingIntakeRequired:
                if (MonthlyValues.Max() > 1)
                {
                    string[] memberNames = new string[] { "Monthly values" };
                    results.Add(new ValidationResult("Invalid monthly value provided [v" + MonthlyValues.Max().ToString() + "] for [" + this.Name + "] Feed Group for [" + this.Parent.Name + "] given the style of feeding selected requires a proportion.", memberNames));
                }
                break;

            default:
                break;
            }
            return(results);
        }
 /// <summary>
 /// Provides the description of the model settings for summary (GetFullSummary)
 /// </summary>
 /// <param name="formatForParentControl">Use full verbose description</param>
 /// <returns></returns>
 public override string ModelSummary(bool formatForParentControl)
 {
     using (StringWriter htmlWriter = new StringWriter())
     {
         if (!formatForParentControl)
         {
             if (MonthlyValues == null)
             {
                 return("\r\n<div class=\"activityentry\">No availability provided</div>");
             }
             double min = MonthlyValues.Min();
             double max = MonthlyValues.Max();
             htmlWriter.Write("\r\n<div class=\"activityentry\">Monthly availability ");
             if (min != max)
             {
                 htmlWriter.Write("ranges from ");
             }
             else
             {
                 htmlWriter.Write("is ");
             }
             if (min <= 0)
             {
                 htmlWriter.Write("<span class=\"errorlink\">" + min.ToString() + "</span>");
             }
             else
             {
                 htmlWriter.Write("<span class=\"setvalue\">" + min.ToString() + "</span>");
             }
             if (min != max)
             {
                 htmlWriter.Write("to <span class=\"setvalue\">" + max.ToString() + "</span>");
             }
             htmlWriter.Write(" days each month</div>");
         }
         return(htmlWriter.ToString());
     }
 }