//Listing 7-2. Compare validation

        partial void ClosedDateTime_Validate(EntityValidationResultsBuilder results)
        {
            if (this.CreateDateTime > this.ClosedDateTime)
            {
                results.AddPropertyError("Closed Date cannot be earlier than Create Date");
            }
        }
partial         void RecordableIncidents_Validate(EntityValidationResultsBuilder results)
        {
            if(this.RecordableIncidents < 0)
            {
                results.AddPropertyError("Recordable incidents must be a positive number.");
            }
        }
partial         void LossTime_Validate(EntityValidationResultsBuilder results)
        {
            if (this.LossTime < 0)
            {
                results.AddPropertyError("Loss time must be a positive number.");
            }
        }
 partial void Price_Validate(EntityValidationResultsBuilder results)
 {
     if (Price < 0)
     {
         results.AddPropertyError("Price must be greater than zero.");
     }
 }
Esempio n. 5
0
 partial void NoComerciableAPartirDe_Validate(EntityValidationResultsBuilder results)
 {
     if (this.NoComerciableAPartirDe < DateTime.Now)
     {
         results.AddPropertyError("La fecha para expirar el producto debe ser mayor a la actual.");
     }
 }
partial         void ManHours_Validate(EntityValidationResultsBuilder results)
        {
            if (this.ManHours < 0)
            {
                results.AddPropertyError("Man hours must be a positive number.");
            }
        }
        partial void Name_Validate(EntityValidationResultsBuilder results)
        {
            /*
             * This is where the business logic would have gone
             * Compare this code to the code in CustomerValidationController.ValidateCustomer
             *
             * if (Name != null)
             * {
             *  if (Name.Length < 3)
             *      results.AddPropertyError("Names cannot be less than 3 characters");
             *
             *  var reg = Regex.Match(Name, @"[0-9]");
             *  if (reg.Success)
             *      results.AddPropertyError("Names cannot contain numbers");
             * }
             */
            var controller = new CustomerValidationController(this);

            IEnumerable <string> errorMessages;

            if (!controller.ValidateCustomer(out errorMessages))
            {
                foreach (var error in errorMessages)
                {
                    results.AddPropertyError(error);
                }
            }
        }
Esempio n. 8
0
 //</Snippet19>
 //<Snippet2>
 partial void ShippedDate_Validate(EntityValidationResultsBuilder results)
 {
     if (this.ShippedDate > DateTime.Today)
     {
         results.AddPropertyError("Shipped date cannot be later than today");
     }
 }
 partial void Year_Validate(EntityValidationResultsBuilder results)
 {
     if (Year < 1930 || Year > 2030)
     {
         results.AddPropertyError("Year must be in 1930 to 2030.");
     }
 }
Esempio n. 10
0
 partial void CustomerOrderNumber_Validate(EntityValidationResultsBuilder results)
 {
     if (this.CustomerOrderNumber.Contains("/") | this.CustomerOrderNumber.Contains("\\"))
     {
         results.AddPropertyError("CustomerOrderNumber cannot contain / or \\ characters as it is used for filename generation!");
     }
 }
Esempio n. 11
0
 //<Snippet17>
 partial void OrderDate_Validate(EntityValidationResultsBuilder results)
 {
     if (this.RequiredDate <= this.OrderDate)
     {
         results.AddEntityError("Due date must be later than order date");
     }
 }
Esempio n. 12
0
 partial void Año_Validate(EntityValidationResultsBuilder results)
 {
     if (this.Año < 1900 || this.Año > 2200)
     {
         results.AddPropertyError("El formato del año es incorrecto.");
     }
 }
Esempio n. 13
0
 partial void IVACompras_Validate(EntityValidationResultsBuilder results)
 {
     if (this.IVACompras < 0 || this.IVACompras > 100)
     {
         results.AddPropertyError("El porcentaje de IVA compras debe estar entre 0 y 100.");
     }
 }
Esempio n. 14
0
 partial void Quantity_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (Quantity < 0)
     {
         results.AddPropertyError("Quantity must be zero or greater than zero");
     }
 }
