This commit is contained in:
parent
d88394984b
commit
39acbb7f95
11 changed files with 780 additions and 13 deletions
92
BMA.EHR.MetaData.Service/Services/BloodGroupService.cs
Normal file
92
BMA.EHR.MetaData.Service/Services/BloodGroupService.cs
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace BMA.EHR.MetaData.Service.Services
|
||||
{
|
||||
public class BloodGroupService
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly ILogger<BloodGroupService> _logger;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public BloodGroupService(ApplicationDBContext context,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ILogger<BloodGroupService> logger)
|
||||
{
|
||||
_context = context;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
#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<BloodGroup>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
if (showAll)
|
||||
return await _context.BloodGroups.AsQueryable()
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
else
|
||||
return await _context.BloodGroups.AsQueryable()
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<BloodGroup?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _context.BloodGroups.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Guid id, BloodGroup updated)
|
||||
{
|
||||
var existData = await _context.BloodGroups.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(BloodGroup 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.BloodGroups.AddAsync(inserted);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
90
BMA.EHR.MetaData.Service/Services/EducationLevelService.cs
Normal file
90
BMA.EHR.MetaData.Service/Services/EducationLevelService.cs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
||||
namespace BMA.EHR.MetaData.Service.Services
|
||||
{
|
||||
public class EducationLevelService
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public EducationLevelService(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<EducationLevel>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
if (showAll)
|
||||
return await _context.EducationLevels.AsQueryable()
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
else
|
||||
return await _context.EducationLevels.AsQueryable()
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<EducationLevel?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _context.EducationLevels.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Guid id, EducationLevel updated)
|
||||
{
|
||||
var existData = await _context.EducationLevels.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(EducationLevel 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.EducationLevels.AddAsync(inserted);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
90
BMA.EHR.MetaData.Service/Services/GenderService.cs
Normal file
90
BMA.EHR.MetaData.Service/Services/GenderService.cs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
||||
namespace BMA.EHR.MetaData.Service.Services
|
||||
{
|
||||
public class GenderService
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public GenderService(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<Gender>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
if (showAll)
|
||||
return await _context.Genders.AsQueryable()
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
else
|
||||
return await _context.Genders.AsQueryable()
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Gender?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _context.Genders.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Guid id, Gender updated)
|
||||
{
|
||||
var existData = await _context.Genders.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(Gender 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.Genders.AddAsync(inserted);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
90
BMA.EHR.MetaData.Service/Services/PrefixService.cs
Normal file
90
BMA.EHR.MetaData.Service/Services/PrefixService.cs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
||||
namespace BMA.EHR.MetaData.Service.Services
|
||||
{
|
||||
public class PrefixService
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public PrefixService(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<Prefix>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
if (showAll)
|
||||
return await _context.Prefixes.AsQueryable()
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
else
|
||||
return await _context.Prefixes.AsQueryable()
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Prefix?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _context.Prefixes.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Guid id, Prefix updated)
|
||||
{
|
||||
var existData = await _context.Prefixes.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.LastUpdateUserId = UserId ?? "";
|
||||
existData.LastUpdateFullName = FullName ?? "";
|
||||
existData.LastUpdatedAt = DateTime.Now;
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CreateAsync(Prefix 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.Prefixes.AddAsync(inserted);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
93
BMA.EHR.MetaData.Service/Services/ProvinceService.cs
Normal file
93
BMA.EHR.MetaData.Service/Services/ProvinceService.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
||||
namespace BMA.EHR.MetaData.Service.Services
|
||||
{
|
||||
public class ProvinceService
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public ProvinceService(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<Province>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
if (showAll)
|
||||
return await _context.Provinces.AsQueryable()
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
else
|
||||
return await _context.Provinces.AsQueryable()
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Province?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _context.Provinces
|
||||
.AsQueryable()
|
||||
.Include(x => x.Districts)
|
||||
.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Guid id, Province updated)
|
||||
{
|
||||
var existData = await _context.Provinces.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(Province 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.Provinces.AddAsync(inserted);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
89
BMA.EHR.MetaData.Service/Services/RelationshipService.cs
Normal file
89
BMA.EHR.MetaData.Service/Services/RelationshipService.cs
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
||||
namespace BMA.EHR.MetaData.Service.Services;
|
||||
|
||||
public class RelationshipService
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public RelationshipService(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<Relationship>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
if (showAll)
|
||||
return await _context.Relationships.AsQueryable()
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
else
|
||||
return await _context.Relationships.AsQueryable()
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Relationship?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _context.Relationships.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Guid id, Relationship updated)
|
||||
{
|
||||
var existData = await _context.Relationships.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.LastUpdateUserId = UserId ?? "";
|
||||
existData.LastUpdateFullName = FullName ?? "";
|
||||
existData.LastUpdatedAt = DateTime.Now;
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CreateAsync(Relationship 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.Relationships.AddAsync(inserted);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
90
BMA.EHR.MetaData.Service/Services/ReligionService.cs
Normal file
90
BMA.EHR.MetaData.Service/Services/ReligionService.cs
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Claims;
|
||||
|
||||
|
||||
namespace BMA.EHR.MetaData.Service.Services
|
||||
{
|
||||
public class ReligionService
|
||||
{
|
||||
#region " Fields "
|
||||
|
||||
private readonly ApplicationDBContext _context;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constructor and Destructor "
|
||||
|
||||
public ReligionService(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<Religion>> GetsAsync(bool showAll = true)
|
||||
{
|
||||
if (showAll)
|
||||
return await _context.Religions.AsQueryable()
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
else
|
||||
return await _context.Religions.AsQueryable()
|
||||
.Where(p => p.IsActive)
|
||||
.OrderBy(d => d.Name)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<Religion?> GetByIdAsync(Guid id)
|
||||
{
|
||||
return await _context.Religions.FirstOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Guid id, Religion updated)
|
||||
{
|
||||
var existData = await _context.Religions.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.LastUpdateUserId = UserId ?? "";
|
||||
existData.LastUpdateFullName = FullName ?? "";
|
||||
existData.LastUpdatedAt = DateTime.Now;
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CreateAsync(Religion 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.Religions.AddAsync(inserted);
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue