コード例 #1
0
ファイル: Customer.cs プロジェクト: ghabi2106/CslaProject
            protected override async void Execute(IRuleContext context)
            {
                var name = (string)context.InputPropertyValues[NameProperty];

                NameExistsCommand.Execute(name, (result) =>
                {
                    if (result)
                    {
                        context.AddErrorResult(NameProperty, "Name already exists");
                    }
                });
                context.Complete();

                //----------------------------------------------------------------------------------
                //   Second Method
                //----------------------------------------------------------------------------------


                //var cmd = await NameExistsCommand.ExecuteAsync(name);
                //if (cmd.isExist == true)
                //{
                //    context.AddErrorResult("Name already exists");
                //}
                //context.Complete();
            }
コード例 #2
0
ファイル: Customer.cs プロジェクト: ghabi2106/CslaProject
        public static async Task <bool> IsCustomerNameExistAsync(string name)
        {
            var result = await NameExistsCommand.ExecuteAsync(name);

            return(result.isExist);
        }