-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #422 from NielsPilgaard/feature/remove-azure-app-c…
…onfig Remove Azure App config
- Loading branch information
Showing
23 changed files
with
214 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
src/shared/Jordnaer.Shared.Infrastructure/AzureAppConfigurationExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/web/Jordnaer/Features/UserSearch/QueryableUserProfileExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using Jordnaer.Features.Search; | ||
using Jordnaer.Shared; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Jordnaer.Features.UserSearch; | ||
|
||
internal static class QueryableUserProfileExtensions | ||
{ | ||
internal static async Task<(IQueryable<UserProfile> UserProfiles, bool AppliedOrdering)> ApplyLocationFilterAsync( | ||
this IQueryable<UserProfile> users, | ||
UserSearchFilter filter, | ||
IZipCodeService zipCodeService, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(filter.Location) || filter.WithinRadiusKilometers is null) | ||
{ | ||
return (users, false); | ||
} | ||
|
||
var (zipCodesWithinCircle, searchedZipCode) = await zipCodeService.GetZipCodesNearLocationAsync( | ||
filter.Location, | ||
filter.WithinRadiusKilometers.Value, | ||
cancellationToken); | ||
|
||
if (zipCodesWithinCircle.Count is 0 || searchedZipCode is null) | ||
{ | ||
return (users, false); | ||
} | ||
|
||
users = users.Where(user => user.ZipCode != null && | ||
zipCodesWithinCircle.Contains(user.ZipCode.Value)) | ||
.OrderBy(user => Math.Abs(user.ZipCode!.Value - searchedZipCode.Value)); | ||
|
||
return (users, true); | ||
} | ||
|
||
internal static IQueryable<UserProfile> ApplyCategoryFilter(this IQueryable<UserProfile> users, | ||
UserSearchFilter filter) | ||
{ | ||
if (filter.Categories is not null && filter.Categories.Length > 0) | ||
{ | ||
users = users.Where(user => | ||
user.Categories.Any(category => filter.Categories.Contains(category.Name))); | ||
} | ||
|
||
return users; | ||
} | ||
|
||
internal static IQueryable<UserProfile> ApplyNameFilter(this IQueryable<UserProfile> users, string? filter) | ||
{ | ||
if (!string.IsNullOrWhiteSpace(filter)) | ||
{ | ||
users = users.Where(user => !string.IsNullOrEmpty(user.SearchableName) && | ||
EF.Functions.Like(user.SearchableName, $"%{filter}%")); | ||
} | ||
|
||
return users; | ||
} | ||
|
||
internal static IQueryable<UserProfile> ApplyChildFilters(this IQueryable<UserProfile> users,UserSearchFilter filter) | ||
{ | ||
if (filter.ChildGender is not null) | ||
{ | ||
users = users.Where(user => | ||
user.ChildProfiles.Any(child => child.Gender == filter.ChildGender)); | ||
} | ||
|
||
if (filter is { MinimumChildAge: not null, MaximumChildAge: not null } && | ||
filter.MinimumChildAge == filter.MaximumChildAge) | ||
{ | ||
users = users.Where(user => | ||
user.ChildProfiles.Any(child => child.Age != null && | ||
child.Age == filter.MinimumChildAge)); | ||
return users; | ||
} | ||
|
||
if (filter.MinimumChildAge is not null) | ||
{ | ||
users = users.Where(user => | ||
user.ChildProfiles.Any(child => child.Age != null && | ||
child.Age >= filter.MinimumChildAge)); | ||
} | ||
|
||
if (filter.MaximumChildAge is not null) | ||
{ | ||
users = users.Where(user => | ||
user.ChildProfiles.Any(child => child.Age != null && | ||
child.Age <= filter.MaximumChildAge)); | ||
} | ||
|
||
return users; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.