public LoginResponse getLogin(Login model) { var dbcontext = new OnlinebankingContext(); LoginResponse obj = new LoginResponse(); obj = dbcontext.Customer.Where(x => x.CustUserName == model.CustName && x.CustPassword == model.CustPassword) .Select(x => new LoginResponse { CustName = x.CustUserName, IsAdmin = x.IsAdmin, IsFirstLogin = x.IsFirstLogin, CustId = x.CustId }).Single(); if (obj != null) { if (obj.IsFirstLogin == null) { var customer = dbcontext.Customer.FirstOrDefault(x => x.CustId == obj.CustId); if (customer != null) { customer.IsFirstLogin = true; dbcontext.SaveChanges(); } } } return(obj); }
public bool UpdateCustomer(int id, Customer model) { var dbcontext = new OnlinebankingContext(); var customer = dbcontext.Customer.FirstOrDefault(x => x.CustId == id); if (customer != null) { customer.CustName = model.CustName; customer.CustUserName = model.CustUserName; customer.CustPassword = model.CustPassword; customer.CustAddress = model.CustAddress; customer.CustEmail = model.CustEmail; customer.Pan = model.Pan; customer.ContactNo = model.ContactNo; customer.InitialAmount = model.InitialAmount; customer.Dob = model.Dob; customer.Created = DateTime.Now; customer.AccTypeId = model.AccTypeId; customer.ContId = model.ContId; customer.StateId = model.StateId; dbcontext.SaveChanges(); return(true); } return(false); }
public bool AmountTransfer(FundTransferRequest model) { var dbcontext = new OnlinebankingContext(); var amountTransfer = new AmountTransfer(); AmountTransfer objAmt = new AmountTransfer(); var Frmbalance = new OnlinebankingContext().Account.Where(x => x.AccountNo == model.CustAccountNo).OrderByDescending(x => x.Created.Value).Select(x => x.Amount).FirstOrDefault(); if (Frmbalance < model.Amount || Frmbalance < 0 || Frmbalance == null) { return(false); } else { var Tobalance = new OnlinebankingContext().Account.Where(x => x.AccountNo == model.BenAccountNo).OrderByDescending(x => x.Created.Value).Select(x => x.Amount).FirstOrDefault(); decimal FromAccountBalance = Convert.ToDecimal(Frmbalance) - Convert.ToDecimal(model.Amount); decimal ToAccountBalance = Convert.ToDecimal(Tobalance) + Convert.ToDecimal(model.Amount); objAmt.FromAccount = model.CustAccountNo; objAmt.ToAccount = model.BenAccountNo; objAmt.Amount = model.Amount; objAmt.Created = DateTime.Now; dbcontext.AmountTransfer.Add(objAmt); int id = dbcontext.SaveChanges(); if (id > 0) { Account obj = new Account(); obj.AccountNo = model.CustAccountNo; obj.Amount = FromAccountBalance; obj.Created = DateTime.Now; dbcontext.Account.Add(obj); int frmid = dbcontext.SaveChanges(); if (frmid > 0) { Account obj1 = new Account(); obj1.AccountNo = model.BenAccountNo; obj1.Amount = ToAccountBalance; obj1.Created = DateTime.Now; dbcontext.Account.Add(obj1); dbcontext.SaveChanges(); } return(true); } } return(false); }
public bool AddCustomer(Customer model) { var dbcontext = new OnlinebankingContext(); var customer = new Customer(); var account = new Account(); customer.CustId = model.CustId; customer.CustName = model.CustName; customer.CustUserName = model.CustUserName; customer.CustPassword = model.CustPassword; customer.CustAddress = model.CustAddress; customer.CustEmail = model.CustEmail; customer.Pan = model.Pan; customer.ContactNo = model.ContactNo; customer.InitialAmount = model.InitialAmount; customer.AccountNo = model.AccountNo; customer.Dob = model.Dob; customer.Created = DateTime.Now; customer.AccTypeId = model.AccTypeId; customer.ContId = model.ContId; customer.StateId = model.StateId; customer.IsAdmin = model.IsAdmin; dbcontext.Customer.Add(customer); dbcontext.SaveChanges(); long cust_id = customer.CustId; if (cust_id > 0) { var accountData = dbcontext.Customer.FirstOrDefault(x => x.CustId == cust_id); account.AccountNo = accountData.AccountNo; account.Amount = accountData.InitialAmount; account.Created = DateTime.Now; dbcontext.Account.Add(account); dbcontext.SaveChanges(); return(true); } return(false); }
public bool DeleteCustomer(int id) { var dbcontext = new OnlinebankingContext(); var customer = dbcontext.Customer.FirstOrDefault(x => x.CustId == id); if (customer != null) { customer.Deleted = true; dbcontext.SaveChanges(); return(true); } return(false); }
public bool AddBenificiary(AddBenificiary model) { var dbcontext = new OnlinebankingContext(); var customer = new OnlinebankingContext().Customer.FirstOrDefault(x => x.AccountNo == model.BenificiaryAccountNo); var benificiary = new Benificiary(); if (customer != null) { benificiary.CustId = model.cust_id; benificiary.BenId = customer.CustId; dbcontext.Benificiary.Add(benificiary); dbcontext.SaveChanges(); return(true); } return(false); }
public bool changePassword(Password model) { var dbcontext = new OnlinebankingContext(); if (model != null) { var customer = dbcontext.Customer.FirstOrDefault(x => x.CustId == model.CustId); if (customer != null) { customer.CustPassword = model.NewCustPassword; dbcontext.SaveChanges(); return(true); } } return(false); }