Use file scoped namepace

This commit is contained in:
2022-12-22 15:29:53 +01:00
parent 27bf5f0b24
commit 6d7e447ccc
51 changed files with 886 additions and 937 deletions

View File

@@ -4,28 +4,27 @@ using System.Linq.Expressions;
using GerstITS.Common;
using GerstITS.Data;
namespace GerstITS.Examples.Logic.Shared
namespace GerstITS.Examples.Logic.Shared;
internal static class ISearchEngineExtensions
{
internal static class ISearchEngineExtensions
#region Methods
public static TEntity QueryBy<TEntity>(this IReadOnlyRepository repository, Expression<Func<TEntity, bool>> condition)
where TEntity : IEntity
{
#region Methods
public static TEntity QueryBy<TEntity>(this IReadOnlyRepository repository, Expression<Func<TEntity, bool>> condition)
where TEntity : IEntity
{
return repository.Query<TEntity>()
.Where(condition)
.FirstOrDefault();
}
public static TModel ThrowsAnExceptionIfNotFound<TModel, TKey>(this TModel model, TKey id)
{
if (model.IsNull())
throw new EntityNotFoundException($"{typeof(TModel).Name} with id '{id}' not found.");
return model;
}
#endregion
return repository.Query<TEntity>()
.Where(condition)
.FirstOrDefault();
}
public static TModel ThrowsAnExceptionIfNotFound<TModel, TKey>(this TModel model, TKey id)
{
if (model.IsNull())
throw new EntityNotFoundException($"{typeof(TModel).Name} with id '{id}' not found.");
return model;
}
#endregion
}