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