public List<CreditAgency> GetAgencies() { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.CreditAgencies.OrderBy(s => s.CreditAgency1).ToList(); } }
//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 List<tblCountry> GetCountry() { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.tblCountry.OrderBy(s => s.Name).ToList(); } }
public EmailGroup GetById(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.EmailGroups.FirstOrDefault(c => c.ID == id); } }
public List<CreditRating> GetRatingsByAgencyID(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.CreditRatings.Where(c => c.CreditAgencyID == id).ToList(); } }
public tblCountry GetCountry(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.tblCountry.FirstOrDefault(c => c.ID == id); } }
public List<CounterParty> GetCounterParty() { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.CounterParties.OrderBy(s => s.Name).ToList(); } }
public CreditRating GetRatings(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.CreditRatings.FirstOrDefault(c => c.ID == id); } }
public CounterParty GetCounterParty(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.CounterParties.FirstOrDefault(c => c.ID == id); } }
public List<tblHoliday> GetPublicHolidays(int id) { using (LoanPriceEntities context =new LoanPriceEntities()) { return context.tblHoliday.Where(c => c.tblCountry.ID == id).ToList(); } }
public List<Borrower> GetBorrowers() { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.Borrowers.OrderBy(s => s.Name).ToList(); } }
public List<QuotesAndTrades> GetQuotesAndTrades() { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.QuotesAndTrades.OrderByDescending(s => s.ID).ToList(); } }
public List<EmailGroup> GetAll() { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.EmailGroups.ToList(); } }
public CreditAgency GetByID(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.CreditAgencies.SingleOrDefault(c => c.ID == id); } }
public List<Login> GetAccounts() { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.Logins.Where(c => !c.IsLocked).ToList(); } }
public void InsertDuplicateRecord(DuplicateRecord select) { using (LoanPriceEntities context = new LoanPriceEntities()) { context.AddToDuplicateRecords(select); } }
public List<tblActivityLog> GetAllLogs() { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.tblActivityLogs.ToList(); } }
/// <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 tblEmailQue GetEmailQue(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.tblEmailQues.FirstOrDefault(c => c.ID == id); } }
public Borrower GetBorrowers(int id) { using (LoanPriceEntities context = new LoanPriceEntities()) { return context.Borrowers.FirstOrDefault(c => c.ID == id); } }
public List<tblActivityLog> GetTodayLogs() { using (LoanPriceEntities context = new LoanPriceEntities()) { DateTime date = DateTime.Now.Date; return context.tblActivityLogs.Where(c => EntityFunctions.TruncateTime(c.ActivityDate) == date).ToList(); } }
public QuotesAndTrades GetQuotesAndTrades(string loanName) { using (LoanPriceEntities context = new LoanPriceEntities()) { QuotesAndTrades model = context.QuotesAndTrades.OrderByDescending(s => s.ID).First(c => c.LoanName == loanName); return model; } }
public tblActivityLog AddActivityLog(tblActivityLog model) { using (LoanPriceEntities context = new LoanPriceEntities()) { context.tblActivityLogs.AddObject(model); context.SaveChanges(); return model; } }
public string SaveHistory(LoanHistory history) { using (LoanPriceEntities context = new LoanPriceEntities()) { context.AddToLoanHistories(history); context.SaveChanges(); return "History is added successfully"; } }
public List<EmailGroup> GetEmailReceiver(string group) { using (LoanPriceEntities context = new LoanPriceEntities()) { // Get email receiver group return context.EmailGroups.Where(c => c.GroupName == group).ToList(); return null; } }
public int GetBorrowerFromName(string name) { using (LoanPriceEntities context = new LoanPriceEntities()) { Borrower borrower = context.Borrowers.FirstOrDefault(c => c.Name == name); if (borrower != null) return borrower.ID; else return 0; } }
public int GetCountryFromName(string name) { using (LoanPriceEntities context = new LoanPriceEntities()) { tblCountry group = context.tblCountry.FirstOrDefault(c => c.Name == name); if (group != null) return group.ID; else return 0; } }
public bool IsValidName(string countryName) { using (LoanPriceEntities context = new LoanPriceEntities()) { int count = context.tblCountry.Where(s => s.Name == countryName).Count(); if (count == 0) return true; else return false; } }
public bool CheckForExist(string loanName, string counterParty) { using (LoanPriceEntities context = new LoanPriceEntities()) { List<QuotesAndTrades> quoteList = context.QuotesAndTrades.Where(s => s.LoanName == loanName && s.CounterParty == counterParty).ToList(); if (quoteList != null && quoteList.Count > 0) return true; else return false; } }
public Setting GetSettingyear(string name) { using (LoanPriceEntities context = new LoanPriceEntities()) { Setting setting = context.Settings.SingleOrDefault(s => s.Name == name); if (setting != null) return setting; else return null; } }