Updating 105

This commit is contained in:
Karol Górzyński 2020-12-20 16:34:37 +01:00
commit 6350ad7239

View File

@ -61,16 +61,16 @@ namespace SessionCompanion.Controllers
public async Task<Either<SuccessResponse, ErrorResponse>> Register(UserRegisterViewModel userRegisterModel)
{
if (!ModelState.IsValid)
{
return new ErrorResponse() { StatusCode = 400, Message = "Given model is incorect" };
}
if (await _service.SearchUserByUsername(userRegisterModel.Username) is not null)
return new ErrorResponse() { StatusCode = 400, Message = "Given user is already registered" };
UserViewModel userModel = new UserViewModel()
{
Password = userRegisterModel.Password,
Username = userRegisterModel.Username
};
await _service.Create(userModel);
await _service.SaveAsync();