54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Serwer.Infrastructure.DTO;
|
|
using Serwer.Infrastructure.Services;
|
|
using Serwer.Infrastructure.ViewModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Serwer.Api.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class UserController : ControllerBase
|
|
{
|
|
private readonly IUserService _userService;
|
|
public UserController(IUserService userService)
|
|
{
|
|
_userService = userService;
|
|
}
|
|
|
|
[HttpPost("Register")]
|
|
public async Task<IActionResult> Register([FromForm]RegisterModel request)
|
|
{
|
|
await _userService.RegisterAsync(request.Email, request.Name, request.Surname, request.Login, request.Password);
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpPost("SignIn")]
|
|
public async Task<IActionResult> SignIn([FromForm]SignInModel request)
|
|
{
|
|
var user = await _userService.SignInAsync(request.Login, request.Password);
|
|
return Ok(user);
|
|
}
|
|
|
|
[Authorize]
|
|
[HttpPost("Update")]
|
|
public async Task<IActionResult> Update([FromForm]UpdateUserModel request)
|
|
{
|
|
var user = await _userService.UpdateAsync(request);
|
|
return Ok(user);
|
|
}
|
|
|
|
[HttpGet("Test")]
|
|
public IActionResult Test()
|
|
{
|
|
return NoContent();
|
|
}
|
|
}
|
|
}
|