Merge pull request #279 from LD-Reborn/feature/issue_91

Issue 91: Cleanup: Fix controller methods and method name
This commit is contained in:
LD50
2025-11-06 08:16:13 +01:00
committed by GitHub
9 changed files with 16 additions and 16 deletions

View File

@@ -19,7 +19,7 @@ public class GroupsController : Controller
}
[HttpGet("Get")]
public async Task<GroupsGetResponseModel> GetAsync(GroupsIndexRequestModel model)
public async Task<GroupsGetResponseModel> GetAsync(GroupsGetRequestModel model)
{
if (model is null)
{

View File

@@ -19,18 +19,18 @@ public class LocationsController : Controller
_logger = logger;
}
[HttpGet("Index")]
public async Task<LocationsIndexResponseModel> Index()
[HttpGet("GetAll")]
public async Task<LocationsGetAllResponseModel> GetAll()
{
try
{
IEnumerable<LocationModel> list = await _ldap.ListLocationsAsync();
return new LocationsIndexResponseModel { Locations = list };
return new LocationsGetAllResponseModel { Locations = list };
}
catch (Exception ex)
{
_logger.LogError("Unable to list locations: {Message} - {StackTrace}", ex.Message, ex.StackTrace);
return new LocationsIndexResponseModel { Locations = [] };
return new LocationsGetAllResponseModel { Locations = [] };
}
}
@@ -59,7 +59,7 @@ public class LocationsController : Controller
}
}
[HttpGet("Delete")]
[HttpDelete("Delete")]
public async Task<LocationsDeleteResponseModel> DeleteAsync(string cn)
{
if (cn is null)

View File

@@ -22,8 +22,8 @@ public class UsersController : Controller
_logger = logger;
}
[HttpGet("Index")]
public async Task<IEnumerable<UserModel>> Index(UsersIndexRequestModel requestModel)
[HttpGet("GetAll")]
public async Task<IEnumerable<UserModel>> GetAll(UsersGetAllRequestModel requestModel)
{
string? uid = requestModel.Uid;
List<string> attributes = ["cn", "sn", "title", "uid", "jpegPhoto", "userPassword", "description"];
@@ -46,7 +46,7 @@ public class UsersController : Controller
}
}
[HttpGet("Delete")]
[HttpDelete("Delete")]
public async Task<UsersDeleteRequestModel> Delete(string uid)
{
try

View File

@@ -2,7 +2,7 @@ using System.Text.Json.Serialization;
namespace Berufsschule_HAM.Models;
public class GroupsIndexRequestModel
public class GroupsGetRequestModel
{
public string? Cn { get; set; }
public bool GidNumber { get; set; } = true;

View File

@@ -7,7 +7,7 @@ public class LocationsDeleteResponseModel(bool successful, string exception = "N
public string? Exception { get; set; } = exception;
}
public class LocationsIndexResponseModel
public class LocationsGetAllResponseModel
{
public required IEnumerable<LocationModel> Locations { get; set; }
}

View File

@@ -2,7 +2,7 @@ using System.Text.Json.Serialization;
namespace Berufsschule_HAM.Models;
public class UsersIndexRequestModel
public class UsersGetAllRequestModel
{
public string? Uid { get; set; } = null;
public bool Cn { get; set; } = true;

View File

@@ -120,7 +120,7 @@
try {
const response = await fetch(url, {
method: 'GET',
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'

View File

@@ -126,7 +126,7 @@
try {
const response = await fetch(url, {
method: 'GET',
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'

View File

@@ -167,7 +167,7 @@ document.addEventListener('DOMContentLoaded', () => {
async function loadLocationsIntoSelect(selectElement, selectedValue = null) {
try {
const response = await fetch('/Locations/Index');
const response = await fetch('/Locations/GetAll');
const data = await response.json();
const locations = data.locations;
@@ -208,7 +208,7 @@ async function loadLocationsIntoSelect(selectElement, selectedValue = null) {
async function loadUsersIntoSelect(selectElement, selectedValue = null) {
try {
const response = await fetch('/Users/Index?Cn=false&Sn=false&Title=false&Description=false&JpegPhoto=false&UserPassword=false');
const response = await fetch('/Users/GetAll?Cn=false&Sn=false&Title=false&Description=false&JpegPhoto=false&UserPassword=false');
const users = await response.json();
const ts = selectElement.tomselect;