Restructure TAble

This commit is contained in:
Suphonchai Phoonsawat 2023-06-25 18:36:02 +07:00
parent 717b0f0a8e
commit 1ba2f2eec1
37 changed files with 1107 additions and 527 deletions

View file

@ -1,9 +1,10 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.BloodGroup;
using BMA.EHR.Application.Repositories.Prefix;
using Microsoft.Extensions.DependencyInjection;
namespace BMA.EHR.Application
{
public static class ApplicationServicesRegistration
public static class ApplicationServicesRegistration
{
public static IServiceCollection AddApplication(this IServiceCollection services)
{

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

View file

@ -1,14 +1,23 @@
using BMA.EHR.Domain.Entities.MetaData;
using BMA.EHR.Domain.Entities.MetaData.BloodGroup;
using BMA.EHR.Domain.Entities.MetaData.Prefix;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Application.Common.Interfaces
{
public interface IApplicationDBContext
{
DbSet<PrefixEntity> Prefixes { get; set; }
public interface IApplicationDBContext
{
DbSet<PrefixEntity> MD_Prefixes { get; set; }
DbSet<BloodGroupEntity> BloodGroups { get; set; }
DbSet<PrefixDraftEntity> MD_Prefix_Drafts { get; set; }
Task<int> SaveChangesAsync();
DbSet<PrefixPublishHistoryEntity> MD_Prefix_Histories { get; set; }
DbSet<BloodGroupEntity> MD_BloodGroups { get; set; }
DbSet<BloodGroupDraftEntity> MD_BloodGroup_Drafts { get; set; }
DbSet<BloodGroupPublishHistoryEntity> MD_BloodGroup_Histories { get; set; }
Task<int> SaveChangesAsync();
}
}

View file

@ -1,4 +1,6 @@
namespace BMA.EHR.Application.Common.Interfaces
using BMA.EHR.Domain.Common;
namespace BMA.EHR.Application.Common.Interfaces
{
public interface IGenericRepository<S,T> where T : class
{

View file

@ -0,0 +1,26 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Entities.MetaData.BloodGroup;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Application.Repositories.BloodGroup
{
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.MD_BloodGroups.ToListAsync();
}
public async Task<BloodGroupEntity?> GetByIdAsync(Guid id)
{
return await _dbContext.MD_BloodGroups.FirstOrDefaultAsync(x => x.Id == id);
}
}
}

View file

@ -1,26 +0,0 @@
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);
}
}
}

View file

@ -0,0 +1,26 @@
using BMA.EHR.Application.Common.Interfaces;
using BMA.EHR.Domain.Entities.MetaData.Prefix;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Application.Repositories.Prefix
{
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.MD_Prefixes.ToListAsync();
}
public async Task<PrefixEntity?> GetByIdAsync(Guid id)
{
return await _dbContext.MD_Prefixes.FirstOrDefaultAsync(x => x.Id == id);
}
}
}

View file

@ -1,26 +0,0 @@
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);
}
}
}