Exemple #1
0
        public IActionResult SendActivationCode([FromBody] UserDto userDto)
        {
            try
            {
                var activationCode = UsersService.CreateActivationKey();

                if (UsersService.IsUserActive(UsersService.FindUser(userDto.Email)))
                {
                    throw new Exception("The user is already active");
                }

                UsersService.AddActivationKeyToTable(activationCode, UsersService.FindUser(userDto.Email));

                UsersService.SendActivationCode(userDto.Email, activationCode);

                return(Ok());
            }
            catch (Exception ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }