Exemplo n.º 1
0
        /// <summary>
        /// Validate function for all LastUpdateAndTVTextService 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);
            LastUpdateAndTVText lastUpdateAndTVText = validationContext.ObjectInstance as LastUpdateAndTVText;

            lastUpdateAndTVText.HasErrors = false;

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

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

            if (string.IsNullOrWhiteSpace(lastUpdateAndTVText.TVText))
            {
                lastUpdateAndTVText.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "TVText"), new[] { "TVText" }));
            }

            if (!string.IsNullOrWhiteSpace(lastUpdateAndTVText.TVText) && (lastUpdateAndTVText.TVText.Length < 1 || lastUpdateAndTVText.TVText.Length > 200))
            {
                lastUpdateAndTVText.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._LengthShouldBeBetween_And_, "TVText", "1", "200"), new[] { "TVText" }));
            }

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

            if (OmitPropName != "LastUpdateAndTVTextDate_UTC")
            {
                lastUpdateAndTVText.LastUpdateAndTVTextDate_UTC = new DateTime(2005, 3, 6);
            }
            if (OmitPropName != "LastUpdateDate_Local")
            {
                lastUpdateAndTVText.LastUpdateDate_Local = new DateTime(2005, 3, 6);
            }
            if (OmitPropName != "TVText")
            {
                lastUpdateAndTVText.TVText = GetRandomString("", 6);
            }

            return(lastUpdateAndTVText);
        }
Exemplo n.º 3
0
        public LastUpdateAndTVText GetLastUpdateAndDateDB(string Table, int ID, int Offset_min)
        {
            string Tables = "";

            if (Table == "Address")
            {
                Tables = Table + "es";
            }
            else
            {
                Tables = Table + "s";
            }
            string sql = "";

            if (Table == "TVItemLanguage")
            {
                sql = "SELECT TVItemLanguages_1.LastUpdateDate_UTC, TVItemLanguages.TVText"
                      + " FROM TVItems INNER JOIN"
                      + " TVItemLanguages ON TVItems.TVItemID = TVItemLanguages.TVItemID INNER JOIN"
                      + " TVItemLanguages AS TVItemLanguages_1 ON TVItems.TVItemID = TVItemLanguages_1.LastUpdateContactTVItemID"
                      + " WHERE     (TVItemLanguages.Language = " + ((int)LanguageRequest).ToString() + ")"
                      + " AND (TVItemLanguages_1.Language = " + ((int)LanguageRequest).ToString() + ")"
                      + " AND (TVItemLanguages_1.TVItemID = " + ID.ToString() + ")";
            }
            else
            {
                sql = "SELECT " + Tables + ".LastUpdateDate_UTC, TVItemLanguages.TVText"
                      + " FROM " + Tables + " INNER JOIN"
                      + " TVItems ON " + Tables + ".LastUpdateContactTVItemID = TVItems.TVItemID INNER JOIN"
                      + " TVItemLanguages ON TVItems.TVItemID = TVItemLanguages.TVItemID"
                      + " WHERE (" + Tables + "." + Table + "ID = " + ID.ToString()
                      + ") AND (TVItemLanguages.Language = " + ((int)LanguageRequest).ToString() + ")";
            }

            LastUpdateAndTVText lastUpdateAndTVText = db.Database.SqlQuery <LastUpdateAndTVText>(sql).FirstOrDefault <LastUpdateAndTVText>();

            lastUpdateAndTVText.LastUpdateDate_Local = lastUpdateAndTVText.LastUpdateDate_UTC.AddMinutes(Offset_min * (-1));

            return(lastUpdateAndTVText);
        }
Exemplo n.º 4
0
 public LastUpdateAndTVTextTest()
 {
     lastUpdateAndTVText = new LastUpdateAndTVText();
 }