Updating 105
This commit is contained in:
commit
6350ad7239
@ -61,16 +61,16 @@ namespace SessionCompanion.Controllers
|
|||||||
public async Task<Either<SuccessResponse, ErrorResponse>> Register(UserRegisterViewModel userRegisterModel)
|
public async Task<Either<SuccessResponse, ErrorResponse>> Register(UserRegisterViewModel userRegisterModel)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
|
||||||
return new ErrorResponse() { StatusCode = 400, Message = "Given model is incorect" };
|
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()
|
UserViewModel userModel = new UserViewModel()
|
||||||
{
|
{
|
||||||
Password = userRegisterModel.Password,
|
Password = userRegisterModel.Password,
|
||||||
Username = userRegisterModel.Username
|
Username = userRegisterModel.Username
|
||||||
};
|
};
|
||||||
|
|
||||||
await _service.Create(userModel);
|
await _service.Create(userModel);
|
||||||
await _service.SaveAsync();
|
await _service.SaveAsync();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user