Exemplo n.º 1
0
        public string GenerateResetCode(string usernameOrEmail)
        {
            ResponseDataModel response = new ResponseDataModel();

            try
            {
                string message    = null;
                bool   resultFlag = false;
                _userOperations.GenerateResetCode(usernameOrEmail, out message, out resultFlag);
                response.ResultMessage = string.IsNullOrEmpty(message) ? UserMessages.ResetCodeGenerated : message;
                response.ResultFlag    = resultFlag;

                switch (message)
                {
                case UserMessages.MissingUser:
                    response.ResultCode = ResultCode.MissingUser.ToString();
                    break;

                case UserMessages.ResetCodeAlreadyGenerated:
                    response.ResultCode = ResultCode.ResetCodeAlreadyGenerated.ToString();
                    break;

                case UserMessages.UnexpectedError:
                    response.ResultCode = ResultCode.GenerateResetCodeFailed.ToString();
                    break;

                default:
                    if (string.IsNullOrEmpty(message))
                    {
                        response.ResultCode = ResultCode.ResetCodeGenerated.ToString();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                response.ResultMessage = UserMessages.GenerateResetCodeFailed;
                response.ResultFlag    = false;
                response.ResultCode    = ResultCode.GenerateResetCodeFailed.ToString();
                _logger.Log("GenerateResetCode_Exception: ", ex.Message);
            }
            return(JsonConvert.SerializeObject(response));
        }