public async Task AddAsync(BankAccountAddModel model)
        {
            var result = BankAccountFactory.Create(model, _userId);

            await _bankAccountRepository.AddAsync(result);

            if (model.COA_AccountTypeId == 1 || model.COA_AccountTypeId == 2 || model.COA_AccountTypeId == 6 || model.COA_AccountTypeId == 7)
            {
                Reconciliation reconciliation = new Reconciliation();
                ReconciliationFactory.Create(result.Id, reconciliation);
                await _reconciliationRepository.AddAsync(reconciliation);
            }
            await _unitOfWork.SaveChangesAsync();
        }
Esempio n. 2
0
 public async Task <IActionResult> Add([FromBody] BankAccountAddModel model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState.GetErrorList()));
     }
     if (model.LedgerType == 2)
     {
         if (await _bankAccountManager.IsAccountNumberExistsAsync(model.AccountNumber))
         {
             return(BadRequest("Bank account number already exists"));
         }
     }
     try
     {
         await _bankAccountManager.AddAsync(model);
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
     return(Ok());
 }
        public static BankAccount Create(BankAccountAddModel model, string userId)
        {
            BankAccount bankAccount = new BankAccount
            {
                AccountNumber     = model.AccountNumber,
                AccountHolderName = model.AccountHolderName,
                BankName          = model.BankName,
                BranchName        = model.BranchName,
                Ifsc              = model.Ifsc,
                Status            = Constants.RecordStatus.Active,
                CreatedBy         = userId ?? "0",
                CreatedOn         = Utility.GetDateTime(),
                AccountCode       = model.AccountCode,
                COA_AccountTypeId = model.COA_AccountTypeId,
                Description       = model.Description,
                LedgerType        = model.LedgerType,
                AccountName       = model.AccountName,
                AccountId         = model.AccountId,
                IsForEdit         = true
            };

            return(bankAccount);
        }
        public async Task AddAsync(BankAccountAddModel model)
        {
            await _bankAccountRepository.AddAsync(BankAccountFactory.Create(model, _userId));

            await _unitOfWork.SaveChangesAsync();
        }