41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
// Auto-generiert von CreateWebshopFiles.ps1
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Webshop.Application.DTOs.Users;
|
|
using Webshop.Application.Services.Admin;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Webshop.Api.Controllers.Admin
|
|
{
|
|
[ApiController]
|
|
[Route("api/v1/admin/[controller]")]
|
|
[Authorize(Roles = "Admin")]
|
|
public class AdminUsersController : ControllerBase
|
|
{
|
|
private readonly AdminUserService _adminUserService;
|
|
|
|
public AdminUsersController(AdminUserService adminUserService)
|
|
{
|
|
_adminUserService = adminUserService;
|
|
}
|
|
|
|
[HttpGet]
|
|
public async Task<ActionResult<IEnumerable<UserDto>>> GetAllUsers()
|
|
{
|
|
var users = await _adminUserService.GetAllUsersAsync();
|
|
return Ok(users);
|
|
}
|
|
|
|
[HttpGet("{userId}")]
|
|
public async Task<ActionResult<UserDto>> GetUserById(string userId)
|
|
{
|
|
var user = await _adminUserService.GetUserByIdAsync(userId);
|
|
if (user == null) return NotFound();
|
|
return Ok(user);
|
|
}
|
|
}
|
|
}
|