SES-105 list of logged charcters #36
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user