Result und DataResult Callbacks wurden zu Controllern hinzugefügt.
This commit is contained in:
@@ -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)
|
||||
{
|
||||
var createdResource = new { Id = result.Data };
|
||||
var actionName = nameof(GetById);
|
||||
var routeValues = new { id = createdResource.Id };
|
||||
return CreatedAtAction(actionName, routeValues, createdResource);
|
||||
}
|
||||
return BadRequest(result);
|
||||
return await _service.CreateAsync(upDto).ThenAsync(
|
||||
Success: id =>
|
||||
{
|
||||
var createdResource = new { Id = id };
|
||||
var actionName = nameof(GetById);
|
||||
var routeValues = new { id = createdResource.Id };
|
||||
return CreatedAtAction(actionName, routeValues, createdResource);
|
||||
},
|
||||
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