Torma Kristóf
10c1bb008f
All checks were successful
continuous-integration/drone/push Build is passing
47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using HanyadikHetVan.DTO;
|
|
using HanyadikHetVan.Services;
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net.Mime;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HanyadikHetVan.Controllers.V2
|
|
{
|
|
[ApiVersion("2.0")]
|
|
[Route("api/v{version:apiVersion}/[controller]")]
|
|
[ApiController]
|
|
public class UserController : Controller
|
|
{
|
|
private readonly UserService _userservice;
|
|
|
|
public UserController(UserService userservice)
|
|
{
|
|
_userservice = userservice ?? throw new ArgumentNullException(nameof(userservice));
|
|
}
|
|
|
|
[HttpPost]
|
|
[Authorize(Policy = "AdminPolicy", AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
[Consumes(MediaTypeNames.Application.Json)]
|
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(UserDTO))]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
|
public async Task<IActionResult> UpdateWeeklyTimeSpan([FromBody] UserDTO user)
|
|
{
|
|
try
|
|
{
|
|
var userobj = await _userservice.CreateUser(user);
|
|
return Ok(userobj);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return BadRequest();
|
|
}
|
|
}
|
|
}
|
|
}
|