mirror of
https://github.com/LD-Reborn/Berufsschule_HAM.git
synced 2025-12-20 06:51:55 +00:00
Implemented /Home/Location table and delete action
This commit is contained in:
@@ -54,9 +54,21 @@ public class HomeController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("Locations")]
|
||||
public ActionResult Locations()
|
||||
public async Task<ActionResult> LocationsAsync()
|
||||
{
|
||||
return View();
|
||||
IEnumerable<LocationModel> locations = await _ldap.ListLocationsAsync();
|
||||
List<LocationTableViewModel> LocationsTableViewModels = [];
|
||||
foreach (LocationModel location in locations)
|
||||
{
|
||||
LocationsTableViewModels.Add(new()
|
||||
{
|
||||
LocationID = location.Location,
|
||||
LocationName = location.Description?.Location ?? "",
|
||||
RoomNumber = location.Description?.RoomNumber ?? "",
|
||||
Seat = location.Description?.Seat ?? ""
|
||||
});
|
||||
}
|
||||
return View(new LocationsIndexViewModel() { LocationTableViewModels = LocationsTableViewModels });
|
||||
}
|
||||
|
||||
[HttpGet("Users")]
|
||||
|
||||
@@ -40,7 +40,7 @@ public class LocationsController : Controller
|
||||
new LdapAttribute("l", location),
|
||||
new LdapAttribute("description", JsonSerializer.Serialize(room))
|
||||
];
|
||||
|
||||
|
||||
await _ldap.CreateLocation(attributeSet);
|
||||
return true;
|
||||
}
|
||||
@@ -52,22 +52,20 @@ public class LocationsController : Controller
|
||||
}
|
||||
|
||||
[HttpGet("Delete")]
|
||||
public async Task<bool> Delete(string cn)
|
||||
public async Task<LocationsDeleteRequestModel> DeleteAsync(string cn)
|
||||
{
|
||||
if (cn is null) { return false; }
|
||||
return await Task.Run(async () =>
|
||||
if (cn is null) { return new(false); }
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
await _ldap.DeleteLocationAsync(cn);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
await _ldap.DeleteLocationAsync(cn);
|
||||
return new(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new(false, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("Update")]
|
||||
public async Task<bool> Update(LocationsModifyRequestModel requestModel)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user