Result und DataResult Callbacks wurden zu Controllern hinzugefügt.
This commit is contained in:
@@ -117,8 +117,11 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
if (dirEntryUsername is null)
|
if (dirEntryUsername is null)
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var result = _dirSearchService.FindAllByUserCache(dirEntryUsername, filter, properties: propName);
|
return _dirSearchService.FindAllByUserCache(dirEntryUsername, filter, properties: propName).Then(Ok, IActionResult (m, n) =>
|
||||||
return Ok(result);
|
{
|
||||||
|
_logger.LogNotice(n);
|
||||||
|
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -142,9 +145,11 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
if (filter is null)
|
if (filter is null)
|
||||||
return NotFound($"The filter named {filterName} does not exist.");
|
return NotFound($"The filter named {filterName} does not exist.");
|
||||||
|
|
||||||
var result = _dirSearchService.FindAllByUserCache(dirEntryUsername, filter, properties: propName);
|
return _dirSearchService.FindAllByUserCache(dirEntryUsername, filter, properties: propName).Then(Ok, IActionResult (m, n) =>
|
||||||
|
{
|
||||||
return Ok(result);
|
_logger.LogNotice(n);
|
||||||
|
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -168,9 +173,11 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
if (filter is null)
|
if (filter is null)
|
||||||
throw new InvalidOperationException("The LDAP Group Search filter configuration is missing in your appsettings. Please ensure it's added under DirectorySearch:CustomSearchFilters:Group to enable group searches.");
|
throw new InvalidOperationException("The LDAP Group Search filter configuration is missing in your appsettings. Please ensure it's added under DirectorySearch:CustomSearchFilters:Group to enable group searches.");
|
||||||
|
|
||||||
var result = _dirSearchService.FindAllByUserCache(username: dirEntryUsername, filter, properties: propName);
|
return _dirSearchService.FindAllByUserCache(username: dirEntryUsername, filter, properties: propName).Then(Ok, IActionResult (m, n) =>
|
||||||
|
{
|
||||||
return Ok(result);
|
_logger.LogNotice(n);
|
||||||
|
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -195,15 +202,21 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
if (filter is null)
|
if (filter is null)
|
||||||
throw new InvalidOperationException("The LDAP User Search filter configuration is missing in your appsettings. Please ensure it's added under DirectorySearch:CustomSearchFilters:User to enable group searches.");
|
throw new InvalidOperationException("The LDAP User Search filter configuration is missing in your appsettings. Please ensure it's added under DirectorySearch:CustomSearchFilters:User to enable group searches.");
|
||||||
|
|
||||||
var result = _dirSearchService.FindAllByUserCache(username: dirEntryUsername, filter, properties: propName);
|
return _dirSearchService.FindAllByUserCache(username: dirEntryUsername, filter, properties: propName).Then(
|
||||||
|
Success: data =>
|
||||||
if (groupName is not null && result.IsSuccess && result.Data is not null)
|
{
|
||||||
result.Data = result.Data
|
if (groupName is not null)
|
||||||
.Where(rp => rp.PropertyNames.Cast<string>().Contains("memberof") &&
|
data = data
|
||||||
rp["memberof"].Cast<string>().Any(ldapDir => ldapDir.Contains(groupName)))
|
.Where(rp => rp.PropertyNames.Cast<string>().Contains("memberof") &&
|
||||||
.ToList();
|
rp["memberof"].Cast<string>().Any(ldapDir => ldapDir.Contains(groupName)))
|
||||||
|
.ToList();
|
||||||
return Ok(result);
|
return Ok(data);
|
||||||
|
},
|
||||||
|
Fail: IActionResult (m, n) =>
|
||||||
|
{
|
||||||
|
_logger.LogNotice(n);
|
||||||
|
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using DigitalData.Core.API;
|
using DigitalData.Core.API;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
using DigitalData.UserManager.Application.Contracts;
|
using DigitalData.UserManager.Application.Contracts;
|
||||||
using DigitalData.UserManager.Application.DTOs.Group;
|
using DigitalData.UserManager.Application.DTOs.Group;
|
||||||
using DigitalData.UserManager.Domain.Entities;
|
using DigitalData.UserManager.Domain.Entities;
|
||||||
@@ -19,15 +20,19 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await _service.CreateAsync(adGroup);
|
return await _service.CreateAsync(adGroup).ThenAsync(
|
||||||
if (result.IsSuccess)
|
Success: id =>
|
||||||
{
|
{
|
||||||
var createdResource = new { Id = result.Data };
|
var createdResource = new { Id = id };
|
||||||
var actionName = nameof(GetById);
|
var actionName = nameof(GetById);
|
||||||
var routeValues = new { id = createdResource.Id };
|
var routeValues = new { id = createdResource.Id };
|
||||||
return CreatedAtAction(actionName, routeValues, createdResource);
|
return CreatedAtAction(actionName, routeValues, createdResource);
|
||||||
}
|
},
|
||||||
return BadRequest(result);
|
Fail: IActionResult (m, n) =>
|
||||||
|
{
|
||||||
|
_logger.LogNotice(n);
|
||||||
|
return BadRequest();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using DigitalData.Core.API;
|
using DigitalData.Core.API;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
using DigitalData.UserManager.Application.Contracts;
|
using DigitalData.UserManager.Application.Contracts;
|
||||||
using DigitalData.UserManager.Application.DTOs.GroupOfUser;
|
using DigitalData.UserManager.Application.DTOs.GroupOfUser;
|
||||||
using DigitalData.UserManager.Domain.Entities;
|
using DigitalData.UserManager.Domain.Entities;
|
||||||
@@ -19,13 +20,11 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await _service.DeleteAsyncByGroupUserId(groupId, userId);
|
return await _service.DeleteAsyncByGroupUserId(groupId, userId).ThenAsync(Ok, IActionResult (m, n) =>
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
{
|
||||||
return Ok(result);
|
_logger.LogNotice(n);
|
||||||
}
|
return BadRequest();
|
||||||
|
});
|
||||||
return BadRequest(result);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -42,13 +41,11 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await _service.ReadAllAsyncWith(withUser, withGroup);
|
return await _service.ReadAllAsyncWith(withUser, withGroup).ThenAsync(Ok, IActionResult (m, n) =>
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
{
|
||||||
return Ok(result);
|
_logger.LogNotice(n);
|
||||||
}
|
return NotFound();
|
||||||
|
});
|
||||||
return NotFound(result);
|
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using DigitalData.Core.API;
|
using DigitalData.Core.API;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
using DigitalData.UserManager.Application.Contracts;
|
using DigitalData.UserManager.Application.Contracts;
|
||||||
using DigitalData.UserManager.Application.DTOs.ModuleOfUser;
|
using DigitalData.UserManager.Application.DTOs.ModuleOfUser;
|
||||||
using DigitalData.UserManager.Domain.Entities;
|
using DigitalData.UserManager.Domain.Entities;
|
||||||
@@ -19,13 +20,11 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await _service.DeleteAsyncByModuleUserId(moduleId, userId);
|
return await _service.DeleteAsyncByModuleUserId(moduleId, userId).ThenAsync(Ok, IActionResult (m, n) =>
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
{
|
||||||
return Ok(result);
|
_logger.LogNotice(n);
|
||||||
}
|
return BadRequest();
|
||||||
|
});
|
||||||
return BadRequest(result);
|
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using DigitalData.Core.API;
|
using DigitalData.Core.API;
|
||||||
|
using DigitalData.Core.DTO;
|
||||||
using DigitalData.UserManager.Application.Contracts;
|
using DigitalData.UserManager.Application.Contracts;
|
||||||
using DigitalData.UserManager.Application.DTOs.User;
|
using DigitalData.UserManager.Application.DTOs.User;
|
||||||
using DigitalData.UserManager.Domain.Entities;
|
using DigitalData.UserManager.Domain.Entities;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace DigitalData.UserManager.API.Controllers
|
namespace DigitalData.UserManager.API.Controllers
|
||||||
{
|
{
|
||||||
@@ -19,8 +21,12 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = assigned ? await _service.ReadByModuleIdAsync(moduleId) : await _service.ReadUnassignedByModuleIdAsync(moduleId);
|
return await (assigned ? _service.ReadByModuleIdAsync(moduleId) : _service.ReadUnassignedByModuleIdAsync(moduleId))
|
||||||
return Ok(result);
|
.ThenAsync(Ok, IActionResult(m, n) =>
|
||||||
|
{
|
||||||
|
_logger.LogNotice(n);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
@@ -34,8 +40,12 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = assigned ? await _service.ReadByGroupIdAsync(groupId) : await _service.ReadUnassignedByGroupIdAsync(groupId); ;
|
return await (assigned ? _service.ReadByGroupIdAsync(groupId) : _service.ReadUnassignedByGroupIdAsync(groupId))
|
||||||
return Ok(result);
|
.ThenAsync(Ok, IActionResult (m, n) =>
|
||||||
|
{
|
||||||
|
_logger.LogNotice(n);
|
||||||
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
@@ -49,15 +59,19 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await _service.CreateAsync(upDto);
|
return await _service.CreateAsync(upDto).ThenAsync(
|
||||||
if (result.IsSuccess)
|
Success: id =>
|
||||||
{
|
{
|
||||||
var createdResource = new { Id = result.Data };
|
var createdResource = new { Id = id };
|
||||||
var actionName = nameof(GetById);
|
var actionName = nameof(GetById);
|
||||||
var routeValues = new { id = createdResource.Id };
|
var routeValues = new { id = createdResource.Id };
|
||||||
return CreatedAtAction(actionName, routeValues, createdResource);
|
return CreatedAtAction(actionName, routeValues, createdResource);
|
||||||
}
|
},
|
||||||
return BadRequest(result);
|
Fail: IActionResult (m, n) =>
|
||||||
|
{
|
||||||
|
_logger.LogNotice(n);
|
||||||
|
return BadRequest();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
@@ -71,12 +85,11 @@ namespace DigitalData.UserManager.API.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var result = await _service.ReadByUsernameAsync(username);
|
return await _service.ReadByUsernameAsync(username).ThenAsync(Ok, IActionResult (m, n) =>
|
||||||
if (result.IsSuccess)
|
|
||||||
{
|
{
|
||||||
return Ok(result);
|
_logger.LogNotice(n);
|
||||||
}
|
return NotFound();
|
||||||
return NotFound(result);
|
});
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user