diff --git a/SessionCompanion/SessionCompanion/Controllers/UserController.cs b/SessionCompanion/SessionCompanion/Controllers/UserController.cs index da697bf..c577be9 100644 --- a/SessionCompanion/SessionCompanion/Controllers/UserController.cs +++ b/SessionCompanion/SessionCompanion/Controllers/UserController.cs @@ -2,6 +2,8 @@ using SessionCompanion.Services.Interfaces; using SessionCompanion.ViewModels.UserViewModels; using System.Threading.Tasks; +using SessionCompanion.Extensions.EitherType; +using SessionCompanion.ViewModels.ApiResponses; namespace SessionCompanion.Controllers { @@ -24,15 +26,27 @@ namespace SessionCompanion.Controllers return BadRequest(); } + + /// + /// Metoda rejestruje podanego użytkownika + /// + /// Model uzytkownika do zarejestrowania + /// SuccessResponse/ErrorResponse [HttpPost("register")] - public async Task Register(UserViewModel model) + public async Task> Register(UserViewModel model) { if(!ModelState.IsValid) - return BadRequest(); + return new ErrorResponse() + { + StatusCode = 400, + Message = "Given model is incorect" + }; + await _service.Create(model); await _service.SaveAsync(); - return Ok(); + + return new SuccessResponse("User created"); } }