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(); }
public static async Task <bool> IsCustomerNameExistAsync(string name) { var result = await NameExistsCommand.ExecuteAsync(name); return(result.isExist); }