/// <summary>
        /// Validate function for all LastUpdateAndContactService commands
        /// </summary>
        /// <param name="validationContext">System.ComponentModel.DataAnnotations.ValidationContext (Describes the context in which a validation check is performed.)</param>
        /// <param name="actionDBType">[ActionDBTypeEnum] (CSSPEnums.ActionDBTypeEnum.html) action type to validate</param>
        /// <returns>IEnumerable of ValidationResult (Where ValidationResult is a container for the results of a validation request.)</returns>
        private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType)
        {
            string retStr = "";
            Enums  enums  = new Enums(LanguageRequest);
            LastUpdateAndContact lastUpdateAndContact = validationContext.ObjectInstance as LastUpdateAndContact;

            lastUpdateAndContact.HasErrors = false;

            if (lastUpdateAndContact.LastUpdateAndContactDate_UTC.Year == 1)
            {
                lastUpdateAndContact.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "LastUpdateAndContactDate_UTC"), new[] { "LastUpdateAndContactDate_UTC" }));
            }
            else
            {
                if (lastUpdateAndContact.LastUpdateAndContactDate_UTC.Year < 1980)
                {
                    lastUpdateAndContact.HasErrors = true;
                    yield return(new ValidationResult(string.Format(CSSPServicesRes._YearShouldBeBiggerThan_, "LastUpdateAndContactDate_UTC", "1980"), new[] { "LastUpdateAndContactDate_UTC" }));
                }
            }

            if (lastUpdateAndContact.LastUpdateAndContactTVItemID < 1)
            {
                lastUpdateAndContact.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "LastUpdateAndContactTVItemID", "1"), new[] { "LastUpdateAndContactTVItemID" }));
            }

            retStr = "";      // added to stop compiling CSSPError
            if (retStr != "") // will never be true
            {
                lastUpdateAndContact.HasErrors = true;
                yield return(new ValidationResult("AAA", new[] { "AAA" }));
            }
        }
        private LastUpdateAndContact GetFilledRandomLastUpdateAndContact(string OmitPropName)
        {
            LastUpdateAndContact lastUpdateAndContact = new LastUpdateAndContact();

            if (OmitPropName != "LastUpdateAndContactDate_UTC")
            {
                lastUpdateAndContact.LastUpdateAndContactDate_UTC = new DateTime(2005, 3, 6);
            }
            if (OmitPropName != "LastUpdateAndContactTVItemID")
            {
                lastUpdateAndContact.LastUpdateAndContactTVItemID = GetRandomInt(1, 11);
            }

            return(lastUpdateAndContact);
        }
Esempio n. 3
0
 public LastUpdateAndContactTest()
 {
     lastUpdateAndContact = new LastUpdateAndContact();
 }