-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
432b5cc
commit a943f69
Showing
32 changed files
with
486 additions
and
258 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="GenericRepository\Interface\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Dapper" Version="2.0.78" /> | ||
<PackageReference Include="Humanizer" Version="2.14.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="7.0.7" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.7" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.7" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="7.0.7" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="7.0.7" /> | ||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="7.0.7" /> | ||
<PackageReference Include="Npgsql" Version="7.0.4" /> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" /> | ||
<PackageReference Include="Dapper" Version="2.1.28"/> | ||
<PackageReference Include="Humanizer" Version="2.14.1"/> | ||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.1"/> | ||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0"/> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="8.0.1"/> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1"/> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.1"/> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0"/> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0"/> | ||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.1"/> | ||
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.1"/> | ||
<PackageReference Include="Npgsql" Version="8.0.1"/> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0"/> | ||
</ItemGroup> | ||
|
||
</Project> |
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 |
---|---|---|
@@ -1,16 +1,22 @@ | ||
using App.Base.DataContext; | ||
using System; | ||
using System.Linq; | ||
using App.Base.DataContext; | ||
using App.Base.DataContext.Interfaces; | ||
using App.Base.Providers; | ||
using App.Base.Providers.Interface; | ||
using App.Base.Repository; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.FileProviders; | ||
|
||
namespace App.Base | ||
{ | ||
public static class DiConfig | ||
{ | ||
public static IServiceCollection UseBase(this IServiceCollection service) | ||
=> service.AddScoped<IConnectionProvider, ConnectionProvider>() | ||
public static IServiceCollection UseBase(this IServiceCollection services) | ||
{ | ||
services.AddScoped<IConnectionProvider, ConnectionProvider>() | ||
.AddScoped<IUow, Uow>(); | ||
services.AddScoped(typeof(IRepository<,>), typeof(Repository<,>)); | ||
return services; | ||
} | ||
} | ||
} |
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,16 @@ | ||
#nullable enable | ||
using System; | ||
using App.Base.Constants; | ||
|
||
namespace App.Base.Entities | ||
{ | ||
public abstract class FullAuditedEntity<TKey> | ||
{ | ||
public TKey Id { get; set; } | ||
public DateTime CreatedDate { get; set; } = DateTime.Now; | ||
public DateTime? UpdatedDate { get; set; } | ||
public char RecStatus { get; set; } = Status.Active; | ||
public TKey CreatedBy { get; set; } | ||
public TKey UpdatedBy { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
App.Base/GenericRepository/Interface/IGenericRepository.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#nullable enable | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Threading.Tasks; | ||
|
||
namespace App.Base.Repository; | ||
|
||
public interface IRepository<T, in TKey> where T : class | ||
{ | ||
Task<T?> FindByAsync(TKey id); | ||
|
||
T? Find(TKey id); | ||
|
||
Task<int> GetCountAsync(Expression<Func<T, bool>> predicate); | ||
|
||
Task<bool> CheckIfExistAsync(Expression<Func<T, bool>> predicate); | ||
|
||
Task<T?> GetItemAsync(Expression<Func<T, bool>> predicate); | ||
|
||
Task<List<T>> GetAllAsync(Expression<Func<T, bool>> predicate = null); | ||
|
||
List<T> Get(Expression<Func<T, bool>> predicate); | ||
|
||
IQueryable<T?> GetQueryable(); | ||
|
||
Task<T> FindOrThrowAsync(TKey id, string message); | ||
} |
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,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace App.Base.Repository; | ||
|
||
public class Repository<T, TKey> : IRepository<T, TKey> where T : class | ||
{ | ||
private readonly DbSet<T> _dbSet; | ||
|
||
public Repository(DbContext dbContext) | ||
{ | ||
_dbSet = dbContext.Set<T>(); | ||
} | ||
|
||
public virtual async Task<T?> FindByAsync(TKey id) => await _dbSet.FindAsync(id); | ||
|
||
public virtual T? Find(TKey id) => _dbSet.Find(id); | ||
|
||
public virtual async Task<int> GetCountAsync(Expression<Func<T, bool>> predicate) | ||
{ | ||
predicate ??= x => true; | ||
return await _dbSet.CountAsync(predicate); | ||
} | ||
|
||
public virtual async Task<bool> CheckIfExistAsync(Expression<Func<T, bool>> predicate) => await _dbSet.AnyAsync(predicate); | ||
|
||
public virtual Task<T?> GetItemAsync(Expression<Func<T, bool>> predicate) => _dbSet.FirstOrDefaultAsync(predicate); | ||
|
||
public virtual Task<List<T>> GetAllAsync(Expression<Func<T, bool>> predicate = null) | ||
{ | ||
predicate ??= x => true; | ||
return _dbSet.Where(predicate).ToListAsync(); | ||
} | ||
|
||
public virtual List<T> Get(Expression<Func<T, bool>> predicate) => _dbSet.Where(predicate).ToList(); | ||
|
||
public virtual IQueryable<T?> GetQueryable() => _dbSet.AsQueryable(); | ||
|
||
public virtual async Task<T> FindOrThrowAsync(TKey id, string message) | ||
{ | ||
var entity = await FindByAsync(id); | ||
if (entity == null) | ||
{ | ||
throw new Exception(message); | ||
} | ||
|
||
return entity; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using App.User.Entity; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace App.User; | ||
|
||
public static class EntityRegisterer | ||
{ | ||
public static ModelBuilder AddUser(this ModelBuilder builder) | ||
{ | ||
builder.Entity<Model.User>(); | ||
builder.Entity<AppUser>(); | ||
return builder; | ||
} | ||
} |
Oops, something went wrong.