/// <summary>
 /// Adds any errors from the domain to the view model.
 /// </summary>
 /// <param name="currentState">The model state dictionary to update.</param>
 /// <param name="result">The result from the domain validation, which contains any errors that occurred in the domain validation.</param>
 /// <param name="mappingFromDomainToUi">Provides a set of mappings that map the propeties of a domain object to those of a view model object.</param>
 public static void UpdateFromDomain(this ModelStateDictionary currentState, ValidationResult result, StringDictionary mappingFromDomainToUi)
 {
     foreach (var message in result.Messages)
     {
         var propertyName = message.PropertyName;
         if (mappingFromDomainToUi.ContainsKey(message.PropertyName))
             propertyName = mappingFromDomainToUi[message.PropertyName];
         currentState.AddModelError(propertyName, message.Message);
     }
 }
 /// <summary>
 /// Initialises an instance of the DomainValidationException class.
 /// </summary>
 /// <param name="result">The validation result.</param>
 public DomainValidationException(ValidationResult result)
 {
     Result = result;
 }
 /// <summary>
 /// Initialises an instance of the DomainValidationException class.
 /// </summary>
 /// <param name="message">The error message string.</param>
 /// <param name="innerException">The inner exception.</param>
 public DomainValidationException(string message, Exception innerException)
     : base(message, innerException)
 {
     Result = new ValidationResult();
     Result.AddError(message);
 }
 /// <summary>
 /// Initialises an instance of the DomainValidationException class.
 /// </summary>
 /// <param name="message">The error message string.</param>
 /// <param name="propertyName">The property that the error message relates to.</param>
 public DomainValidationException(string message, string propertyName)
 {
     Result = new ValidationResult();
     Result.AddError(message, propertyName);
 }
 /// <summary>
 /// Adds any errors from the domain to the view model.
 /// </summary>
 /// <param name="currentState">The model state dictionary to update.</param>
 /// <param name="result">The result from the domain validation, which contains any errors that occurred in the domain validation.</param>
 public static void UpdateFromDomain(this ModelStateDictionary currentState, ValidationResult result)
 {
     foreach (var message in result.Messages)
         currentState.AddModelError(message.PropertyName, message.Message);
 }