Example #1
0
        public static Account Create(AccountCreateArgs args)
        {
            Account account = new Account
            {
                AccountId          = Guid.NewGuid(),
                AccountCode        = args.AccountCode,
                AccountName        = args.AccountName,
                AccountDescription = args.AccountDescription,
                ParentAccountId    = args.ParentAccountId,
                DebitOrCredit      = args.DebitOrCredit,
                IsHidden           = args.IsHidden
            };

            return(account);
        }
        public async Task <ActionResult <AccountCreateResponse> > Create([FromBody] AccountCreateRequest request)
        {
            request.EnsureValidation();
            AccountCreateArgs accountCreateArgs = new AccountCreateArgs
            {
                AccountCode        = request.Code,
                AccountName        = request.Name,
                AccountDescription = request.Description,
                ParentAccountId    = request.ParentId,
                DebitOrCredit      = request.DebitOrCredit,
                IsHidden           = request.IsHidden
            };
            IMediator           mediator            = Factory.Resolve <IMediator>();
            AccountCreateResult accountCreateResult = await mediator.Send(new AccountCreateCommand(accountCreateArgs));

            accountCreateResult.EnsureSuccess();
            AccountCreateResponse response = new AccountCreateResponse
            {
                IsSuccess = true
            };

            return(Ok(response));
        }
Example #3
0
 public AccountCreateCommand(AccountCreateArgs args)
 {
     Args = args;
 }