Add project files.
This commit is contained in:
parent
cc6b248537
commit
717b0f0a8e
31 changed files with 1296 additions and 0 deletions
16
BMA.EHR.Application/ApplicationServicesRegistration.cs
Normal file
16
BMA.EHR.Application/ApplicationServicesRegistration.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace BMA.EHR.Application
|
||||
{
|
||||
public static class ApplicationServicesRegistration
|
||||
{
|
||||
public static IServiceCollection AddApplication(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<PrefixRepository>();
|
||||
services.AddTransient<BloodGroupRepository>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
BMA.EHR.Application/BMA.EHR.Application.csproj
Normal file
19
BMA.EHR.Application/BMA.EHR.Application.csproj
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BMA.EHR.Domain\BMA.EHR.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using BMA.EHR.Domain.Entities.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Application.Common.Interfaces
|
||||
{
|
||||
public interface IApplicationDBContext
|
||||
{
|
||||
DbSet<PrefixEntity> Prefixes { get; set; }
|
||||
|
||||
DbSet<BloodGroupEntity> BloodGroups { get; set; }
|
||||
|
||||
Task<int> SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
namespace BMA.EHR.Application.Common.Interfaces
|
||||
{
|
||||
public interface IGenericRepository<S,T> where T : class
|
||||
{
|
||||
Task<T?> GetByIdAsync(S id);
|
||||
|
||||
Task<IReadOnlyList<T>> GetAllAsync();
|
||||
}
|
||||
}
|
||||
26
BMA.EHR.Application/Repositories/BloodGroupRepository.cs
Normal file
26
BMA.EHR.Application/Repositories/BloodGroupRepository.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Domain.Entities.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories
|
||||
{
|
||||
public class BloodGroupRepository : IGenericRepository<Guid, BloodGroupEntity>
|
||||
{
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
|
||||
public BloodGroupRepository(IApplicationDBContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<BloodGroupEntity>> GetAllAsync()
|
||||
{
|
||||
return await _dbContext.BloodGroups.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<BloodGroupEntity?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _dbContext.BloodGroups.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
26
BMA.EHR.Application/Repositories/PrefixRepository.cs
Normal file
26
BMA.EHR.Application/Repositories/PrefixRepository.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using BMA.EHR.Application.Common.Interfaces;
|
||||
using BMA.EHR.Domain.Entities.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Application.Repositories
|
||||
{
|
||||
public class PrefixRepository : IGenericRepository<Guid, PrefixEntity>
|
||||
{
|
||||
private readonly IApplicationDBContext _dbContext;
|
||||
|
||||
public PrefixRepository(IApplicationDBContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<PrefixEntity>> GetAllAsync()
|
||||
{
|
||||
return await _dbContext.Prefixes.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<PrefixEntity?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _dbContext.Prefixes.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue