예제 #1
0
        public ActionResult Process(int?id, int?param)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
            Response.Cache.SetNoStore();
            if (Session != null)
            {
                if (Session["AdminUser"] == null)
                {
                    return(RedirectToAction("AdminLogin", "Home"));
                }
                else
                {
                    WebApplication.Models.ThreatReportViewModel viewModel = new WebApplication.Models.ThreatReportViewModel();

                    if (id == null)
                    {
                        return(HttpNotFound());
                    }


                    viewModel       = user.GetThreatRequest(id, param);
                    person          = user.GetUser(param, 0);
                    viewModel.Users = person;
                    viewModel       = Initialize(viewModel);
                    viewModel       = InitializeWhoToNotify(viewModel);
                    if (viewModel.Threat == null)
                    {
                        return(HttpNotFound());
                    }

                    return(View(viewModel));
                }
            }
            else
            {
                return(RedirectToAction("AdminLogin", "Home"));
            }
        }
예제 #2
0
        public ActionResult Process(WebApplication.Models.ThreatReportViewModel viewModel)
        {
            /*Gettig values form text boxex*/
            //=================================Email Body Creation fo sending email=====================================//
            long    parentid       = viewModel.Threat.ThreatReport_Id;
            string  level          = viewModel.Threat.Level_Of_Threat;
            string  threatdetail   = dateval;
            string  sourceofthreat = viewModel.ThreatDetails.Source;
            string  details        = viewModel.ThreatDetails.Details;
            Boolean witness        = viewModel.ThreatDetails.Witness;
            string  witnessvalues  = "No";

            if (witness == true)
            {
                witnessvalues = "Yes";
            }



            string Reason         = viewModel.ThreatDetails.Any_Personal_Reason;
            string nameofsuspects = "<b>Name of Suspects are as follows: </b> <br />";

            for (int i = 0; i < textboxitems.Count(); i++)
            {
                int val = i + 1;
                nameofsuspects += val.ToString() + ". " + textboxitems[i] + "<br />";
            }


            nameofsuspects += "<br />";



            string whounotifyto = "<b>To whom you notified:</b> <br/>";


            if (viewModel.SelectedCheckBoxes != null)
            {
                foreach (var item in viewModel.SelectedCheckBoxes)
                {
                    whounotifyto += ". " + item.ToString() + "<br/>";
                }
            }
            whounotifyto += "<br/>";
            string towhommuhafiznotify = "<b>To whom Muhafiz notify:</b> <br/>";
            int    initiall            = 0;

            if (viewModel.SelectedCheckBoxesNotify != null)
            {
                foreach (var item in viewModel.SelectedCheckBoxesNotify)
                {
                    int val = initiall + 1;
                    towhommuhafiznotify += ". " + item.ToString() + "<br/>";
                }
            }
            towhommuhafiznotify += "<br/>";
            string response = viewModel.ThreatDetails.Response;

            viewModel.Users = person;
            // =============================================End===============================================//
            //       if (ModelState.IsValid)
            //       {
            string ConfirmCode = user.InsertReportDetails(viewModel, textboxitems, dateval);

            if (!String.IsNullOrEmpty(ConfirmCode))
            {
                string url = Url.Action("ConfirmationDetails", "Home",
                                        new RouteValueDictionary(new { id = ConfirmCode }),
                                        //url param
                                        HttpContext.Request.Url.Scheme,
                                        HttpContext.Request.Url.Host);
                string Messagebody = "Dear " + person.UserName + "<br/><br/>" + "You have reported a threat using Muhafiz. Please review the details of the threat and then click the link below to verify that these details are accurate, to the best of your knowledge:<br/><br/>" + "<b>Parent threat number</b>: " + parentid.ToString() + "<br /><br />" + "<b>Level of threat</b>: " + level + "<br /><br />" + "<b>Date of threat:</b> " + threatdetail + "<br/><br />" + "<b>Source of threat:</b> " + sourceofthreat + "<br/><br />" + "<b>Details of threat:</b> " + details + "<br/><br />" + "<b>Witnesses of threat:</b> " + witnessvalues
                                     + "<br/><br />" + "<b>Any personal reason:</b> " + Reason + "<br/><br />" + nameofsuspects + whounotifyto + "<b>Response of Authorities:</b> " + response + "<br/><br />" + towhommuhafiznotify + "<b>Link:</b> <br/>I hereby verify that the aforementioned details are correct and accurate, to the best of my knowledge at this time" + "<br/>" + url;
                Models.Admin.SendEmail(person.email, "ConfirmationDetails", Messagebody);
            }

            return(RedirectToAction("GetAllThreathRequests"));

            //     }


            //    var message = "Error occurred while submitting credentials try again. ";
            //      return RedirectToAction("GetAllThreathRequests" , new { returnmessage = message });
        }