public MSI_ComplaintMain Get(string accountNumber, string agencyId, string userRole) { MSI_ComplaintMainRepository repository = null; MSI_ComplaintMain complaint = null; ; try { repository = new MSI_ComplaintMainRepository(); IEnumerable<MSI_ComplaintMain> data = (from existingComplaint in repository.GetAll().Where(record => record.AgencyId == agencyId && record.Account == accountNumber) select existingComplaint); if (data.Count() > 0) { complaint = data.First(); if (!string.IsNullOrEmpty(userRole)) { if (userRole == "user") complaint.IsViewedByOwner = true; if (userRole == "agency") complaint.IsViewedByAgency = true; repository.Update(complaint); } } else { complaint = new MSI_ComplaintMain(); complaint.AgencyId = agencyId; complaint.ComplaintDate = DateTime.Now; IEnumerable<MSI_Debtor> debtors = null; DataQueries query = new DataQueries(); debtors = query.GetDebtors(accountNumber); PopulateDebtInfo(debtors.First(), complaint); //PopulateComplaintID(complaint); } } catch (System.Data.Entity.Validation.DbEntityValidationException validationException) { foreach (System.Data.Entity.Validation.DbEntityValidationResult errorResult in validationException.EntityValidationErrors) { foreach (System.Data.Entity.Validation.DbValidationError error in errorResult.ValidationErrors) { string data = error.ErrorMessage; } } } catch (Exception ex) { } return complaint; }
public IEnumerable<MSI_Debtor> Get(string accountNumber) { IEnumerable<MSI_Debtor> debtors = null; try { DataQueries query = new DataQueries(); debtors = query.GetDebtors(accountNumber); } catch (Exception ex) { } return debtors; }