public async Task <ActionResult> Register([FromBody] SignInRegisterRequestDto newRunner) { var runnerCreated = await runnerService.CreateAsync(newRunner.NewRunner()); if (!runnerCreated) { return(BadRequest($"Runner could't be created. Please try again!")); } return(Ok($"Successful registration: new runner - {newRunner.Email}")); }
public async Task <ActionResult> SingIn([FromBody] SignInRegisterRequestDto signinRequest) { var response = await runnerService.SingInAsync(signinRequest); if (!response.Message.Equals("Successfully signed in!")) { return(BadRequest(response)); } return(Ok(response)); }
public async Task <ResponseMessageDto> SingInAsync(SignInRegisterRequestDto signinRequest) { var runner = await GetRunnerByEmail(signinRequest.Email); if (runner is null) { return(new ResponseMessageDto { Message = "Runner not found! Please try again." }); } if (signinRequest.Password != runner.Password) { return(new ResponseMessageDto { Message = "Password is not correct! Please try again." }); } return(new ResponseMessageDto { Message = "Successfully signed in!" }); }
public static Runner NewRunner(this SignInRegisterRequestDto registerDto) { return(new(registerDto.Email, registerDto.Password)); }