-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
220 additions
and
12 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
49 changes: 49 additions & 0 deletions
49
idee5.Globalization.EFCore/SearchResourceKeysForResourceSetQueryHandler.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,49 @@ | ||
using idee5.Common; | ||
using idee5.Globalization.Models; | ||
using idee5.Globalization.Queries; | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace idee5.Globalization.EFCore; | ||
|
||
/// <summary> | ||
/// The search resource keys for resource set query handler. | ||
/// </summary> | ||
public class SearchResourceKeysForResourceSetQueryHandler : IQueryHandlerAsync<SearchResourceKeysForResourceSetQuery, IList<ResourceKey>> { | ||
#region Private Fields | ||
|
||
private readonly GlobalizationDbContext _context; | ||
|
||
#endregion Private Fields | ||
|
||
#region Public Constructors | ||
|
||
public SearchResourceKeysForResourceSetQueryHandler(GlobalizationDbContext context) => _context = context; | ||
|
||
#endregion Public Constructors | ||
|
||
#region Public Methods | ||
|
||
/// <summary> | ||
/// Query the resource ids in a resource set. Including all parlances. | ||
/// </summary> | ||
/// <param name="query">The query.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="query"/> is <c>null</c>.</exception> | ||
public async Task<IList<ResourceKey>> HandleAsync(SearchResourceKeysForResourceSetQuery query, CancellationToken cancellationToken = default) { | ||
ArgumentNullException.ThrowIfNull(query); | ||
return await _context.Resources.Where(Specifications.ContainsInResourceSet(query.ResourceSet, query.SearchValue)).Select(r => new ResourceKey() { | ||
// just casting results in all records being read | ||
ResourceSet = r.ResourceSet, | ||
Id = r.Id, | ||
Industry = r.Industry, | ||
Customer = r.Customer | ||
}).Distinct().ToListAsync(cancellationToken); | ||
} | ||
#endregion Public Methods | ||
} |
49 changes: 49 additions & 0 deletions
49
idee5.Globalization.EFCore/SearchResourceKeysQueryHandler.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,49 @@ | ||
using idee5.Common; | ||
using idee5.Globalization.Models; | ||
using idee5.Globalization.Queries; | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace idee5.Globalization.EFCore; | ||
|
||
/// <summary> | ||
/// The search resource keys query handler. | ||
/// </summary> | ||
public class SearchResourceKeysQueryHandler : IQueryHandlerAsync<SearchResourceKeysQuery, IList<ResourceKey>> { | ||
#region Private Fields | ||
|
||
private readonly GlobalizationDbContext _context; | ||
|
||
#endregion Private Fields | ||
|
||
#region Public Constructors | ||
|
||
public SearchResourceKeysQueryHandler(GlobalizationDbContext context) => _context = context; | ||
|
||
#endregion Public Constructors | ||
|
||
#region Public Methods | ||
|
||
/// <summary> | ||
/// Query the resource ids in a resource set. Including all parlances. | ||
/// </summary> | ||
/// <param name="query">The query.</param> | ||
/// <exception cref="ArgumentNullException"><paramref name="query"/> is <c>null</c>.</exception> | ||
public async Task<IList<ResourceKey>> HandleAsync(SearchResourceKeysQuery query, CancellationToken cancellationToken = default) { | ||
ArgumentNullException.ThrowIfNull(query); | ||
return await _context.Resources.Where(Specifications.Contains(query.SearchValue)).Select(r => new ResourceKey() { | ||
// just casting results in all records being read | ||
ResourceSet = r.ResourceSet, | ||
Id = r.Id, | ||
Industry = r.Industry, | ||
Customer = r.Customer | ||
}).Distinct().ToListAsync(cancellationToken); | ||
} | ||
#endregion Public Methods | ||
} |
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
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
13 changes: 13 additions & 0 deletions
13
idee5.Globalization/Queries/SearchResourceKeysForResourceSetQuery.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,13 @@ | ||
using idee5.Common; | ||
using idee5.Globalization.Models; | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace idee5.Globalization.Queries; | ||
|
||
/// <summary> | ||
/// Search a value in a resource set query. | ||
/// </summary> | ||
/// <param name="ResourceSet">Resource set to search in</param> | ||
/// <param name="SearchValue">Value to search for</param> | ||
public record SearchResourceKeysForResourceSetQuery(string ResourceSet, string SearchValue) : IQuery<IList<ResourceKey>>; |
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,12 @@ | ||
using idee5.Common; | ||
using idee5.Globalization.Models; | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace idee5.Globalization.Queries; | ||
|
||
/// <summary> | ||
/// Search a value in all resource sets query. | ||
/// </summary> | ||
/// <param name="SearchValue">Value to search for</param> | ||
public record SearchResourceKeysQuery(string SearchValue) : IQuery<IList<ResourceKey>>; |
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
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