Ejemplo n.º 1
0
        public ActionResult Rebuttal(int page, ManageMessageId?message)
        {
            var UserId           = User.Identity.GetUserId();
            var loggedInUserById = _applicationDbContext.Users.SingleOrDefault(i => i.Id == UserId);

            if (loggedInUserById.Career == "General")
            {
                ViewBag.StatusMessage =
                    message == ManageMessageId.Error ? "You must enter a rebuttal."
                : "";
                RebuttalForReportViewModel rebuttalModel = new RebuttalForReportViewModel();
                HtmlToText convert    = new HtmlToText();
                var        reportById = _applicationDbContext.Reports.Where(m => m.ReportId == page).SingleOrDefault();

                rebuttalModel.ReportId   = reportById.ReportId;
                rebuttalModel.ReportText = convert.Convert(reportById.ReportText);

                ViewBag.State = _applicationDbContext.States.ToList();
                ViewBag.City  = _applicationDbContext.Cities.ToList();

                return(View(rebuttalModel));
            }
            else
            {
                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                return(RedirectToAction("Login", "Account"));
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> CreateRebuttal([Bind(Include = "RebuttalId,ReportId,UserId,Title,RebuttalText,Address,CityId,StateId,DateCreated")] RebuttalForReportViewModel rebuttal)
        {
            HtmlToText      convert = new HtmlToText();
            ManageMessageId?message;
            var             reportById = _applicationDbContext.Reports.Where(m => m.ReportId == rebuttal.ReportId).SingleOrDefault();

            string RandomId = Guid.NewGuid().ToString();

            string PageTitle    = reportById.CompanyorIndividual + " : " + convert.Convert(reportById.ReportText).Substring(0, 50);
            string sm_PageTitle = Regex.Replace(PageTitle, "[^A-Za-z0-9]", "-");

            Rebuttal reb = new Rebuttal();

            if (rebuttal.RebuttalText != null && rebuttal.Title != null)
            {
                reb.ReportId     = rebuttal.ReportId;
                reb.RebuttalText = rebuttal.RebuttalText;
                reb.UserId       = User.Identity.GetUserId();
                reb.Title        = rebuttal.Title;
                reb.RebuttalText = rebuttal.RebuttalText;
                reb.Address      = rebuttal.Address;
                reb.CityId       = rebuttal.CityId;
                reb.StateId      = rebuttal.StateId;
                reb.Status       = false;
                reb.DateCreated  = DateTime.UtcNow;

                if (ModelState.IsValid)
                {
                    _applicationDbContext.Rebuttals.Add(reb);
                    await _applicationDbContext.SaveChangesAsync();

                    var    getReportOwnerDisplayName = UserManager.FindByIdAsync(reportById.UserId);
                    var    getRebuttalDisplayName    = UserManager.FindByIdAsync(reb.UserId);
                    string id = Guid.NewGuid().ToString();
                    if (UserManager.EmailService != null)
                    {
                        var callbackUrl = Url.Action(
                            "ReportDetails",
                            "Report",
                            new { title = sm_PageTitle, page = reportById.ReportId, iD = id }, protocol: Request.Url.Scheme);

                        string Body =
                            "<p><h3>Rip-Off NG</h3></p>" +
                            "<p>Hi " + getReportOwnerDisplayName.Result.Email + ",</p>" +
                            "<p class=\"lead\">A response has been posted to your complaint by " + getRebuttalDisplayName.Result.NameExtension +
                            "<p>----------------------------------------------------------------------------------------------------------------------------------------</p>";

                        await UserManager.SendEmailAsync(reportById.UserId, "Rip-Off Ng | Response to your complaint about: " + reportById.Title, Body + " <a href=\"" + callbackUrl + "\">Click here to view</a>" + "<p></p><p>Do not reply to this email.</p><p>Regards,</p><p>Rip-Off NG Team</p><p>Psst! Remember - this is not a marketing email.Since you have a Rip-Off NG Account,we want to keep you informed about operational updates or changes to our websites.</p>");
                    }
                }
            }
            else
            {
                message = ManageMessageId.Error;

                return(RedirectToAction("Rebuttal", new { Controller = "Report", action = "Rebuttal", title = sm_PageTitle, page = rebuttal.ReportId, id = RandomId, message }));
            }


            return(RedirectToAction("ReportDetails", new { Controller = "Report", action = "ReportDetails", title = sm_PageTitle, page = rebuttal.ReportId, id = RandomId }));
        }