no message

This commit is contained in:
kittapath 2024-12-24 05:14:31 +07:00
parent b64bf10419
commit 0b760a253f
15 changed files with 1147 additions and 91 deletions

View file

@ -0,0 +1,88 @@
using System.Security.Claims;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.MetaData.Service.Services
{
public class PositionExecutiveService
{
#region " Fields "
private readonly ApplicationDBContext _context;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destructor "
public PositionExecutiveService(ApplicationDBContext context,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_httpContextAccessor = httpContextAccessor;
}
#endregion
#region " Properties "
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
#region " Methods "
public async Task<IEnumerable<PositionExecutive>> GetsAsync(bool showAll = true)
{
if (showAll)
return await _context.PositionExecutives.AsQueryable()
.OrderBy(d => d.Name)
.ToListAsync();
else
return await _context.PositionExecutives.AsQueryable()
.Where(p => p.IsActive)
.OrderBy(d => d.Name)
.ToListAsync();
}
public async Task<PositionExecutive?> GetByIdAsync(Guid id)
{
return await _context.PositionExecutives.FirstOrDefaultAsync(x => x.Id == id);
}
public async Task UpdateAsync(Guid id, PositionExecutive updated)
{
var existData = await _context.PositionExecutives.FirstOrDefaultAsync(x => x.Id == id);
if (existData != null)
{
if (existData.Name != updated.Name || existData.IsActive != updated.IsActive)
{
existData.Name = updated.Name;
existData.IsActive = updated.IsActive;
existData.LastUpdatedAt = DateTime.Now;
existData.LastUpdateUserId = UserId ?? "";
existData.LastUpdateFullName = FullName ?? "";
}
await _context.SaveChangesAsync();
}
}
public async Task CreateAsync(PositionExecutive inserted)
{
inserted.CreatedUserId = UserId ?? "";
inserted.CreatedFullName = FullName ?? "System Administrator";
inserted.CreatedAt = DateTime.Now;
inserted.LastUpdatedAt = DateTime.Now;
inserted.LastUpdateFullName = FullName ?? "System Administrator";
inserted.LastUpdateUserId = UserId ?? "";
await _context.PositionExecutives.AddAsync(inserted);
await _context.SaveChangesAsync();
}
#endregion
}
}

View file

@ -0,0 +1,89 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.MetaData.Service.Services
{
public class PositionExecutiveSideService
{
#region " Fields "
private readonly ApplicationDBContext _context;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destructor "
public PositionExecutiveSideService(ApplicationDBContext context,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_httpContextAccessor = httpContextAccessor;
}
#endregion
#region " Properties "
public string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
public string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
#region " Methods "
public async Task<IEnumerable<PositionExecutiveSide>> GetsAsync(bool showAll = true)
{
if (showAll)
return await _context.PositionExecutiveSides.AsQueryable()
.OrderBy(d => d.Name)
.ToListAsync();
else
return await _context.PositionExecutiveSides.AsQueryable()
.Where(p => p.IsActive)
.OrderBy(d => d.Name)
.ToListAsync();
}
public async Task<PositionExecutiveSide?> GetByIdAsync(Guid id)
{
return await _context.PositionExecutiveSides.FirstOrDefaultAsync(x => x.Id == id);
}
public async Task UpdateAsync(Guid id, PositionExecutiveSide updated)
{
var existData = await _context.PositionExecutiveSides.FirstOrDefaultAsync(x => x.Id == id);
if (existData != null)
{
if (existData.Name != updated.Name || existData.Note != updated.Note || existData.IsActive != updated.IsActive)
{
existData.Name = updated.Name;
existData.IsActive = updated.IsActive;
existData.Note = updated.Note;
existData.LastUpdatedAt = DateTime.Now;
existData.LastUpdateUserId = UserId ?? "";
existData.LastUpdateFullName = FullName ?? "";
}
await _context.SaveChangesAsync();
}
}
public async Task CreateAsync(PositionExecutiveSide inserted)
{
inserted.CreatedUserId = UserId ?? "";
inserted.CreatedFullName = FullName ?? "System Administrator";
inserted.CreatedAt = DateTime.Now;
inserted.LastUpdatedAt = DateTime.Now;
inserted.LastUpdateFullName = FullName ?? "System Administrator";
inserted.LastUpdateUserId = UserId ?? "";
await _context.PositionExecutiveSides.AddAsync(inserted);
await _context.SaveChangesAsync();
}
#endregion
}
}

View file

