public async Task <IActionResult> ForgotPassword([FromBody] string Username) { DBResponse objResponse = new DBResponse(); try { if (!string.IsNullOrEmpty(Username)) { UserDetails acc = new UserDetails(); UserInfo obj = acc.GetUserInfo(new UserInfo { Username = Username }); string recoveryToken = acc.GenerateToken(Username); if (obj != null && obj.UserID > 0 && !string.IsNullOrEmpty(recoveryToken)) { EmailService objEmailService = new EmailService(); string url = ConfigurationSetting.WebAppUrl; objEmailService.ForgetPassword(TemplateCode.FORGETPASSWORD.ToString(), obj.Email, obj.FirstName, url, recoveryToken); objResponse.Message = "Thank You! Account recovery email sent to " + obj.Email; objResponse.Result = true; } else { objResponse.Message = "Email is not related to any existing account!"; } } else { objResponse.Message = AppMessage.UnknownError; } } catch (Exception ex) { objResponse.Message = ex.Message; CLogger.WriteLog(ProjectSource.WebApi, ELogLevel.ERROR, "ERROR ocurred in Account Controller while calling ForgotPassword Action, Ex.: " + ex.Message); } return(Ok(new { Response = objResponse })); }