public ActionResult SendForgetPasswordMail(ForgetPasswordModel objForgetPassword)
        {
            string             ActionName     = this.ControllerContext.RouteData.Values["action"].ToString();
            string             ControllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            Int32?             UserID         = HttpContext.Session.GetInt32("UserID");
            string             ErrorMessage   = string.Empty;
            var                RoleName       = "";
            FinocartMaster     objDatawithSP1 = null;
            Company            objDatawithSP2 = null;
            User               objDatawithSP3 = null;
            IEnumerable <User> objDatawithSP  = _CommonRepository.CheckUserPassword();
            IEnumerable <User> objDatawithSP4 = _CommonRepository.CheckUserPassword();

            try
            {
                var    Name = "";
                string ID   = "";

                string randomPassword = _CommonRepository.GeneratePassword();
                // string EncryptToken = SecurityHelperService.Encrypt(Token);
                string EmailID = objForgetPassword.EmailID.Trim();
                var    data    = Encoding.UTF8.GetBytes(objForgetPassword.RoleName);
                RoleName = Convert.ToBase64String(data);
                if (objForgetPassword.RoleName == "MasterAdmin")
                {
                    //IEnumerable<Company> objDatawithSP = _CommonRepository.CheckAdminPassword();
                    //objDatawithSP = objDatawithSP.Where(x => x.Contact_email == EmailID && x.IsDelete == false);
                    objDatawithSP2 = _CommonRepository.CheckAdminByEmailExists(EmailID);
                    if (objDatawithSP2 != null && (!objDatawithSP2.IsDelete || objDatawithSP2.LoginAttempt == 3))
                    {
                        Name = objDatawithSP2.Company_name;
                        ID   = Convert.ToString(objDatawithSP2.CompanyID);
                    }
                }
                if (objForgetPassword.RoleName == "InternalUser")
                {
                    //IEnumerable<User> objDatawithSP = _CommonRepository.CheckUserPassword();
                    //objDatawithSP = objDatawithSP.Where(x => x.Email == EmailID && x.IsDelete == true);
                    objDatawithSP3 = _CommonRepository.CheckUserByEmail(EmailID, true);
                    if (objDatawithSP3 != null)
                    {
                        Name = objDatawithSP3.Name;
                        ID   = Convert.ToString(objDatawithSP3.UserID);
                    }
                }
                if (objForgetPassword.RoleName == "Vendor")
                {
                    objDatawithSP = objDatawithSP.Where(x => x.Email == EmailID);
                    if (objDatawithSP.Any())
                    {
                        Name = objDatawithSP.ElementAt(0).Name;
                        ID   = Convert.ToString(objDatawithSP.ElementAt(0).UserID);
                    }
                }

                if (objForgetPassword.RoleName == "Anchor Company")
                {
                    objDatawithSP4 = objDatawithSP.Where(x => x.Email == EmailID && x.IsDelete == false);
                    if (objDatawithSP4.Any())
                    {
                        Name = objDatawithSP4.ElementAt(0).Name;
                        ID   = Convert.ToString(objDatawithSP4.ElementAt(0).UserID);
                    }
                }
                if (objForgetPassword.RoleName == "SuperAdmin")
                {
                    objDatawithSP1 = _CommonRepository.CheckSuperAdminByEmail(EmailID, false);
                    if (objDatawithSP1 != null)
                    {
                        Name = objDatawithSP1.Name;
                        ID   = Convert.ToString(objDatawithSP1.ID);
                    }
                }

                if (Name != "")
                {
                    string Token = ID + "~" + objForgetPassword.RoleName + "~" + DateTime.Now;

                    string EncryptToken = SecurityHelperService.Encrypt(Token);
                    // var Result = _CommonRepository.UpdatePassword(Password, EmailID, objForgetPassword.RoleName);
                    // if (Result > 0)
                    //{

                    IEnumerable <GetForgetPasswordMailTemplate> lstAwaitedInvVendorsView = _lookUpRepository.getForgetPasswordMailTemplate();
                    string path = lstAwaitedInvVendorsView.ElementAt(0).Template;
                    string EMAIL_TOKEN_PAYMENT_LINK = "##$$LOGIN_LINK$$##";
                    //string paymentLink ="http://*****:*****@@User@@", Name);
                    body = body.Replace("@@ProjectName@@", "Finocart");
                    body = body.Replace(EMAIL_TOKEN_PAYMENT_LINK, paymentLink);
                    body = body.Replace("http://dotnet.brainvire.com/Finocart/Account/AdminLogin", paymentLink);
                    body = body.Replace("@@Password@@", randomPassword);
                    IEnumerable <LookupDetails> lookupDetails = _lookUpRepository.getLookupDetailByKey("SMTPInfo");
                    _CommonRepository.SendEmail(lookupDetails, emailToAddress, subject, body, true);
                    TempData["MailSuccess"] = "Mail sent successfully";
                    // }
                }
                else
                {
                    TempData["WrongMail"] = "Email ID is not valid";
                }
            }
            catch (Exception ex)
            {
                TempData["FailureMessage"] = "We are sorry, something went wrong. Please try again later";
                var st        = new StackTrace(ex, true);
                var frame     = st.GetFrame(0);
                int ErrorLine = frame.GetFileLineNumber();
                var Result    = _CommonRepository.LogManagement(ControllerName, ActionName, ex.Message, ErrorLine, UserID);
                return(RedirectToAction("ErrorPage", "Common"));
            }

            return(RedirectToAction("ForgetPassword", "Account", new { Role = RoleName }));
        }