diff --git a/SessionCompanion/SessionCompanion/Controllers/UserController.cs b/SessionCompanion/SessionCompanion/Controllers/UserController.cs
index 0c37ab4..5a17747 100644
--- a/SessionCompanion/SessionCompanion/Controllers/UserController.cs
+++ b/SessionCompanion/SessionCompanion/Controllers/UserController.cs
@@ -1,6 +1,9 @@
using Microsoft.AspNetCore.Mvc;
using SessionCompanion.Services.Interfaces;
+using SessionCompanion.ViewModels.UserViewModels;
using System.Threading.Tasks;
+using SessionCompanion.Extensions.EitherType;
+using SessionCompanion.ViewModels.ApiResponses;
namespace SessionCompanion.Controllers
{
@@ -41,5 +44,29 @@ namespace SessionCompanion.Controllers
Message = "User name not found or incorrect password"
};
}
+
+
+ ///
+ /// Metoda rejestruje podanego użytkownika
+ ///
+ /// Model uzytkownika do zarejestrowania
+ /// SuccessResponse/ErrorResponse
+ [HttpPost("register")]
+
+ public async Task> Register(UserViewModel model)
+ {
+ if(!ModelState.IsValid)
+ return new ErrorResponse()
+ {
+ StatusCode = 400,
+ Message = "Given model is incorect"
+ };
+
+ await _service.Create(model);
+ await _service.SaveAsync();
+
+ return new SuccessResponse("User created");
+ }
+
}
}
\ No newline at end of file