本文整理汇总了C#中Csla.AddErrorResult方法的典型用法代码示例。如果您正苦于以下问题:C# Csla.AddErrorResult方法的具体用法?C# Csla.AddErrorResult怎么用?C# Csla.AddErrorResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Csla
的用法示例。
在下文中一共展示了Csla.AddErrorResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Business or validation rule implementation.
/// </summary>
/// <param name="context">Rule context object.</param>
protected override void Execute(Csla.Rules.RuleContext context)
{
base.Execute(context);
var element = context.Target as SystemOptionsEdit;
if (element == null) return;
var list = context.InputPropertyValues[this.InputProperties[0]] as SystemParametersList;
if (list == null) return;
var duplicates = list.GroupBy(x => x.Name.Trim()).Where(x => x.Count() > 1).Select(k=>k.Key);
if (!duplicates.Any())
{
return;
}
context.AddErrorResult("This name already exists: " + duplicates.First());
_required.Execute(context);
}
示例2: Execute
protected override void Execute(Csla.Rules.RuleContext context)
{
var target = (VoucherEdit)context.Target;
string firstName = (string)ReadProperty(target, FirstProperty);
string lastName = (string)ReadProperty(target, LastProperty);
string companyName = (string)ReadProperty(target, CompanyProperty);
string address1 = (string)ReadProperty(target, AddressLine1Property);
string municipality = (string)ReadProperty(target, MunicipalityProperty);
string postalCode = (string)ReadProperty(target, PostalCodeProperty);
if (!string.IsNullOrEmpty(firstName + lastName + companyName) && !string.IsNullOrEmpty(address1) && !string.IsNullOrEmpty(municipality) && !string.IsNullOrEmpty(postalCode) && target.IsDirty )
{
//if a complete address then verify against web service
var config = ConfigurationManager.AppSettings;
var dataCleanEventFactory =
new DataCleanEventFactory(
new DataCleaner(config),
new DataCleanRespository(),
new DataCleanCriteria()
{
AutoFixAddressLine1 = false,
AutoFixCity = false,
AutoFixPostalCode = false,
AutoFixState = false,
ForceValidation = false
});
var inputAddress = new InputStreetAddress()
{
AddressLine1 = target.AddressLine1,
AddressLine2 = target.AddressLine2,
City = target.Municipality,
CompanyName = target.Company,
Country = target.Country,
FirstName = target.First,
FullName = target.FullName,
LastName = target.Last,
PostalCode = target.PostalCode,
State = target.Region
};
var dataCleanEvent = dataCleanEventFactory.ValidateAddress(inputAddress);
if (!dataCleanEvent.Output.OkMailingAddress)
{
var errStr = string.Empty;
foreach (var err in dataCleanEvent.Output.Errors)
{
context.AddErrorResult(err.LongDescription);
}
}
}
}