Esempio n. 15
0
 partial void Purchase_Rate_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (Purchase_Rate < 0)
     {
         results.AddPropertyError("Purchase Rate must be zero or greater than zero");
     }
 }
 partial void CurrentContract_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.ContractPrice < 0)
     {
         results.AddPropertyError("A Service Contract price cannot be less than 0");
     }
 }
Esempio n. 17
0
partial         void DateOfBirth_Validate(EntityValidationResultsBuilder results)
        {
            if (this.DateOfBirth > DateTime.Today)
            {
                results.AddPropertyError("Your date of birth cannot be today");
            }
            // results.AddPropertyError("<Error-Message>");
        }
Esempio n. 18
0
 //<Snippet19>
 partial void RequiredDate_Validate(EntityValidationResultsBuilder results)
 {
     if (this.RequiredDate < this.OrderDate)
     {
         results.AddEntityError
             ("Required data cannot be earlier than the order date");
     }
 }
 partial void BirthDate_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.BirthDate.HasValue && this.BirthDate > DateTime.Today)
     {
         results.AddPropertyError("Birthdate cannot be in the future");
     }
 }
Esempio n. 20
0
 partial void Machine_Reading_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (Machine_Reading == null)
     {
         Machine_Reading = 0;
     }
 }
 //Listing 7-3. Making fields mandatory based on some condition
 partial void ClosedByEngineer_Validate(
     EntityValidationResultsBuilder results)
 {
     if (ClosedDateTime.HasValue && ClosedByEngineer == null)
     {
         results.AddPropertyError("Closed By Engineer is required");
     }
 }
 partial void Amount_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.Amount <= 0)
     {
         results.AddPropertyError("Invalid Amount");
     }
 }
Esempio n. 23
0
 partial void Deposit_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.Deposit > this.DueAmount || this.Deposit <= 0)
     {
         results.AddPropertyError("Invalid payment.");
     }
 }
Esempio n. 24
0
 partial void PurchasePrice_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.PurchasePrice < 0)
     {
         results.AddPropertyError("Purchase Price cannot be less than 0");
     }
 }
 partial void Behandeldatum_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (Behandeldatum > DateTime.Now)
     {
         results.AddPropertyError("Een behandeldatum kan niet in de toekomst liggen!");
     }
 }
Esempio n. 26
0
 partial void CurrentValue_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.CurrentValue < 0)
     {
         results.AddPropertyError("Current Value cannot be less than 0");
     }
 }
Esempio n. 27
0
 partial void MaintenanceTypeIntervalInMonths_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.MaintenanceTypeIntervalInMonths < 0)
     {
         results.AddPropertyError("Maintenance interval (in months) cannot be less than 0");
     }
 }
partial         void razon_social_rep_Legal_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            if (this.razon_social_rep_Legal == null)
            {
                this.razon_social_rep_Legal = " ";
            }
        }
 partial void Soort_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (Soort != "HO" && Soort != "KA" && Soort != "KN" && Soort != "VO" && Soort != "VI")
     {
         results.AddPropertyError("Deze diersoort is niet bekend");
     }
 }
 partial void Deposit_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if(this.Deposit>this.DueAmount || this.Deposit<=0)
     {
         results.AddPropertyError("Invalid payment.");
     }
 }
Esempio n. 31
0
 partial void Quantity_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (Quantity <= 0)
     {
         results.AddPropertyError("Quantity cannot be negative. Closing sale is not correctly entered ");
     }
 }
 partial void Termino_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Mensaje de error>");
     if (this.Termino < this.Inicio)
     {
         results.AddPropertyError("La fecha de término debe ser mayor o igual a la fecha de inicio");
     }
 }
Esempio n. 33
0
        partial void rePassword_Validate(EntityValidationResultsBuilder results)
        {
            if (rePassword != Password)
            {
                results.AddPropertyError("הסיסמאות אינן תואמות, אנא חזור שנית");
            }

        }
 partial void Salaris_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (Salaris < 1850 || Salaris > 5000)
     {
         results.AddPropertyError("Dit salaris valt buiten de range (1850 - 5000 euro)");
     }
 }
 //Listing 5-2. Compare Validation
 partial void ClosedDateTime_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.CreateDateTime > this.ClosedDateTime)
     {
         results.AddPropertyError("Closed Date cannot be before Create Date");
     }
 }
 partial void employee_code_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (!Regex.IsMatch(employee_code, @"\d{6}"))
     {
         results.AddPropertyError("Wrong Format");
     }
 }
