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)
|
||||
return Unauthorized();
|
||||
|
||||
var result = _dirSearchService.FindAllByUserCache(dirEntryUsername, filter, properties: propName);
|
||||
return Ok(result);
|
||||
return _dirSearchService.FindAllByUserCache(dirEntryUsername, filter, properties: propName).Then(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -142,9 +145,11 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
if (filter is null)
|
||||
return NotFound($"The filter named {filterName} does not exist.");
|
||||
|
||||
var result = _dirSearchService.FindAllByUserCache(dirEntryUsername, filter, properties: propName);
|
||||
|
||||
return Ok(result);
|
||||
return _dirSearchService.FindAllByUserCache(dirEntryUsername, filter, properties: propName).Then(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -168,9 +173,11 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
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.");
|
||||
|
||||
var result = _dirSearchService.FindAllByUserCache(username: dirEntryUsername, filter, properties: propName);
|
||||
|
||||
return Ok(result);
|
||||
return _dirSearchService.FindAllByUserCache(username: dirEntryUsername, filter, properties: propName).Then(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return StatusCode(StatusCodes.Status424FailedDependency);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -195,15 +202,21 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
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.");
|
||||
|
||||
var result = _dirSearchService.FindAllByUserCache(username: dirEntryUsername, filter, properties: propName);
|
||||
|
||||
if (groupName is not null && result.IsSuccess && result.Data is not null)
|
||||
result.Data = result.Data
|
||||
return _dirSearchService.FindAllByUserCache(username: dirEntryUsername, filter, properties: propName).Then(
|
||||
Success: data =>
|
||||
{
|
||||
if (groupName is not null)
|
||||
data = data
|
||||
.Where(rp => rp.PropertyNames.Cast<string>().Contains("memberof") &&
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using DigitalData.Core.API;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.Group;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
@@ -19,15 +20,19 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _service.CreateAsync(adGroup);
|
||||
if (result.IsSuccess)
|
||||
return await _service.CreateAsync(adGroup).ThenAsync(
|
||||
Success: id =>
|
||||
{
|
||||
var createdResource = new { Id = result.Data };
|
||||
var createdResource = new { Id = id };
|
||||
var actionName = nameof(GetById);
|
||||
var routeValues = new { id = createdResource.Id };
|
||||
return CreatedAtAction(actionName, routeValues, createdResource);
|
||||
}
|
||||
return BadRequest(result);
|
||||
},
|
||||
Fail: IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return BadRequest();
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using DigitalData.Core.API;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.GroupOfUser;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
@@ -19,13 +20,11 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _service.DeleteAsyncByGroupUserId(groupId, userId);
|
||||
if (result.IsSuccess)
|
||||
return await _service.DeleteAsyncByGroupUserId(groupId, userId).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
return BadRequest(result);
|
||||
_logger.LogNotice(n);
|
||||
return BadRequest();
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -42,13 +41,11 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _service.ReadAllAsyncWith(withUser, withGroup);
|
||||
if (result.IsSuccess)
|
||||
return await _service.ReadAllAsyncWith(withUser, withGroup).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
return NotFound(result);
|
||||
_logger.LogNotice(n);
|
||||
return NotFound();
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using DigitalData.Core.API;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.ModuleOfUser;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
@@ -19,13 +20,11 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _service.DeleteAsyncByModuleUserId(moduleId, userId);
|
||||
if (result.IsSuccess)
|
||||
return await _service.DeleteAsyncByModuleUserId(moduleId, userId).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
return BadRequest(result);
|
||||
_logger.LogNotice(n);
|
||||
return BadRequest();
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using DigitalData.Core.API;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.User;
|
||||
using DigitalData.UserManager.Domain.Entities;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
@@ -19,8 +21,12 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = assigned ? await _service.ReadByModuleIdAsync(moduleId) : await _service.ReadUnassignedByModuleIdAsync(moduleId);
|
||||
return Ok(result);
|
||||
return await (assigned ? _service.ReadByModuleIdAsync(moduleId) : _service.ReadUnassignedByModuleIdAsync(moduleId))
|
||||
.ThenAsync(Ok, IActionResult(m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -34,8 +40,12 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = assigned ? await _service.ReadByGroupIdAsync(groupId) : await _service.ReadUnassignedByGroupIdAsync(groupId); ;
|
||||
return Ok(result);
|
||||
return await (assigned ? _service.ReadByGroupIdAsync(groupId) : _service.ReadUnassignedByGroupIdAsync(groupId))
|
||||
.ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -49,15 +59,19 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _service.CreateAsync(upDto);
|
||||
if (result.IsSuccess)
|
||||
return await _service.CreateAsync(upDto).ThenAsync(
|
||||
Success: id =>
|
||||
{
|
||||
var createdResource = new { Id = result.Data };
|
||||
var createdResource = new { Id = id };
|
||||
var actionName = nameof(GetById);
|
||||
var routeValues = new { id = createdResource.Id };
|
||||
return CreatedAtAction(actionName, routeValues, createdResource);
|
||||
}
|
||||
return BadRequest(result);
|
||||
},
|
||||
Fail: IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return BadRequest();
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
@@ -71,12 +85,11 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _service.ReadByUsernameAsync(username);
|
||||
if (result.IsSuccess)
|
||||
return await _service.ReadByUsernameAsync(username).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
return Ok(result);
|
||||
}
|
||||
return NotFound(result);
|
||||
_logger.LogNotice(n);
|
||||
return NotFound();
|
||||
});
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user