Example #1
0
        public IActionResult SubmitErrorReport(SubmitReportViewModel model)
        {
            try
            {
                string exceptionMsg = model.Exception;

                // Try to grab the actual exception that occured
                Exception ex = HttpContext.Session.Get <Exception>("Exception");
                if (ex != null)
                {
                    exceptionMsg = string.Format(@"
Exception: {0}

Source: {1}

Stack Trace:

{2}
", ex.GetFullMessage(true), ex.Source, ex.StackTrace);
                }

                // Let's also email the message to support
                SmtpClient client = new SmtpClient();
                client.Host                  = _config.ContactConfig.EmailAccount.Host;
                client.Port                  = _config.ContactConfig.EmailAccount.Port;
                client.EnableSsl             = _config.ContactConfig.EmailAccount.SSL;
                client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = true;
                client.Credentials           = new System.Net.NetworkCredential(_config.ContactConfig.EmailAccount.Username, _config.ContactConfig.EmailAccount.Password);
                client.Timeout               = 5000;

                MailMessage mail = new MailMessage(new MailAddress(_config.NoReplyEmail, _config.NoReplyEmail), new MailAddress(_config.SupportEmail, "Teknik Support"));
                mail.Sender       = new MailAddress(_config.ContactConfig.EmailAccount.EmailAddress);
                mail.Subject      = "[Exception] Application Exception Occured";
                mail.Body         = @"
An exception has occured at: " + model.CurrentUrl + @"

----------------------------------------
User Message:

" + model.Message + @"

----------------------------------------
" + exceptionMsg;
                mail.BodyEncoding = UTF8Encoding.UTF8;
                mail.DeliveryNotificationOptions = DeliveryNotificationOptions.Never;

                client.Send(mail);
            }
            catch (Exception ex)
            {
                return(Json(new { error = "Error submitting report. Exception: " + ex.Message }));
            }

            return(Json(new { result = "true" }));
        }
        public ActionResult SubmitReport(int?id)
        {
            if (id == null || !this._service.CommentExists(id))
            {
                return(RedirectToAction("All", "Products", new { area = "" }));
            }

            SubmitReportViewModel srvm = this._service.PrepareSubmitReportInfo(id);

            return(View(srvm));
        }
        public ActionResult SubmitReport(SubmitReportViewModel srbm)
        {
            var currentUserId = this.User.Identity.GetUserId();

            if (!ModelState.IsValid)
            {
                return(RedirectToAction("SubmitReport", new { id = srbm.ReportedCommentId }));
            }

            this._service.SendCommentReport(currentUserId, srbm);
            return(RedirectToAction("Details", "Reviews", new { id = srbm.ReviewId, area = "" }));
        }
Example #4
0
        public void SendCommentReport(string currentUserId, SubmitReportViewModel srbm)
        {
            var customer = this.Context.Customers.First(c => c.UserId == currentUserId);
            var comment  = this.Context.Comments.Find(srbm.ReportedCommentId);

            Report report = Mapper.Instance.Map <Report>(srbm);

            report.Snitch           = customer;
            report.OffensiveComment = comment;

            this.Context.Reports.Add(report);
            this.Context.SaveChanges();
        }