UserController.cs change

This commit is contained in:
Kosma 2020-12-13 12:45:50 +01:00
parent 7b122e160e
commit 6f8cf6dcb4

View File

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Services.Interfaces; using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.UserViewModels;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SessionCompanion.Controllers namespace SessionCompanion.Controllers
@ -22,5 +23,17 @@ namespace SessionCompanion.Controllers
if (User.Password == password) { return Json(User.Id); } if (User.Password == password) { return Json(User.Id); }
return BadRequest(); return BadRequest();
} }
[HttpPost("register")]
public async Task<IActionResult> Register(UserViewModel model)
{
if(!ModelState.IsValid)
return BadRequest();
await _service.Create(model);
await _service.SaveAsync();
return Ok();
}
} }
} }