diff --git a/PC2/Data/AgencyDB.cs b/PC2/Data/AgencyDB.cs index a0ccda0..21b207b 100644 --- a/PC2/Data/AgencyDB.cs +++ b/PC2/Data/AgencyDB.cs @@ -95,21 +95,11 @@ public static async Task> GetAllAgenciesAsync(ApplicationDbContext /// public static async Task> GetSpecificAgenciesAsync(ApplicationDbContext context, int categoryID) { - List agencies = await GetAllAgenciesAsync(context); - - List result = new List(); - for (int i = 0; i < agencies.Count; i++) - { - for (int j = 0; j < agencies[i].AgencyCategories.Count; j++) - { - if (agencies[i].AgencyCategories[j].AgencyCategoryId == categoryID) - { - result.Add(agencies[i]); - } - } - } - - return result; + return await context.Agency + .Include(nameof(Agency.AgencyCategories)) + .Where(agency => agency.AgencyCategories.Any(cat => cat.AgencyCategoryId == categoryID)) + .OrderBy(agency => agency.AgencyName) + .ToListAsync(); } /// diff --git a/PC2/Views/Resources/ResourceGuide.cshtml b/PC2/Views/Resources/ResourceGuide.cshtml index 701b7f7..887492f 100644 --- a/PC2/Views/Resources/ResourceGuide.cshtml +++ b/PC2/Views/Resources/ResourceGuide.cshtml @@ -227,27 +227,12 @@ else @if (Model.Agencies[i].Email != null) { - string email = Model.Agencies[i].Email; - int emailStart = 0; - - @*separate multiple emails*@ - @for (int j = 0; j < email.Length; j++) + @foreach (string singleEmail in Model.Agencies[i].Email.Split(' ', StringSplitOptions.RemoveEmptyEntries)) { - // if the email contains a space - if (email[j] == ' ') - { - // display all characters from emailStart to current index as link - string singleEmail = email.Substring(emailStart, j - emailStart); - @singleEmail + @singleEmail.Trim()
- emailStart = j; } } - // display link as final email - string finalEmail = email.Substring(emailStart, email.Length - emailStart); - - @finalEmail - }
@@ -263,85 +248,7 @@ else