public async Task AddAsync(SalesTaxAddModel model) { var result = await _bankAccountRepository.getAccountTypeByCode(); var bankAcc = SalesTaxFactory.AccountCreate(model, _userId, result.KeyInt); await _bankAccountRepository.AddAsync(bankAcc); await _unitOfWork.SaveChangesAsync(); await _repository.AddAsync(SalesTaxFactory.Create(model, _userId, bankAcc.Id)); await _unitOfWork.SaveChangesAsync(); }
public static SalesTax Create(SalesTaxAddModel addModel, string userId, int accId) { var salesTax = new SalesTax { Code = addModel.Code, Description = addModel.Description, TaxPercentage = addModel.TaxPercentage, CreatedBy = userId, CreatedOn = Utilities.Utility.GetDateTime(), Status = Utilities.Constants.RecordStatus.Active, BankAccountId = accId }; return(salesTax); }
public static BankAccount AccountCreate(SalesTaxAddModel model, string userId, int typeId) { BankAccount bankAccount = new BankAccount { AccountHolderName = model.Code, Status = Constants.RecordStatus.Active, CreatedBy = userId ?? "0", CreatedOn = Utility.GetDateTime(), AccountCode = model.Code, COA_AccountTypeId = typeId, Description = model.Code, LedgerType = 3, AccountName = model.Code, AccountId = model.Code }; return(bankAccount); }
public async Task <IActionResult> Add([FromBody] SalesTaxAddModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorList())); } if (await _manager.IsCodeExistsAsync(model.Code)) { return(BadRequest("Sales tax of this code is already exists")); } try { await _manager.AddAsync(model); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok()); }