45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using DigitalData.Core.API;
|
|
using DigitalData.UserManager.Application.Contracts;
|
|
using DigitalData.UserManager.Application.DTOs.UserRep;
|
|
using DigitalData.UserManager.Domain.Entities;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Data.SqlClient;
|
|
|
|
namespace DigitalData.UserManager.API.Controllers
|
|
{
|
|
[Authorize]
|
|
public class UserRepController : CRUDControllerBaseWithErrorHandling<IUserRepService, UserRepCreateDto, UserRepReadDto, UserRepUpdateDto, UserRep, int>
|
|
{
|
|
public UserRepController(ILogger<UserRepController> logger, IUserRepService service) : base(logger, service)
|
|
{
|
|
}
|
|
|
|
[NonAction]
|
|
public override Task<IActionResult> GetAll()
|
|
{
|
|
return base.GetAll();
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<IActionResult> GetAll(bool withUser = false, bool withRepGroup = false, bool withRightGroup = false, bool withRepUser = false, int? userId = null)
|
|
{
|
|
try
|
|
{
|
|
var result = await _service.ReadAllAsync(withUser, withRepGroup, withRightGroup, withRepUser, userId);
|
|
|
|
if (result.IsSuccess)
|
|
{
|
|
return Ok(result);
|
|
}
|
|
|
|
return NotFound(result);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "{Message}", ex.Message);
|
|
return StatusCode(StatusCodes.Status500InternalServerError);
|
|
}
|
|
}
|
|
}
|
|
} |