Esempio n. 1
0
        public ActionResult Support()
        {
            SkyberryUser user    = UOW.SkyberryUsers.GetById(User.Identity.GetUserId());
            Account      account = null;
            HttpCookie   cookie  = Request.Cookies.Get("accountId");

            if (cookie != null)
            {
                try
                {
                    account = UOW.Accounts.GetById(Guid.Parse(cookie.Value));
                }
                catch { }
            }
            if (account == null && user.Accounts != null && user.Accounts.Count > 0)
            {
                foreach (var item in user.Accounts)
                {
                    account = UOW.Accounts.GetById(item.Id);
                    break;
                }
            }
            MyAccountSupportVM vm = new MyAccountSupportVM
            {
                User    = user,
                Account = account
            };

            return(View(vm));
        }
Esempio n. 2
0
        public ActionResult Support_Post(MyAccountSupportVM myAccountSupportVM)
        {
            bool received = false;

            if (ModelState.IsValid)
            {
                string description = "Skyberry Client Support Submission";

                StringBuilder body = new StringBuilder();
                body.Append("<table cellpadding='3' border='0'>");
                body.AppendFormat("<tr><td style='background-color:#d7d7d7;white-space:nowrap;text-align:right;vertical-align:top;'><strong>{0}</strong></td><td style='background-color:#e6e6e5;text-align:left;vertical-align:top;'>{1}</td></tr>", "Name", myAccountSupportVM.Name);
                body.AppendFormat("<tr><td style='background-color:#d7d7d7;white-space:nowrap;text-align:right;vertical-align:top;'><strong>{0}</strong></td><td style='background-color:#e6e6e5;text-align:left;vertical-align:top;'>{1}</td></tr>", "Email", myAccountSupportVM.Email);
                body.AppendFormat("<tr><td style='background-color:#d7d7d7;white-space:nowrap;text-align:right;vertical-align:top;'><strong>{0}</strong></td><td style='background-color:#e6e6e5;text-align:left;vertical-align:top;'>{1}</td></tr>", "Regarding", myAccountSupportVM.Regarding);
                body.AppendFormat("<tr><td style='background-color:#d7d7d7;white-space:nowrap;text-align:right;vertical-align:top;'><strong>{0}</strong></td><td style='background-color:#e6e6e5;text-align:left;vertical-align:top;'>{1}</td></tr>", "Details", myAccountSupportVM.Details);
                body.AppendFormat("<tr><td style='background-color:#d7d7d7;white-space:nowrap;text-align:right;vertical-align:top;'><strong>{0}</strong></td><td style='background-color:#e6e6e5;text-align:left;vertical-align:top;'>{1}</td></tr>", "Timestamp", DateTime.UtcNow.AddHours(-8).ToString("MM/dd/yyyy @ h:mm tt"));
                body.AppendFormat("<tr><td style='background-color:#d7d7d7;white-space:nowrap;text-align:right;vertical-align:top;'><strong>{0}</strong></td><td style='background-color:#e6e6e5;text-align:left;vertical-align:top;'>{1}</td></tr>", "Users IP", HtmlUtil.GetUserIP());
                body.Append("</table>");

                MailMessage message = new MailMessage();
                message.From = new MailAddress(myAccountSupportVM.Email);
                message.To.Add(new MailAddress("*****@*****.**"));
                message.Subject         = description;
                message.IsBodyHtml      = true;
                message.Body            = body.ToString();
                message.BodyEncoding    = System.Text.Encoding.UTF8;
                message.SubjectEncoding = System.Text.Encoding.UTF8;


                SmtpClient SMTPServer = new SmtpClient(WebConfigurationManager.AppSettings["SMTP_HOST"]);
                SMTPServer.Port = Int16.Parse(WebConfigurationManager.AppSettings["SMTP_PORT"]);
                //SMTPServer.Credentials = new System.Net.NetworkCredential(WebConfigurationManager.AppSettings["SMTP_USERNAME"], WebConfigurationManager.AppSettings["SMTP_PASSWORD"]);

                try
                {
                    #if DEBUG
                    string debugAddress = WebConfigurationManager.AppSettings["DEBUG_EMAIL"];
                    if (!string.IsNullOrEmpty(debugAddress))
                    {
                        message.To.Clear();
                        message.CC.Clear();
                        message.Bcc.Clear();
                        message.To.Add(debugAddress);
                    }
                    #endif
                    SMTPServer.Send(message);
                    received = true;
                }
                catch (Exception ex)
                {
                    #if DEBUG
                    ModelState.AddModelError(string.Empty, "Exception: " + ex.Message);
                    #endif
                }
                message.Dispose();
            }

            SkyberryUser user    = UOW.SkyberryUsers.GetById(User.Identity.GetUserId());
            Account      account = null;
            HttpCookie   cookie  = Request.Cookies.Get("accountId");
            if (cookie != null)
            {
                try
                {
                    account = UOW.Accounts.GetById(Guid.Parse(cookie.Value));
                }
                catch { }
            }
            if (account == null && user.Accounts != null && user.Accounts.Count > 0)
            {
                foreach (var item in user.Accounts)
                {
                    account = UOW.Accounts.GetById(item.Id);
                    break;
                }
            }
            MyAccountSupportVM vm = new MyAccountSupportVM
            {
                User    = user,
                Account = account
            };
            vm.Received = received;

            return(View(vm));
        }