public async Task <BankContract> Handle(AddBankCommand request, CancellationToken cancellationToken) { try { var contract = request.BankContract; var bank = new BankBuilder() .WithCode(contract.Code) .WithIspb(contract.ISPB) .WithName(contract.Name) .WithDocument(contract.Document) .Build(); await _repository.AddBank(bank); await _uow.CommitAsync(cancellationToken); contract.Id = bank.Id.Value; return(contract); } catch (Exception e) { Log.Error(new { details = "Error on save bank", exception = new { e.Message, e.InnerException } }); throw; } }
private void AddNewBank(long parentDepartmentId, string bankName) { var newBank = new Bank { BankName = bankName }; _bankRepository.AddBank(parentDepartmentId, newBank); }
public HttpResponseMessage AddBank([FromBody] BanksViewModel model) { try { var data = repo.AddBank(model); if (data != null) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, result = model, message = "The record has been creted successfuly" })); } return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = "There was error creating record" })); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.OK, new { success = false, message = $"There was error creating record{e.Message}" })); } }
public async Task <Response> AddBank(Bank bank) { Response response = _utilities.InitializeResponse(); try { int addedBanks = await _bankRepository.AddBank(bank); if (addedBanks > 0) { response.Data = "Bank added successfully"; } if (addedBanks == 0) { return(_utilities.UnsuccessfulResponse(response, "Unable to save Bank")); } }catch (Exception ex) { response = _utilities.CatchException(response); _logger.LogError($"{ex.Message} REQUEST BODY => REQUEST ID => {response.RequestId}"); } return(response); }
public CommonDbResponse AddBank(BankCommon bank) { return(repo.AddBank(bank)); }
public void AddBank(Bank bank) { bank.Author = _currentUserRepository.GetCurrentUserLookupValue(); _bankRepository.AddBank(bank); }