Exemplo n.º 1
0
 private void MustHaveShippingAddress(IOrder order, IValidationResults results)
 {
     if (order.ShippingAddress == null)
     {
         results.AddError(ValidationErrorTypes.ShippingAddressRequired, "Must have a shipping address.");
     }
 }
Exemplo n.º 2
0
 private void MustHaveOrderlines(IOrder order, IValidationResults results)
 {
     if (order.OrderLines.Count() < 1)
     {
         results.AddError(ValidationErrorTypes.OrderlinesRequired, "Must have at least one orderline.");
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds all results to the IValidationResults list
        /// </summary>
        private static void CopyModelErrors(IEnumerable <ValidationResult> fromList, IValidationResults toList)
        {
            foreach (var result in fromList)
            {
                string key = result.MemberNames.FirstOrDefault();

                // hint: good place for doing string manipulation (eg. translation)
                string errorMessage = result.ErrorMessage + " (own Validator!)";

                toList.AddError(key, errorMessage);
            }
        }