@ -0,0 +1,90 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.MetaData.Service.Services
{
public class PositionLevelService
{
#region " Fields "
private readonly ApplicationDBContext _context;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destructor "
public PositionLevelService(ApplicationDBContext context,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_httpContextAccessor = httpContextAccessor;
}
#endregion
#region " Properties "
public string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
public string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
#region " Methods "
public async Task<IEnumerable<PositionLevel>> GetsAsync(bool showAll = true)
{
if (showAll)
return await _context.PositionLevels.AsQueryable()
.OrderBy(d => d.Level)
.ToListAsync();
else
return await _context.PositionLevels.AsQueryable()
.Where(p => p.IsActive)
.OrderBy(d => d.Level)
.ToListAsync();
}
public async Task<PositionLevel?> GetByIdAsync(Guid id)
{
return await _context.PositionLevels.FirstOrDefaultAsync(x => x.Id == id);
}
public async Task UpdateAsync(Guid id, PositionLevel updated)
{
var existData = await _context.PositionLevels.FirstOrDefaultAsync(x => x.Id == id);
if (existData != null)
{
if (existData.Name != updated.Name || existData.ShortName != updated.ShortName || existData.Level != updated.Level || existData.IsActive != updated.IsActive)
{
existData.Level = updated.Level;
existData.Name = updated.Name;
existData.ShortName = updated.ShortName;
existData.IsActive = updated.IsActive;
existData.LastUpdatedAt = DateTime.Now;
existData.LastUpdateUserId = UserId ?? "";
existData.LastUpdateFullName = FullName ?? "";
}
await _context.SaveChangesAsync();
}
}
public async Task CreateAsync(PositionLevel inserted)
{
inserted.CreatedUserId = UserId ?? "";
inserted.CreatedFullName = FullName ?? "System Administrator";
inserted.CreatedAt = DateTime.Now;
inserted.LastUpdatedAt = DateTime.Now;
inserted.LastUpdateFullName = FullName ?? "System Administrator";
inserted.LastUpdateUserId = UserId ?? "";
await _context.PositionLevels.AddAsync(inserted);
await _context.SaveChangesAsync();
}
#endregion
}
}

View file

@ -0,0 +1,89 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.MetaData.Service.Services
{
public class PositionLineService
{
#region " Fields "
private readonly ApplicationDBContext _context;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destructor "
public PositionLineService(ApplicationDBContext context,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_httpContextAccessor = httpContextAccessor;
}
#endregion
#region " Properties "
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
#region " Methods "
public async Task<IEnumerable<PositionLine>> GetsAsync(bool showAll = true)
{
if (showAll)
return await _context.PositionLines.AsQueryable()
.OrderBy(d => d.Name)
.ToListAsync();
else
return await _context.PositionLines.AsQueryable()
.Where(p => p.IsActive)
.OrderBy(d => d.Name)
.ToListAsync();
}
public async Task<PositionLine?> GetByIdAsync(Guid id)
{
return await _context.PositionLines.FirstOrDefaultAsync(x => x.Id == id);
}
public async Task UpdateAsync(Guid id, PositionLine updated)
{
var existData = await _context.PositionLines.FirstOrDefaultAsync(x => x.Id == id);
if (existData != null)
{
if (existData.Name != updated.Name || existData.IsActive != updated.IsActive)
{
existData.Name = updated.Name;
existData.IsActive = updated.IsActive;
existData.LastUpdatedAt = DateTime.Now;
existData.LastUpdateUserId = UserId ?? "";
existData.LastUpdateFullName = FullName ?? "";
}
await _context.SaveChangesAsync();
}
}
public async Task CreateAsync(PositionLine inserted)
{
inserted.CreatedUserId = UserId ?? "";
inserted.CreatedFullName = FullName ?? "System Administrator";
inserted.CreatedAt = DateTime.Now;
inserted.LastUpdatedAt = DateTime.Now;
inserted.LastUpdateFullName = FullName ?? "System Administrator";
inserted.LastUpdateUserId = UserId ?? "";
await _context.PositionLines.AddAsync(inserted);
await _context.SaveChangesAsync();
}
#endregion
}
}

View file

@ -0,0 +1,89 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.MetaData.Service.Services
{
public class PositionPathService
{
#region " Fields "
private readonly ApplicationDBContext _context;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destructor "
public PositionPathService(ApplicationDBContext context,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_httpContextAccessor = httpContextAccessor;
}
#endregion
#region " Properties "
public string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
public string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
#region " Methods "
public async Task<IEnumerable<PositionPath>> GetsAsync(bool showAll = true)
{
if (showAll)
return await _context.PositionPaths.AsQueryable()
.OrderBy(d => d.Name)
.ToListAsync();
else
return await _context.PositionPaths.AsQueryable()
.Where(p => p.IsActive)
.OrderBy(d => d.Name)
.ToListAsync();
}
public async Task<PositionPath?> GetByIdAsync(Guid id)
{
return await _context.PositionPaths.FirstOrDefaultAsync(x => x.Id == id);
}
public async Task UpdateAsync(Guid id, PositionPath updated)
{
var existData = await _context.PositionPaths.FirstOrDefaultAsync(x => x.Id == id);
if (existData != null)
{
if (existData.Name != updated.Name || existData.Note != updated.Note || existData.IsActive != updated.IsActive)
{
existData.Name = updated.Name;
existData.IsActive = updated.IsActive;
existData.Note = updated.Note;
existData.LastUpdatedAt = DateTime.Now;
existData.LastUpdateUserId = UserId ?? "";
existData.LastUpdateFullName = FullName ?? "";
}
await _context.SaveChangesAsync();
}
}
public async Task CreateAsync(PositionPath inserted)
{
inserted.CreatedUserId = UserId ?? "";
inserted.CreatedFullName = FullName ?? "System Administrator";
inserted.CreatedAt = DateTime.Now;
inserted.LastUpdatedAt = DateTime.Now;
inserted.LastUpdateFullName = FullName ?? "System Administrator";
inserted.LastUpdateUserId = UserId ?? "";
await _context.PositionPaths.AddAsync(inserted);
await _context.SaveChangesAsync();
}
#endregion
}
}

