public async Task <ActionResult> Index(CancellationToken cancellationToken)
        {
            ViewData[Constant.FormTitle] = "ADD Email Server";
            IEmailServerModel model = await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, GetCanellationToken(cancellationToken));

            return(View(model));
        }
        public async Task <ActionResult> IndexEdit(string hdnEmailServerId, CancellationToken cancellationToken)
        {
            if (System.Convert.ToInt64(hdnEmailServerId) > 0)
            {
                ViewData[Constant.FormTitle] = "EDIT Email Server";
                IEmailServerModel model = await _service.IndexAsync(this.HttpContext.ApplicationInstance.Context, hdnEmailServerId, GetCanellationToken(cancellationToken));

                ViewData[Constant.QuerySuccess] = HttpContext.Items[Constant.QuerySuccess];
                return(View("Index", model));
            }
            else
            {
                return(Redirect("~/EmailServerSearch/Index"));
            }
        }
Exemple #3
0
        public Int32 SendEmail(string userEmail, IEmailServerModel model)
        {
            TempUserDAL _dal         = new TempUserDAL();
            string      emailBody    = "";
            string      emailSubject = "";
            int         retVal       = 0;

            retVal = _dal.GetEmailTemplateChangePassword(model.UserId, model.UserName, ref emailBody, ref emailSubject);

            model.SysEmailServers = new List <EmailServerModel>();

            model.SysEmailServers = GetEmailServerList();

            if (model.SysEmailServers.Count > 0)
            {
                //Email email = new Email("HireThingsAdminPortal", model.SysEmailServers);
                //email.SetToAddress(userEmail);
                //email.SetSubject(emailSubject);
                //email.SetBody(Convert.ToString(emailBody));
                //email.IsBodyHTML = true;
                //if (email.SendEmail())
                //{
                //    // Email sending successful
                //    retVal = 1;
                //}
                //else
                //{
                //    retVal = 2;
                //}
            }
            else
            {
                retVal = 2;
            }


            return(retVal);
        }
Exemple #4
0
        public Int32 SendEmail(IEmailLogModel emailLog, string callBackUrl, IEmailServerModel model, Constant.EmailType emailType)
        {
            TempUserDAL    _dal          = new TempUserDAL();
            IEmailLogModel emailLogModel = null;
            string         emailBody     = "";
            string         emailSubject  = "";
            int            retVal        = 0;

            retVal = _dal.GetEmailTemplate(model.UserId, model.UserName, callBackUrl, ref emailBody, ref emailSubject, emailType);
            // Initialize emailLogModel
            //emailLogModel = new EmailLogModel() { UserId = model.UserId, To = user.EmailId, Subject = emailSubject, Body = emailBody, EmailType = (int)emailType };
            emailLogModel = new EmailLogModel()
            {
                UserId = emailLog.UserId, To = emailLog.To, Subject = emailSubject, Body = emailBody, EmailType = (int)emailType, SystemId = emailLog.SystemId
            };

            {
                model.SysEmailServers = new List <EmailServerModel>();
                model.SysEmailServers = GetEmailServerList();

                if (model.SysEmailServers.Count > 0)
                {
                    //MailMessage message = new MailMessage();
                    //message.From = new MailAddress("your email address");

                    //message.To.Add(new MailAddress("your recipient"));

                    //message.Subject = "your subject";
                    //message.Body = "content of your email";

                    //SmtpClient client = new SmtpClient();
                    //client.Send(message);



                    Email email = new Email("HireThingsAdminPortal", model.SysEmailServers);
                    email.SetToAddress(emailLog.To);
                    email.SetSubject(emailSubject);
                    email.SetBody(Convert.ToString(emailBody));
                    email.IsBodyHTML = true;
                    if (email.SendEmail())
                    {
                        // Email Log
                        emailLogModel.SentStatus = 1;
                        _dal.EmailLog(emailLogModel);
                        // Email sending successful
                        retVal = 1;
                    }
                    else
                    {
                        // Email Log
                        emailLogModel.SentStatus   = 0;
                        emailLogModel.UnSentReason = "Write Exception Log here";
                        _dal.EmailLog(emailLogModel);
                        retVal = 2;
                    }
                }
                else
                {
                    retVal = 2;
                }
            }

            return(retVal);
        }
        public bool sendChangePasswordEmail(HttpContext context, string userEmail, string callBackUrl, IEmailServerModel model)
        {
            model.UserName = context.User.Identity.GetUserName();
            IEmailLogModel emailLog = new EmailLogModel {
                To = userEmail
            };

            if (this.SendEmail(emailLog, callBackUrl, model, Constant.EmailType.ChangePassword) == 1)
            {
                context.Items[Constant.QuerySuccess] = true;
                return(true);
            }
            else
            {
                context.Items[Constant.QuerySuccess] = false;
                return(false);
            }
        }
Exemple #6
0
        public bool sendEmail(HttpContext context, string userEmail, string callBackUrl, IEmailServerModel model, Constant.EmailType emailType, long userId = 0, long systemId = 0)
        {
            if (model.UserName == null)
            {
                model.UserName = context.User.Identity.Name;
            }
            if (userEmail == null)
            {
                userEmail = Convert.ToString(context.Session[Constant.EmailId]);
            }

            //long userId = Convert.ToInt64(context.Session[Constant.UserId]);
            //long sysytemId = (long)context.Session[Constant.SystemId];
            //IEmailLogModel emailLog = generateEmailLogModel(context);

            IEmailLogModel emailLog = new EmailLogModel {
                UserId = userId, SystemId = systemId, To = userEmail
            };

            if (this.SendEmail(emailLog, callBackUrl, model, emailType) == 1)
            {
                return(true);
            }

            return(false);
        }