partial         void Dig_verificador_emp_subco_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            if (this.Dig_verificador_emp_subco != null && System.Text.RegularExpressions.Regex
               .IsMatch(this.Dig_verificador_emp_subco, @"^[a-zA-Z]+$"))
            {
                results.AddPropertyError("Favor ingresar Rut Valido");
            }
        }
        partial void Inicio_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            if (this.Inicio <= DateTime.Today)
            {
                results.AddPropertyError("La fecha de inicio debe ser después de hoy");
            }

        }
Esempio n. 39
0
        //Listing 7-1. Creating a validation warning
        partial void EmailAddress_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Error-Message>");

            if (System.String.IsNullOrEmpty(EmailAddress))
            {
                results.AddPropertyResult("Email Address recommended", ValidationSeverity.Informational);
            }
        }
partial         void RUT_rep_Legal_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            if (this.RUT_rep_Legal != null && System.Text.RegularExpressions.Regex
            .IsMatch(this.RUT_rep_Legal, @"^[a-zA-Z]+$"))
            {
                results.AddPropertyError("Favor ingresar Rut Valido");
            }
        }
 //Listing 5-3. Making Fields Mandatory Based on Some Condition
 partial void ClosedByEngineer_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (ClosedByEngineer != null &&
         ClosedDateTime.HasValue == false)
     {
         results.AddPropertyError("Closed By Date must be entered");
     }
 }
partial         void fecha_entr_Vigencia_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            if (this.fecha_entr_Vigencia != null && !System.Text.RegularExpressions.Regex
                     .IsMatch(this.fecha_entr_Vigencia, @"[0-9]{1,9}(\.[0-9]{0,2})?$"))
            {
                results.AddPropertyError("Favor ingresar fecha Valido");
            }
        }
partial         void fecha_expira_Estipulada_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Mensaje de error>");
            if (this.fecha_expira_Estipulada != null && System.Text.RegularExpressions.Regex
               .IsMatch(this.fecha_expira_Estipulada, @"^[a-zA-Z]+$"))

            {
                results.AddPropertyError("Favor ingresar fecha Valido");
            }
        }
Esempio n. 44
0
 partial void StockCheckDate_Validate(EntityValidationResultsBuilder results)
 {
     if (this.StockCheckDate != null)
     {
         if (this.StockCheckDate > DateTime.Today)
         {
             results.AddPropertyError("Cannot add a future stock check date");
         }
     }
 }
 partial void GrossWeight_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.TearWeight != 0)
     {
         if (this.GrossWeight < this.TearWeight)
         {
             results.AddPropertyError("Tear Weight can not exceed Gross weight.");
         }
     }
 }
Esempio n. 46
0
 partial void FindingDate_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.FindingDate != null & this.Audit.DateStarted != null)
     {
         if (this.FindingDate < this.Audit.DateStarted)
         {
             results.AddPropertyError("Aa audit finding date cannot be earlier than the audit start date");
         }
     }
 }
 partial void Weight_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Error-Message>");
     if (this.Item != null)
     {
         if (this.Weight > this.Item.Stock)
         {
             results.AddPropertyError("Not enough stock available.");
         }
     }
 }
Esempio n. 48
0
partial         void RevisionRequired_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Error-Message>");
            if (RevisionRequired)
            {
                if (Offers.Count(x => x.State == 0) > 0)
                {
                     results.AddEntityResult("Opportunity major items has changed, the current active offer requires a revision", ValidationSeverity.Warning, "RevisionRequired");
                }
            }
        }
 partial void bis_Validate(EntityValidationResultsBuilder results)
 {
     if (bis <= von)
     {
         results.AddPropertyError("Bis-Datum liegt vor dem Von-Datum");
     }
     if (MitarbeiterItem.VertragItemCollection.Any(p => p.von <= bis && p.bis >= bis && p.Id != Id))
     {
         VertragAb = MitarbeiterItem.VertragItemCollection.Where(p => p.von <= bis && p.bis >= bis && p.Id!=Id).OrderBy(q=>q.von).First().von;
         results.AddPropertyError("Ein weiterer Vertrag ab "+ VertragAb.ToShortDateString() + " existiert bereits. Bitte ändern Sie das Bis-Datum!");
     }
 }
 partial void NumeroDias_Validate(EntityValidationResultsBuilder results)
 {
     // results.AddPropertyError("<Mensaje de error>");
         
         if (this.NumeroDias > this.SALDO)
         {
             results.AddPropertyError("El número de días a solicitar debe ser menor que tu SALDO DE DÍAS");
         }
         if (this.NumeroDias <= 0)
         {
             results.AddPropertyError("El número de días a solicitar debe ser mayor a cero");
         }
 }