View file

@ -0,0 +1,89 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.MetaData.Service.Services
{
public class PositionPathSideService
{
#region " Fields "
private readonly ApplicationDBContext _context;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destructor "
public PositionPathSideService(ApplicationDBContext context,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_httpContextAccessor = httpContextAccessor;
}
#endregion
#region " Properties "
public string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
public string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
#region " Methods "
public async Task<IEnumerable<PositionPathSide>> GetsAsync(bool showAll = true)
{
if (showAll)
return await _context.PositionPathSides.AsQueryable()
.OrderBy(d => d.Name)
.ToListAsync();
else
return await _context.PositionPathSides.AsQueryable()
.Where(p => p.IsActive)
.OrderBy(d => d.Name)
.ToListAsync();
}
public async Task<PositionPathSide?> GetByIdAsync(Guid id)
{
return await _context.PositionPathSides.FirstOrDefaultAsync(x => x.Id == id);
}
public async Task UpdateAsync(Guid id, PositionPathSide updated)
{
var existData = await _context.PositionPathSides.FirstOrDefaultAsync(x => x.Id == id);
if (existData != null)
{
if (existData.Name != updated.Name || existData.Note != updated.Note || existData.IsActive != updated.IsActive)
{
existData.Name = updated.Name;
existData.IsActive = updated.IsActive;
existData.Note = updated.Note;
existData.LastUpdatedAt = DateTime.Now;
existData.LastUpdateUserId = UserId ?? "";
existData.LastUpdateFullName = FullName ?? "";
}
await _context.SaveChangesAsync();
}
}
public async Task CreateAsync(PositionPathSide inserted)
{
inserted.CreatedUserId = UserId ?? "";
inserted.CreatedFullName = FullName ?? "System Administrator";
inserted.CreatedAt = DateTime.Now;
inserted.LastUpdatedAt = DateTime.Now;
inserted.LastUpdateFullName = FullName ?? "System Administrator";
inserted.LastUpdateUserId = UserId ?? "";
await _context.PositionPathSides.AddAsync(inserted);
await _context.SaveChangesAsync();
}
#endregion
}
}

View file

@ -0,0 +1,88 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Domain.Models.MetaData;
namespace BMA.EHR.MetaData.Service.Services
{
public class PositionTypeService
{
#region " Fields "
private readonly ApplicationDBContext _context;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
#region " Constructor and Destructor "
public PositionTypeService(ApplicationDBContext context,
IHttpContextAccessor httpContextAccessor)
{
_context = context;
_httpContextAccessor = httpContextAccessor;
}
#endregion
#region " Properties "
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
#endregion
#region " Methods "
public async Task<IEnumerable<PositionType>> GetsAsync(bool showAll = true)
{
if (showAll)
return await _context.PositionTypes.AsQueryable()
.OrderBy(d => d.Name)
.ToListAsync();
else
return await _context.PositionTypes.AsQueryable()
.Where(p => p.IsActive)
.OrderBy(d => d.Name)
.ToListAsync();
}
public async Task<PositionType?> GetByIdAsync(Guid id)
{
return await _context.PositionTypes.FirstOrDefaultAsync(x => x.Id == id);
}
public async Task UpdateAsync(Guid id, PositionType updated)
{
var existData = await _context.PositionTypes.FirstOrDefaultAsync(x => x.Id == id);
if (existData != null)
{
if (existData.Name != updated.Name || existData.IsActive != updated.IsActive)
{
existData.Name = updated.Name;
existData.IsActive = updated.IsActive;
existData.LastUpdatedAt = DateTime.Now;
existData.LastUpdateUserId = UserId ?? "";
existData.LastUpdateFullName = FullName ?? "";
}
await _context.SaveChangesAsync();
}
}
public async Task CreateAsync(PositionType inserted)
{
inserted.CreatedUserId = UserId ?? "";
inserted.CreatedFullName = FullName ?? "System Administrator";
inserted.CreatedAt = DateTime.Now;
inserted.LastUpdatedAt = DateTime.Now;
inserted.LastUpdateFullName = FullName ?? "System Administrator";
inserted.LastUpdateUserId = UserId ?? "";
await _context.PositionTypes.AddAsync(inserted);
await _context.SaveChangesAsync();
}
#endregion
}
}