public void Add(BankAccountDetail BankAccount) { try { string clientName = DataBase.DBService.ExecuteCommandScalar(string.Format(GET_CLIENT_NAME_QUERY, BankAccount.Cid)); DataBase.DBService.ExecuteCommand(string.Format(INSERT_QUERY, BankAccount.Cid, BankAccount.AccountHolderID, BankAccount.BankName, BankAccount.AccountNo, BankAccount.AccountType, BankAccount.Address, BankAccount.ContactNo, BankAccount.IsJoinAccount, BankAccount.JoinHolderName, BankAccount.MinRequireBalance, BankAccount.CreatedOn.ToString("yyyy-MM-dd hh:mm:ss"), BankAccount.CreatedBy, BankAccount.UpdatedOn.ToString("yyyy-MM-dd hh:mm:ss"), BankAccount.UpdatedBy, BankAccount.BankId, BankAccount.Nominee)); Activity.ActivitiesService.Add(ActivityType.CreateBankAccount, EntryStatus.Success, Source.Server, BankAccount.UpdatedByUserName, BankAccount.AccountNo, BankAccount.MachineName); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); throw ex; } }
internal BankAccountDetail GetById(int id, int clientId) { BankAccountDetail BankAccountObj = new BankAccountDetail(); try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_ALL_BY_ID_API, id, clientId); RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <IList <BankAccountDetail> >(apiurl, null, "GET"); if (jsonSerialization.IsValidJson(restResult.ToString())) { BankAccountObj = jsonSerialization.DeserializeFromString <BankAccountDetail>(restResult.ToString()); } return(BankAccountObj); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
public IList <BankAccountDetail> Get(int clientId) { try { Logger.LogInfo("Get: Bank account details information process start"); IList <BankAccountDetail> lstBankAccount = new List <BankAccountDetail>(); DataTable dtAppConfig = DataBase.DBService.ExecuteCommand(string.Format(SELECT_ALL_BY_CLIENT_ID, clientId)); foreach (DataRow dr in dtAppConfig.Rows) { BankAccountDetail BankAccount = convertToBankAccountObject(dr); lstBankAccount.Add(BankAccount); } Logger.LogInfo("Get: Bank account details information process completed."); return(lstBankAccount); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(null); } }
public void AddBankAccountDetail(BankAccountDetail bankaccountdetail) { using (var dbcontext = new EntityContext()) { dbcontext.BankAccountDetails.Add(bankaccountdetail); dbcontext.SaveChanges(); } }
public async Task Should_cache_response_when_response_is_successful() { // arrange string cbu = "2323232323"; CancellationToken cancellationToken = CancellationToken.None; BankAccountDetail expected = new BankAccountDetail() { currency = "pesos" }; string url = $"BankAccountDetails?key={cbu}"; object value = null; this.CacheAccessorMock .Setup(x => x.TryGetValue(It.Is <string>(u => u.ToString() == url), out value)) .Returns(false); this.HttpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(expected)) }); // act var actual = await this.Sut.GetBankAccountDetailAsync(cbu, cancellationToken); // assert actual.Should().BeEquivalentTo(expected); this.HttpMessageHandlerMock .Protected() .Verify( "SendAsync", Times.Once(), ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>() ); this.CacheAccessorMock.Verify( x => x.Set( It.Is <string>(p => p == url), It.IsAny <object>(), this.CacheOptions.Value.EntityDataBasicExpiration ), Times.Once() ); }
public void UpdateBankAccountDetail(int id, BankAccountDetail bankaccountdetail) { using (var dbcontext = new EntityContext()) { var found = (from a in dbcontext.BankAccountDetails where a.Id == id select a).FirstOrDefault(); found.BankName = bankaccountdetail.BankName; found.AccountNumber = bankaccountdetail.AccountNumber; found.BranchCode = bankaccountdetail.BranchCode; found.BranchName = bankaccountdetail.BranchName; dbcontext.SaveChanges(); } }
public void Delete(BankAccountDetail BankAccount) { try { DataBase.DBService.ExecuteCommand(string.Format(DELETE_BY_ID, BankAccount.Id)); Activity.ActivitiesService.Add(ActivityType.DeleteBankAccount, EntryStatus.Success, Source.Server, BankAccount.UpdatedByUserName, BankAccount.AccountNo, BankAccount.MachineName); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); throw ex; } }
public Result Delete(BankAccountDetail BankAccountDetail) { var result = new Result(); try { BankAccountService BankAccountDetailService = new BankAccountService(); BankAccountDetailService.Delete(BankAccountDetail); result.IsSuccess = true; } catch (Exception exception) { result.IsSuccess = false; result.ExceptionInfo = exception; } return(result); }
public async Task Should_not_call_http_client_if_response_is_cached() { // arrange string cbu = "23232323"; CancellationToken cancellationToken = CancellationToken.None; BankAccountDetail expected = new BankAccountDetail() { currency = "pesos" }; string url = $"BankAccountDetails?key={cbu}"; object value = expected; this.CacheAccessorMock .Setup(x => x.TryGetValue(It.Is <string>(u => u.ToString() == url), out value)) .Returns(true); // act var actual = await this.Sut.GetBankAccountDetailAsync(cbu, cancellationToken); // assert actual.Should().BeEquivalentTo(expected); this.HttpMessageHandlerMock .Protected() .Verify( "SendAsync", Times.Never(), ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>() ); this.CacheAccessorMock.Verify( x => x.TryGetValue( It.IsAny <string>(), out value ), Times.Once() ); }
internal bool Add(BankAccountDetail BankAccount) { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + ADD_BankAccount_API; RestAPIExecutor restApiExecutor = new RestAPIExecutor(); var restResult = restApiExecutor.Execute <BankAccountDetail>(apiurl, BankAccount, "POST"); return(true); } catch (Exception ex) { StackTrace st = new StackTrace(); StackFrame sf = st.GetFrame(0); MethodBase currentMethodName = sf.GetMethod(); LogDebug(currentMethodName.Name, ex); return(false); } }
private BankAccountDetail convertToBankAccountObject(DataRow dr) { BankAccountDetail BankAccount = new BankAccountDetail(); BankAccount.Id = dr.Field <int>("ID"); BankAccount.Cid = dr.Field <int>("CID"); BankAccount.AccountHolderID = dr.Field <int>("AccountHolderId"); BankAccount.BankName = dr.Field <string>("BankName"); BankAccount.AccountNo = dr.Field <string>("AccountNo"); BankAccount.AccountType = dr.Field <string>("AccountType"); BankAccount.Address = dr.Field <string>("Address"); BankAccount.ContactNo = dr.Field <string>("ContactNo"); BankAccount.IsJoinAccount = dr.Field <bool>("IsJoinAccount"); BankAccount.JoinHolderName = dr.Field <string>("JoinHolderName"); BankAccount.MinRequireBalance = double.Parse(dr["MinRequireBalance"].ToString()); BankAccount.BankId = dr.Field <int>("BankId"); BankAccount.Nominee = dr.Field <string>("Nominee"); return(BankAccount); }
public async Task Should_call_http_client_with_correct_url_if_response_is_not_cached() { // arrange string cbu = "2323232323"; CancellationToken cancellationToken = CancellationToken.None; BankAccountDetail expected = new BankAccountDetail() { currency = "pesos" }; string url = $"BankAccountDetails?key={cbu}"; Uri expectedUri = new Uri($"{this.HttpClient.BaseAddress}{url}"); this.HttpMessageHandlerMock .Protected() .Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(expected)) }); // act var actual = await this.Sut.GetBankAccountDetailAsync(cbu, cancellationToken); // assert actual.Should().BeEquivalentTo(expected); this.HttpMessageHandlerMock .Protected() .Verify( "SendAsync", Times.Once(), ItExpr.Is <HttpRequestMessage>(req => req.Method == HttpMethod.Get && req.RequestUri == expectedUri), ItExpr.IsAny <CancellationToken>() ); }
private BankAccountDetail convertSelectedRowDataToBankAccount(DataGridView dtGridBankAccount) { if (dtGridBankAccount.SelectedRows.Count >= 1) { BankAccountDetail BankAccount = new BankAccountDetail(); DataRow dr = getSelectedDataRowForBankAccount(dtGridBankAccount); if (dr != null) { BankAccount.Id = int.Parse(dr.Field <string>("ID")); BankAccount.Cid = int.Parse(dr.Field <string>("CID")); BankAccount.BankName = dr.Field <string>("BankName"); BankAccount.AccountNo = dr.Field <string>("AccountNo"); BankAccount.AccountType = dr.Field <string>("AccountType"); BankAccount.Address = dr.Field <string>("Address"); BankAccount.ContactNo = dr.Field <string>("ContactNo"); BankAccount.IsJoinAccount = bool.Parse(dr.Field <string>("IsJoinAccount")); BankAccount.JoinHolderName = dr.Field <string>("JoinHolderName"); BankAccount.MinRequireBalance = Double.Parse(dr.Field <string>("MinRequireBalance")); return(BankAccount); } } return(null); }