当前位置: 首页>>代码示例>>C#>>正文


C# Csla.AddErrorResult方法代码示例

本文整理汇总了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);
            }
开发者ID:mparsin,项目名称:Elements,代码行数:25,代码来源:SystemParametesValidationRule.cs

示例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);
                            }
                            
                        }
                        
                }

            }
开发者ID:FrankMedvedik,项目名称:coopcheck,代码行数:59,代码来源:VoucherEdit.cs


注:本文中的Csla.AddErrorResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。