public IActionResult ForgotPassword([FromBody] JObject json)
        {
            try
            {
                JObject jObject = JsonConvert.DeserializeObject <JObject>(DBHelper.ParseString(json));
                if (jObject != null)
                {
                    string emailId = DBHelper.ParseString(jObject["emailId"]);
                    string IsAdmin = DBHelper.ParseString(jObject["IsAdmin"]);
                    if (!string.IsNullOrWhiteSpace(emailId))
                    {
                        if (iforgot.IsEmailExist(emailId, IsAdmin))
                        {
                            string resetCode = RandomHelpers.RandomString();
                            long   isUpdated = iforgot.UpdateForgotPasswordString(resetCode, emailId);
                            if (isUpdated > 0)
                            {
                                var HostingPath = env.ContentRootPath;

                                string clientEmail         = config.GetValue <string>("app_settings:ClientEmail");
                                string clientEmailPassword = config.GetValue <string>("app_settings:ClientEmailPassword");
                                string port     = config.GetValue <string>("app_settings:Port");
                                string mailHost = config.GetValue <string>("app_settings:SMTPURL");
                                string host     = this.Request.Host.Value;
                                string scheme   = this.Request.Scheme;
                                ForgotPasswordHelper.SendResetPasswordMail(emailId, resetCode, HostingPath, clientEmail, clientEmailPassword, port, mailHost, host, scheme);
                                return(Ok(ResponseHelper.Success(MessageConstants.ResetPassordLink)));
                            }
                            else
                            {
                                return(Ok(ResponseHelper.Error(MessageConstants.DataNotFound)));
                            }
                        }
                        else
                        {
                            return(Ok(ResponseHelper.Error(MessageConstants.CheckEmailId)));
                        }
                    }
                    else
                    {
                        return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
                    }
                }
                else
                {
                    return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
                }
            }
            catch (Exception ex)
            {
                LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
                return(Ok(ResponseHelper.Error(ex.Message)));
            }
        }
Beispiel #2
0
        public static PersonColorPreferenceModel GenerateRandomRecord([NotNull] Random randomProvider)
        {
            var dateTimeBirth = DateTime.Now.AddDays(0 - randomProvider.Next(0, 100 * 365));
            var dateOfBirth   = dateTimeBirth.ToPreferenceFormat( );

            string [] strings =
            {
                "Female",
                "Male"
            };

            var newRecord = new PersonColorPreferenceModel
            {
                FavoriteColor = RandomHelpers.RandomString(randomProvider, 3, 10, "color"),
                FirstName     = RandomHelpers.RandomString(randomProvider, 3, 10, "firstFirst"),
                LastName      = RandomHelpers.RandomString(randomProvider, 3, 10, "familyFamily'-"),
                DateOfBirth   = dateOfBirth,
                Gender        = strings [dateTimeBirth.Date.Day % 2].NotNull()
            };

            return(newRecord);
        }