Esempio n. 51
0
partial         void NominatedByUser_Validate(EntityValidationResultsBuilder results)
        {
            //NOTE: due to not being able to set the nominated user in "Achievement.js" we can assume that if it's null here, it's being created in the HTML app:
            if (NominatedByUser == null)
            {
                NominatedByUser = DataWorkspace.GetCurrentUser();
            }

            if (!NominatedByUser.LoginId.Equals(Application.User.Name, StringComparison.InvariantCultureIgnoreCase))
            {
                results.AddPropertyError("You can only alter achievements you created, not someone else's");
            }
        }
partial         void SSN_Validate(EntityValidationResultsBuilder results)
        {
            if (this.SSN != "")
            {//'Add the dashes if the user didn't enter it and the SSN is 9 characters
                if (!this.SSN.Contains("-") && this.SSN.Length == 9)
                {
                    this.SSN = this.SSN.Substring(0, 3) + "-" + this.SSN.Substring(3, 2) + "-" + this.SSN.Substring(5);
                }
            }
            //'Now validate based on regular expression pattern
            if (!Regex.IsMatch(this.SSN, "^\\d{3}-\\d{2}-\\d{4}$"))
            {
                results.AddPropertyError("Please enter a valid SSN (i.e. 123-45-6789).");
            }
        }
partial         void Phone_Validate(EntityValidationResultsBuilder results)
        {
            // results.AddPropertyError("<Error-Message>");
            if (this.Phone != "")
            {
                //'Add the dashes if the user didn't enter it and the SSN is 9 characters
                //if (!this.Phone.Contains("-") && this.Phone.Length == 10)
                //{
                //    this.Phone = this.Phone.Substring(0, 3) + "-" + this.Phone.Substring(3, 3) + "-" + this.Phone.Substring(6);
                //}
            }
            //'Now validate based on regular expression pattern
            if (!Regex.IsMatch(this.Phone, "^\\d{3}-\\d{3}-\\d{4}$"))
            {
                //results.AddPropertyError("Please enter a valid Phone (i.e. 123-456-7890).", this.Details.Properties.Phone);
                results.AddEntityError("Please enter a valid Phone (i.e. 123-456-7890).");
            }
        }
Esempio n. 54
0
partial         void RatedByUser_Validate(EntityValidationResultsBuilder results)
        {
            //NOTE: similar to Achievement, if the RatedByUser is null we must be coming from the HTML client, so set it
            if (RatedByUser == null)
            {
                RatedByUser = DataWorkspace.GetCurrentUser();
            }

            if (!RatedByUser.LoginId.Equals(Application.User.Name, StringComparison.InvariantCultureIgnoreCase))
            {
                results.AddPropertyError("You can only alter your own r8ing, not someone else's");
            }

            if (DataWorkspace.ApplicationData.Ratings.Where(_ => _.Achievement.Id == Achievement.Id && _.RatedByUser.LoginId.Equals(Application.User.Name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault() != null)
            {
                results.AddPropertyError("You may only r8 an achievement once.  You have already r8ed this achievement, please delete one of the r8ings");
            }
        }
        partial void DueDate_Validate(EntityValidationResultsBuilder results)
        {
            if (this.DueDate != null & this.Project.StartDate != null)
            {
                if (this.DueDate < this.Project.StartDate)
                {
                    results.AddPropertyError("A task due date cannot be set to before the project start date");
                }
            }

            if (this.DueDate != null & this.Project.EndDate != null)
            {
                if (this.DueDate > this.Project.EndDate)
                {
                    results.AddPropertyError("A task due date cannot be set to beyond the project end date");
                }
            }
        }