Пример #1
0
        public ResponseModel SendMailforchangepassword(int userID, int IsStoreUser = 1)
        {
            CustomChangePassword customChangePassword = new CustomChangePassword();
            ResponseModel        objResponseModel     = new ResponseModel();
            int    statusCode    = 0;
            string statusMessage = "";

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromTokenCache(Cache, SecurityService.DecryptStringAES(token));

                UserCaller userCaller = new UserCaller();

                customChangePassword = userCaller.SendMailforchangepassword(new UserServices(Cache, Db), userID, authenticate.TenantId, IsStoreUser);
                if (customChangePassword.UserID > 0 && customChangePassword.Password != null && customChangePassword.EmailID != null)
                {
                    MasterCaller   masterCaller     = new MasterCaller();
                    SMTPDetails    sMTPDetails      = masterCaller.GetSMTPDetails(new MasterServices(Cache, Db), authenticate.TenantId);
                    securityCaller securityCaller   = new securityCaller();
                    CommonService  commonService    = new CommonService();
                    string         encryptedEmailId = SecurityService.Encrypt(customChangePassword.EmailID);

                    string decriptedPassword = SecurityService.DecryptStringAES(customChangePassword.Password);
                    string url      = Configuration.GetValue <string>("websiteURL") + "/ChangePassword";
                    string body     = "Dear User, <br/>Please find the below details.  <br/><br/>" + "Your Email ID  : " + customChangePassword.EmailID + "<br/>" + "Your Password : "******"<br/><br/>" + "Click on Below link to change the Password <br/>" + url + "?Id:" + encryptedEmailId;
                    bool   isUpdate = securityCaller.sendMailForChangePassword(new SecurityService(Cache, Db), sMTPDetails, customChangePassword.EmailID, body, authenticate.TenantId);
                    if (isUpdate)
                    {
                        objResponseModel.Status       = true;
                        objResponseModel.StatusCode   = (int)EnumMaster.StatusCode.Success;
                        objResponseModel.Message      = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)(int) EnumMaster.StatusCode.Success);
                        objResponseModel.ResponseData = "Mail sent successfully";
                    }
                    else
                    {
                        objResponseModel.Status       = false;
                        objResponseModel.StatusCode   = (int)EnumMaster.StatusCode.InternalServerError;
                        objResponseModel.Message      = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)(int) EnumMaster.StatusCode.InternalServerError);
                        objResponseModel.ResponseData = "Mail sent failure";
                    }
                }

                else
                {
                    objResponseModel.Status       = false;
                    objResponseModel.StatusCode   = (int)EnumMaster.StatusCode.RecordNotFound;
                    objResponseModel.Message      = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)(int) EnumMaster.StatusCode.RecordNotFound);
                    objResponseModel.ResponseData = "Sorry User does not exist or active";
                }

                /* StatusCode =
                 * isUpdate !=true ?
                 *     (int)EnumMaster.StatusCode.RecordNotFound : (int)EnumMaster.StatusCode.Success;
                 * statusMessage = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)StatusCode);
                 *
                 * objResponseModel.Status = true;
                 * objResponseModel.StatusCode = StatusCode;
                 * objResponseModel.Message = statusMessage;
                 * objResponseModel.ResponseData = "Email Sent";*/
            }
            catch (Exception)
            {
                throw;
            }

            return(objResponseModel);
        }
Пример #2
0
        public ResponseModel SendMailforchangepassword(int userID, int IsStoreUser = 1)
        {
            CustomChangePassword customChangePassword = new CustomChangePassword();
            ResponseModel        objResponseModel     = new ResponseModel();

            try
            {
                string       token        = Convert.ToString(Request.Headers["X-Authorized-Token"]);
                Authenticate authenticate = new Authenticate();
                authenticate = SecurityService.GetAuthenticateDataFromToken(_radisCacheServerAddress, SecurityService.DecryptStringAES(token));
                string            _data        = "";
                string            ProgramCode  = authenticate.ProgramCode;
                RedisCacheService cacheService = new RedisCacheService(_radisCacheServerAddress);
                if (cacheService.Exists("Con" + ProgramCode))
                {
                    _data = cacheService.Get("Con" + ProgramCode);
                    _data = JsonConvert.DeserializeObject <string>(_data);
                }
                string X_Authorized_Domainname = Convert.ToString(Request.Headers["X-Authorized-Domainname"]);
                if (X_Authorized_Domainname != null)
                {
                    X_Authorized_Domainname = SecurityService.DecryptStringAES(X_Authorized_Domainname);
                }
                UserCaller userCaller = new UserCaller();

                customChangePassword = userCaller.SendMailforchangepassword(new UserServices(_data), userID, authenticate.TenantId, IsStoreUser);
                if (customChangePassword.UserID > 0 && customChangePassword.Password != null && customChangePassword.EmailID != null)
                {
                    MasterCaller   masterCaller     = new MasterCaller();
                    SMTPDetails    sMTPDetails      = masterCaller.GetSMTPDetails(new MasterServices(_data), authenticate.TenantId);
                    securityCaller _securityCaller  = new securityCaller();
                    CommonService  commonService    = new CommonService();
                    string         encryptedEmailId = SecurityService.Encrypt(customChangePassword.EmailID);

                    string decriptedPassword = SecurityService.DecryptStringAES(customChangePassword.Password);
                    string url      = configuration.GetValue <string>("websiteURL") + "/ChangePassword";
                    string body     = "Dear User, <br/>Please find the below details.  <br/><br/>" + "Your Email ID  : " + customChangePassword.EmailID + "<br/>" + "Your Password : "******"<br/><br/>" + "Click on Below link to change the Password <br/>" + url + "?Id:" + encryptedEmailId;
                    bool   isUpdate = _securityCaller.sendMailForChangePassword(new SecurityService(_connectioSting), sMTPDetails, customChangePassword.EmailID, body, authenticate.TenantId);
                    if (isUpdate)
                    {
                        objResponseModel.Status       = true;
                        objResponseModel.StatusCode   = (int)EnumMaster.StatusCode.Success;
                        objResponseModel.Message      = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)(int) EnumMaster.StatusCode.Success);
                        objResponseModel.ResponseData = "Mail sent successfully";
                    }
                    else
                    {
                        objResponseModel.Status       = false;
                        objResponseModel.StatusCode   = (int)EnumMaster.StatusCode.InternalServerError;
                        objResponseModel.Message      = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)(int) EnumMaster.StatusCode.InternalServerError);
                        objResponseModel.ResponseData = "Mail sent failure";
                    }
                }

                else
                {
                    objResponseModel.Status       = false;
                    objResponseModel.StatusCode   = (int)EnumMaster.StatusCode.RecordNotFound;
                    objResponseModel.Message      = CommonFunction.GetEnumDescription((EnumMaster.StatusCode)(int) EnumMaster.StatusCode.RecordNotFound);
                    objResponseModel.ResponseData = "Sorry User does not exist or active";
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(objResponseModel);
        }