public HttpResponseMessage UserReg(tblNetBanking tblbank) { proc_test1_Result result = null; proc_test21_Result result2 = null; proc_test31_Result result3 = null; result = entities.proc_test1(tblbank.user_id).FirstOrDefault(); result2 = entities.proc_test21(tblbank.user_id).FirstOrDefault(); result3 = entities.proc_test31(tblbank.user_id).FirstOrDefault(); if (result2 != null) { if (result3 != null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Already Registered")); } else { tblBalance bal = new tblBalance(); bal.account_number = tblbank.account_number; bal.customer_id = tblbank.user_id; bal.balance = 25000; entities.tblNetBankings.Add(tblbank); entities.tblBalances.Add(bal); entities.SaveChanges(); return(Request.CreateResponse <proc_test1_Result>(result)); } } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "User ID not found")); } }
public HttpResponseMessage Post(int id, tblNetBanking users) { var res = entities.sp_checkOldPassword(id, users.password).FirstOrDefault(); if (res == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Password does not match")); } else { return(Request.CreateResponse(res)); } }
public HttpResponseMessage Put([FromUri] int id, tblNetBanking users) { var res = entities.sp_updateLoginPassword(id, users.password); if (res == 0) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid User ID")); } else { return(Request.CreateResponse(res)); } }
public HttpResponseMessage UserLogin(tblNetBanking netusers) { sp_LoginCheck_Result res = entities.sp_LoginCheck(netusers.user_id, netusers.password).FirstOrDefault(); if (res == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid Username / Password")); } else { return(Request.CreateResponse <sp_LoginCheck_Result>(res)); } }
public HttpResponseMessage GetAccountNumber(string id) { int customer_id = Convert.ToInt32(id); tblNetBanking customer = entities.tblNetBankings.Where(c => c.user_id == customer_id).FirstOrDefault(); if (customer == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid ID")); } else { return(Request.CreateResponse <int>(HttpStatusCode.OK, customer.account_number)); } }
public HttpResponseMessage GetTransactionPassword(string id) { int customer_id = Convert.ToInt32(id); tblNetBanking customer = entities.tblNetBankings.Where(c => c.user_id == customer_id).FirstOrDefault(); if (customer == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Invalid ID")); } else { return(Request.CreateResponse <string>(HttpStatusCode.OK, customer.transaction_password)); } }
public HttpResponseMessage updatePassword(tblNetBanking netbank) { var result = entities.tblNetBankings.Where(a => a.user_id == netbank.user_id).FirstOrDefault(); if (result != null) { result.password = netbank.password; entities.SaveChanges(); return(Request.CreateErrorResponse(HttpStatusCode.Accepted, "Password accepted")); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Password not Updated")); } }
public HttpResponseMessage AddBenificiary(tblBeneficiary beneficiary) { DbContextTransaction trans = entities.Database.BeginTransaction(); try { tblNetBanking customer = entities.tblNetBankings.Where(c => c.account_number == beneficiary.beneficiary_account_number).FirstOrDefault(); if (customer == null) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Benificiary Account Number does not exist")); } else { if (beneficiary.account_number == beneficiary.beneficiary_account_number) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid Account Number")); } tblBeneficiary beneficiary1 = entities.tblBeneficiaries.Where(b => b.beneficiary_account_number == beneficiary.beneficiary_account_number && b.account_number == beneficiary.account_number).FirstOrDefault(); if (beneficiary1 == null) { beneficiary.customer_id = customer.user_id; entities.tblBeneficiaries.Add(beneficiary); entities.SaveChanges(); trans.Commit(); return(Request.CreateResponse <tblBeneficiary>(HttpStatusCode.Created, beneficiary)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Benificiary already added")); } } } catch (Exception) { trans.Rollback(); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Unable to add Beneficiary")); } }