* Managed API to handle User maintenance

* Managed Users view in application
This commit is contained in:
2025-02-20 06:39:06 +01:00
parent cd5990039d
commit 9b8d621f42
19 changed files with 530 additions and 195 deletions

View File

@@ -7,14 +7,14 @@ namespace OrdersManagementDataModel.Services;
public class FunctionService(OrdersManagementDbContext context, IMapper mapper) : IFunctionService
{
public async Task<IEnumerable<FunctionDto>> GetFunctions()
public async Task<IEnumerable<FunctionDto>> GetAll()
{
IList<FunctionDto> functions = await context.Functions.Select(x => mapper.Map<FunctionDto>(x)).ToListAsync();
return functions;
}
public async Task<FunctionDto?> GetFunctionById(Guid id)
public async Task<FunctionDto?> GetById(Guid id)
{
FunctionDto? function = await context.Functions.Where(x => x.RowPointer == id)
.Select(x => mapper.Map<FunctionDto>(x)).FirstOrDefaultAsync();
@@ -22,7 +22,7 @@ public class FunctionService(OrdersManagementDbContext context, IMapper mapper)
return function;
}
public async Task<FunctionDto?> GetFunctionByName(string name)
public async Task<FunctionDto?> GetByName(string name)
{
FunctionDto? function = await context.Functions.Where(x => x.Name == name)
.Select(x => mapper.Map<FunctionDto>(x)).FirstOrDefaultAsync();
@@ -30,7 +30,7 @@ public class FunctionService(OrdersManagementDbContext context, IMapper mapper)
return function;
}
public async Task<int> AddFunction(FunctionDto functionDto)
public async Task<int> Add(FunctionDto functionDto)
{
Function function = new Function
{
@@ -42,7 +42,7 @@ public class FunctionService(OrdersManagementDbContext context, IMapper mapper)
return await context.SaveChangesAsync();
}
public async Task<int> DeleteFunction(Guid id)
public async Task<int> Delete(Guid id)
{
Function? function = await context.Functions.Where(x => x.RowPointer == id).FirstOrDefaultAsync() ?? null;
@@ -52,7 +52,7 @@ public class FunctionService(OrdersManagementDbContext context, IMapper mapper)
return await context.SaveChangesAsync();
}
public async Task<int> UpdateFunction(FunctionDto functionDto)
public async Task<int> Update(FunctionDto functionDto)
{
Function function = mapper.Map<Function>(functionDto);
context.Functions.Update(function);