Esempio n. 1
0
        public ActionResult AddSupportQuery(SupportQueryVM _supportQuery)
        {
            try
            {
                ViewBag.UnSuccessMessage = null;
                ViewBag.SuccessMessage   = null;

                if (!ModelState.IsValid)
                {
                    ViewBag.UnSuccessMessage = "Please enter your Email Address/Query.";
                    return(View("AddSupportQuery"));
                }
                else
                {
                    _supportQuery.IPAddress = Request.UserHostAddress;

                    if (_supportQuery.EmailAddress != string.Empty && _supportQuery.Query != string.Empty)
                    {
                        _supportQuery = new Business_BLL().AddSupportQuery(_supportQuery);

                        if (_supportQuery != null)
                        {
                            ViewBag.SuccessMessage = "Your query has been submitted successfully. Support person will contact you shortly to help you with this.";

                            //Send Email to Admin
                            //Fetching Email Body Text from EmailTemplate File.
                            string       FilePath = Server.MapPath(@"~\EmailTemplates") + @"\SupportQuery.html";
                            StreamReader str      = new StreamReader(FilePath);
                            string       MailText = str.ReadToEnd();
                            str.Close();

                            //Repalce EmailTemplate Parameters
                            MailText = MailText.Replace("[#SHPOT]", "SHPOT");
                            MailText = MailText.Replace("[#FULLNAME]", _supportQuery.FullName);
                            MailText = MailText.Replace("[#IPADDRESS]", _supportQuery.IPAddress);
                            MailText = MailText.Replace("[#QUERYDATE]", _supportQuery.QueryDateTime.ToString());
                            MailText = MailText.Replace("[#EMAILID]", _supportQuery.EmailAddress);
                            MailText = MailText.Replace("[#QUERY]", _supportQuery.Query);

                            String _fromEmail = _supportQuery.EmailAddress;
                            String _fromName  = _supportQuery.FullName;
                            String _toEmail   = Common.SMTPUserName;
                            String _toName    = "SHPOT Admin";
                            SendEmailNotifications(_supportQuery.EmailAddress, _supportQuery.FullName, _toEmail, _toName, MailText, "Support Query By: " + _supportQuery.FullName);
                        }
                        else
                        {
                            ViewBag.UnSuccessMessage = "Please submit your query again.";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.UnSuccessMessage = "Please submit your query again. Some error has occurred. Error is: " + ex.Message;
            }
            return(View("AddSupportQuery"));
        }
Esempio n. 2
0
        /// <summary>
        /// Add Support Query
        /// </summary>
        /// <param name="_supportQueryVM"></param>
        /// <returns></returns>
        public SupportQueryVM AddSupportQuery(SupportQueryVM _supportQueryVM)
        {
            SupportQuery _supportQuery = new SupportQuery {
                FullName = _supportQueryVM.FullName, EmailAddress = _supportQueryVM.EmailAddress, Query = _supportQueryVM.Query, IPAddress = _supportQueryVM.IPAddress
            };

            _supportQuery = _objBusinessDAL.AddSupportQuery(_supportQuery);
            if (_supportQuery != null)
            {
                _supportQueryVM.SupportQueryID = _supportQuery.SupportQueryID;
                _supportQueryVM.QueryDateTime  = _supportQuery.QueryDateTime;
                return(_supportQueryVM);
            }
            else
            {
                return(null);
            }
        }