public Loans GetLoanByCode(string loanCode) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.Loans.FirstOrDefault(c => c.CodeName == loanCode)); } }
public Currency GetByID(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.Currencies.SingleOrDefault(c => c.ID == id)); } }
public void UpdateQuote(QuotesAndTrades quote) { using (LoanPriceEntities context = new LoanPriceEntities()) { QuotesAndTrades model = context.QuotesAndTrades.SingleOrDefault(c => c.ID == quote.ID); if (model != null) { model.CounterParty = quote.CounterParty; model.BidPrice = quote.BidPrice; model.OfferPrice = quote.OfferPrice; model.BidSpread = quote.BidSpread; model.OfferSpread = quote.OfferSpread; model.Traded = quote.Traded; model.MarketValue = quote.MarketValue; model.Country = quote.Country; model.TimeStamp = quote.TimeStamp; model.LoanName = quote.LoanName; model.AvgLifeDisc = quote.AvgLifeDisc; model.AvgLifeNonDisc = quote.AvgLifeNonDisc; model.AvgLifeRiskDisc = quote.AvgLifeRiskDisc; if (quote.SettlementDate != Convert.ToDateTime("01/01/0001 00:00:00")) { model.SettlementDate = quote.SettlementDate; } model.TradedDate = quote.TradedDate; model.Margin = quote.Margin; context.SaveChanges(); } } }
public Borrower GetByID(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.Borrowers.SingleOrDefault(c => c.ID == id)); } }
public List <Currency> GetCurrency() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.Currencies.OrderBy(s => s.Currancy).ToList()); } }
public string SaveCountry(tblCountry country) { using (LoanPriceEntities context = new LoanPriceEntities()) { if (country.ID <= 0) { if (context.tblCountry.Where(s => s.Name == country.Name).Count() == 0) { context.AddTotblCountry(country); context.SaveChanges(); return("Country is added successfully"); } else { return("Entry of the same Name is already exists."); } } else { context.tblCountry.Attach(country); context.ObjectStateManager.ChangeObjectState(country, System.Data.EntityState.Modified); context.SaveChanges(); return("Country is Updates successfully"); } } }
public List <Borrower> GetBorrowers() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.Borrowers.OrderBy(s => s.Name).ToList()); } }
public CounterParty GetCounterParty(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.CounterParties.FirstOrDefault(c => c.ID == id)); } }
public List <CounterParty> GetCounterParty() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.CounterParties.OrderBy(s => s.Name).ToList()); } }
public Group GetById(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.Groups.FirstOrDefault(c => c.ID == id)); } }
public List <tblActivityLog> GetAllLogs() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.tblActivityLogs.ToList()); } }
public List <Group> GetAll() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.Groups.ToList()); } }
public List <CreditRating> GetRatingsByAgencyID(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.CreditRatings.Where(c => c.CreditAgencyID == id).ToList()); } }
public CreditRating GetByID(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.CreditRatings.SingleOrDefault(c => c.ID == id)); } }
public List <Login> GetLockedAccounts() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.Logins.Where(c => c.IsLocked).ToList()); } }
public CreditAgency GetAgency(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.CreditAgencies.FirstOrDefault(c => c.ID == id)); } }
public List <tblCountry> GetCountry() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.tblCountry.OrderBy(s => s.Name).ToList()); } }
public List <CreditAgency> GetAgencies() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.CreditAgencies.OrderBy(s => s.CreditAgency1).ToList()); } }
public tblCountry GetByID(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.tblCountry.SingleOrDefault(c => c.ID == id)); } }
//public bool IsValidName(string name) //{ // using (LoanPriceEntities context = new LoanPriceEntities()) // { // int count = context.CreditRatings.Where(s => s. == name).Count(); // if (count == 0) // return true; // else // return false; // } //} public string SaveAgency(CreditAgency agency) { using (LoanPriceEntities context = new LoanPriceEntities()) { if (agency.ID <= 0) { //if (context.CreditRatings.Where(s => s.CreditAgency == rating.CreditAgency).Count() == 0) //{ context.AddToCreditAgencies(agency); context.SaveChanges(); return("Credit Agency is added successfully"); //} //else // return "Entry of the same Currency is already exists."; } else { //if (context.Currencies.Where(s => s.Currancy == currency.Currancy && s.ID != currency.ID).Count() == 0) //{ context.CreditAgencies.Attach(agency); context.ObjectStateManager.ChangeObjectState(agency, System.Data.EntityState.Modified); context.SaveChanges(); return("Credit Agency is Updated successfully"); //} //else // return "Entry of the same Currency is already exists."; } } }
public string SaveBorrower(Borrower borrower) { using (LoanPriceEntities context = new LoanPriceEntities()) { if (borrower.ID <= 0) { if (context.Borrowers.Where(s => s.Name == borrower.Name).Count() == 0) { context.AddToBorrowers(borrower); context.SaveChanges(); return("Borrower is added successfully"); } else { return("Entry of the same Name is already exists."); } } else { if (context.Borrowers.Where(s => s.Name == borrower.Name && s.ID != borrower.ID).Count() == 0) { context.Borrowers.Attach(borrower); context.ObjectStateManager.ChangeObjectState(borrower, System.Data.EntityState.Modified); context.SaveChanges(); return("Borrower is Updated successfully"); } else { return("Entry of the same Name is already exists."); } } } }
public Login ResetPasswordPublic(string userName, string newPassword, out string message) { using (LoanPriceEntities context = new LoanPriceEntities()) { Login model = context.Logins.FirstOrDefault(c => c.Name == userName); if (model == null) { message = "User with this name doesn't exist"; return(model); } else if (model.IsLocked) { message = "User account is locked. We cann't reset password."; return(model); } // Save password history PasswordHistory history = new PasswordHistory(); history.ChangedDate = DateTime.Now; history.ChangedPassword = newPassword; history.Password = model.Password; history.UserId = model.ID; context.PasswordHistories.AddObject(history); model.Password = newPassword; model.LastPasswordReset = DateTime.Now; context.SaveChanges(); message = "Password reseted successfully"; return(model); } }
public List <tblHoliday> GetPublicHolidays(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.tblHoliday.Where(c => c.tblCountry.ID == id).ToList()); } }
public bool RemoveAccount(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { Login model = context.Logins.FirstOrDefault(c => c.ID == id); if (model != null) { // Delete the Password policy of this account List <PasswordHistory> passwordHistory = context.PasswordHistories.Where(c => c.UserId == model.ID).ToList(); foreach (var item in passwordHistory) { context.PasswordHistories.DeleteObject(item); } // Delete all activity of this user List <tblActivityLog> userActivityList = context.tblActivityLogs.Where(c => c.UserID == model.ID).ToList(); foreach (var item in userActivityList) { context.tblActivityLogs.DeleteObject(item); } context.Logins.DeleteObject(model); context.SaveChanges(); return(true); } else { return(false); } } }
public string SaveCurrency(Currency currency) { using (LoanPriceEntities context = new LoanPriceEntities()) { if (currency.ID <= 0) { if (context.Currencies.Where(s => s.Currancy == currency.Currancy).Count() == 0) { context.AddToCurrencies(currency); context.SaveChanges(); return("Currency is added successfully"); } else { return("Entry of the same Currency is already exists."); } } else { if (context.Currencies.Where(s => s.Currancy == currency.Currancy && s.ID != currency.ID).Count() == 0) { context.Currencies.Attach(currency); context.ObjectStateManager.ChangeObjectState(currency, System.Data.EntityState.Modified); context.SaveChanges(); return("Currency is Updated successfully"); } else { return("Entry of the same Currency is already exists."); } } } }
/// <summary> /// Authenticate the user and log the failed attempts and locked the account if failed attemtps reach to 3 /// </summary> /// <param name="name"></param> /// <param name="password"></param> /// <returns></returns> public Login Authenticate(string name, string password) { using (LoanPriceEntities context = new LoanPriceEntities()) { Login login = context.Logins.FirstOrDefault(c => c.Name == name && c.Password == password); if (login == null) { // Log failed attempt Login log = context.Logins.FirstOrDefault(c => c.Name == name); if (log != null) { log.FailedAttempts = log.FailedAttempts + 1; // if there are 3 failed attempts then Lock the account if (log.FailedAttempts == 3) { log.IsLocked = true; } } } else { // reset failed attempt if login successfully login.FailedAttempts = 0; } context.SaveChanges(); return(login); } }
public List <QuotesAndTrades> GetQuotesAndTrades() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.QuotesAndTrades.OrderByDescending(s => s.ID).ToList()); } }
public void SetLogin(Login model, int type) { using (LoanPriceEntities context = new LoanPriceEntities()) { Login login = context.Logins.Where(c => c.ID == model.ID).FirstOrDefault(); if (login != null) { switch (type) { case 1: login.IsLogin = true; context.SaveChanges(); break; case 2: login.IsLogin = false; context.SaveChanges(); break; default: break; } } } }
public void InsertDuplicateRecord(DuplicateRecord select) { using (LoanPriceEntities context = new LoanPriceEntities()) { context.AddToDuplicateRecords(select); } }
public int GetLoanCount() { using (LoanPriceEntities context = new LoanPriceEntities()) { return(context.Loans.Count()); } }