public AddAccountValidator(ICurrencyService currencyService, IAccountGroupService accountGroupService, IAccountService accountService)
        {
            RuleFor(t => t.AccountGroupId).NotEmpty();
            RuleFor(t => t.Name).NotEmpty().Length(1, 100);

            RuleFor(t => t.CurrencyId).NotEmpty().CustomAsync(async(id, context, cancel) =>
            {
                var isValid = await currencyService.IsValidAsync(id);
                if (!isValid)
                {
                    context.AddFailure("That Currency is not Exist");
                }
            });
            RuleFor(t => t.ParentAccountId).CustomAsync(async(id, context, cancel) =>
            {
                if (id.HasValue)
                {
                    var isValid = await accountService.IsValidAsync(id.Value);
                    if (!isValid)
                    {
                        context.AddFailure("This user do not own that Account");
                    }
                }
            });

            RuleFor(t => t.AccountGroupId).NotEmpty().CustomAsync(async(id, context, cancel) =>
            {
                var isValid = await accountGroupService.IsValidAsync(id);
                if (!isValid)
                {
                    context.AddFailure("This user do not own that Account Group");
                }
            });
        }
 public TestDataSeeder(IAccountService accountService, ITransactionService transactionService,
                       IAccountGroupService accountGroupService, ICurrencyService currencyService, ICategoryService categoryService,
                       IUserIdentityContext userContext, ICommandDispatcher commandDispatcher)
 {
     this.accountService      = accountService;
     this.transactionService  = transactionService;
     this.accountGroupService = accountGroupService;
     this.currencyService     = currencyService;
     this.categoryService     = categoryService;
     this.userContext         = userContext;
     this.commandDispatcher   = commandDispatcher;
 }
Example #3
0
 public AccountGroupMemberService(
     IContextService <IPsaContext> arg0,
     IAccountGroupMemberRepository arg1,
     IValidator <AccountGroupMember> arg2,
     IAuthorization <IPsaContext, AccountGroupMember> arg3,
     IAccountService arg4,
     IAuthorization <IPsaContext, Account> arg5,
     IAccountGroupService arg6
     ) : base(arg0, arg1, arg2, arg3)
 {
     field4 = arg4;
     field5 = arg5;
     field6 = arg6;
 }
 public AccountsGroupsController(IAccountGroupService accountGroupService, ICommandDispatcher commandDispatcher) : base(commandDispatcher)
 {
     this.accountGroupService = accountGroupService;
 }