Пример #1
0
        /// <summary>
        /// 分页查询新闻
        /// </summary>
        public ResponseModel NewsPageQuery(int pageSize, int pageIndex, int Querytype, out int total, List <Expression <Func <News, bool> > > where)
        {
            var list = _db.News.Include("NewsClassify").Include("NewsComment");

            foreach (var item in where)
            {
                list = list.Where(item);
            }
            int totalCount = 0;
            var pageData   = new List <News>();

            if (Querytype == 0) //查询所有
            {
                pageData   = list.OrderByDescending(c => c.PublishDate).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
                totalCount = list.Count();
            }
            if (Querytype == 1) //查询篮球模块
            {
                pageData   = list.Where(s => s.NewsClassify.ParentId == 0 && s.NewsClassify.ClassifyType == 0).OrderByDescending(c => c.PublishDate).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
                totalCount = list.Where(s => s.NewsClassify.ParentId == 0 && s.NewsClassify.ClassifyType == 0).Count();
            }
            if (Querytype == 2) //查询步行街
            {
                pageData   = list.Where(s => s.NewsClassify.ParentId != 0 && s.NewsClassify.ClassifyType == 1).OrderByDescending(c => c.PublishDate).Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList();
                totalCount = list.Where(s => s.NewsClassify.ParentId != 0 && s.NewsClassify.ClassifyType == 1).Count();
            }
            total = totalCount;
            var response = new ResponseModel
            {
                code   = 200,
                result = "分页新闻获取成功"
            };

            response.data = new List <NewsModel>();
            HtmlToText convert = new HtmlToText();

            foreach (var news in pageData)
            {
                response.data.Add(new NewsModel
                {
                    Id           = news.Id,
                    ClassifyId   = news.NewsClassify.Id,
                    ClassifyName = news.NewsClassify.Name,
                    Title        = news.Title,
                    Image        = news.Image,
                    Contents     = convert.Convert(news.Contents).Length > 50 ? $"{convert.Convert(news.Contents).Substring(0, 50)}..." : convert.Convert(news.Contents),
                    PublishDate  = news.PublishDate.ToString("yyyy-MM-dd"),
                    CommentCount = news.NewsComment.Count(),
                    LoveCount    = news.NewsComment.Sum(s => s.Love),
                    Remark       = news.Remark == null ? "" : news.Remark
                });
            }
            return(response);
        }
Пример #2
0
        /// <summary>
        /// 查询新闻列表
        /// </summary>
        public ResponseModel GetNewsList(Expression <Func <News, bool> > where, int NewsClassifyId, int topCount)
        {
            var listAll = _db.News.Include("NewsClassify").Include("NewsComment");
            var list    = new List <News>();

            if (NewsClassifyId == 0) //所有球队
            {
                list = listAll.Where(s => s.NewsClassify.ParentId == 0 && s.NewsClassify.ClassifyType == 0).OrderByDescending(c => c.PublishDate).Take(topCount).ToList();
            }
            else
            {
                var NewsClassifylst = _db.NewsClassify.Find(NewsClassifyId);
                if (NewsClassifylst.ParentId == 0 && NewsClassifylst.ClassifyType == 1)
                {
                    var newsIds = _db.NewsClassify.Where(s => s.ParentId == NewsClassifyId).Select(c => c.Id);
                    list = listAll.Where(s => newsIds.Contains(s.NewsClassifyId)).OrderByDescending(c => c.PublishDate).Take(topCount).ToList();
                }
                else
                {
                    list = listAll.Where(s => s.NewsClassifyId == NewsClassifyId).OrderByDescending(c => c.PublishDate).Take(topCount).ToList();
                }
            }
            var response = new ResponseModel
            {
                code   = 200,
                result = "新闻列表获取成功"
            };

            response.data = new List <NewsModel>();
            HtmlToText convert = new HtmlToText();

            foreach (var news in list)
            {
                response.data.Add(new NewsModel
                {
                    Id           = news.Id,
                    ClassifyName = news.NewsClassify.Name,
                    Title        = news.Title,
                    Image        = news.Image == null ? convert.ConvertImgSrc(news.Contents) : news.Image,
                    Contents     = convert.Convert(news.Contents).Length > 50 ? $"{convert.Convert(news.Contents).Substring(0, 50)}..." : convert.Convert(news.Contents),
                    PublishDate  = news.PublishDate.ToString("yyyy-MM-dd"),
                    CommentCount = news.NewsComment.Count(),
                    LoveCount    = news.NewsComment.Sum(s => s.Love),
                    Remark       = news.Remark
                });
            }
            return(response);
        }
Пример #3
0
        private static bool TryValidateMailTipDisplayableLength(string mailTip, ref LocalizedString errorString)
        {
            HtmlToText htmlToText = new HtmlToText();
            bool       result;

            using (TextReader textReader = new StringReader(mailTip))
            {
                using (TextWriter textWriter = new StringWriter())
                {
                    htmlToText.Convert(textReader, textWriter);
                    string text = textWriter.ToString().Trim();
                    if (text.Length == 0)
                    {
                        errorString = DirectoryStrings.ErrorMailTipMustNotBeEmpty;
                        result      = false;
                    }
                    else if (text.Length > 175)
                    {
                        errorString = DirectoryStrings.ErrorMailTipDisplayableLengthExceeded(175);
                        result      = false;
                    }
                    else
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
Пример #4
0
        public void PrepareToCreate()
        {
            if (!IsValid())
            {
                return;
            }
            if (Title.IsNullOrEmptyOrWhiteSpace())
            {
                if (!Content.IsNullOrEmptyOrWhiteSpace())
                {
                    HtmlToText convert = new HtmlToText();
                    string     _text   = convert.Convert(Content);
                    Title = _text.GetSentences().FirstOrDefault();
                }
            }

            if (Price <= 0)
            {
                Price = IssueEstimation * Salary;
            }

            GetSchedule();
            if (IsNoTime())
            {
                MoveNow();
            }
            else
            {
                AutoSetTimes();
            }
        }
Пример #5
0
        public ActionResult GetAllRecentComplaints()
        {
            HtmlToText    convert   = new HtmlToText();
            HomeViewModel homeModel = new HomeViewModel();

            IQueryable <Report> reports = _applicationDbContext.Reports
                                          .OrderByDescending(d => d.DateCreated)
                                          .Take(10);
            var reportList = new List <IndexReportViewModel>();

            foreach (var report in reports)
            {
                var reportModel = new IndexReportViewModel();
                reportModel.ReportId = report.ReportId;
                var User        = UserManager.FindByIdAsync(report.UserId);
                var ReportOwner = User.Result.NameExtension;
                reportModel.DisplayName = ReportOwner;

                string myString     = convert.Convert(report.ReportText).Substring(0, 90);
                int    index        = myString.LastIndexOf(' ');
                string outputString = myString.Substring(0, index);

                reportModel.ReportText  = outputString;
                reportModel.DateCreated = report.DateCreated;

                reportList.Add(reportModel);
            }
            homeModel.IndexReportViewModels = reportList;
            //return View("Index", homeModel);
            return(PartialView("_RecentComplaints", homeModel));
        }
Пример #6
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"));
            }
        }
        public void Apply(StringBuilder opdsSource)
        {
            var strExists        = true;
            var opds             = opdsSource.ToString();
            var stringsToReplace = new List <string>();

            while (strExists)
            {
                var firstIndex      = opds.IndexOf(OPEN_TAG, StringComparison.Ordinal);
                var closeFirstIndex = firstIndex + OPEN_TAG.Length;

                var secondIndex      = opds.IndexOf(CLOSE_TAG, StringComparison.Ordinal);
                var closeSecondIndex = secondIndex + CLOSE_TAG.Length;

                if (firstIndex < 0 || secondIndex < 0)
                {
                    strExists = false;
                    continue;
                }

                var possibleHtml = opds.Substring(closeFirstIndex, secondIndex - closeFirstIndex);
                stringsToReplace.Add(possibleHtml);
                opds = opds.Substring(closeSecondIndex, opds.Length - closeSecondIndex);
            }

            var htmlToText = new HtmlToText();

            foreach (var s in stringsToReplace)
            {
                var normalContent = htmlToText.Convert(s);
                opdsSource.Replace(s, normalContent);
            }
        }
Пример #8
0
        public async Task <ActionResult> UploadVideo(FormCollection fc, IEnumerable <HttpPostedFileBase> files)
        {
            ReportVideo     reportVideo = null;
            ManageMessageId?message;

            try
            {
                HtmlToText convert = new HtmlToText();

                int reportId = Convert.ToInt32(fc["ReportId"]);
                var user     = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                var    userReport   = _applicationDbContext.Reports.Where(m => m.ReportId == reportId).SingleOrDefault();
                string loggedUserId = user.Id;
                string userrptId    = userReport.UserId;
                string sm_titleC    = userReport.CompanyorIndividual + " : " + convert.Convert(userReport.ReportText).Substring(0, 90);
                titleC = Regex.Replace(sm_titleC, "[^A-Za-z0-9]", "-");
                iD     = Guid.NewGuid().ToString();
                var allowedExtensions = new[] { ".mp4", ".MP4" };

                var isReportExist = _applicationDbContext.Reports.Where(m => m.ReportId == reportId).SingleOrDefault();

                foreach (var file in files)
                {
                    var ext = Path.GetExtension(file.FileName);
                    if (file != null && file.ContentLength > 0 && isReportExist != null && loggedUserId.Equals(userrptId) && allowedExtensions.Contains(ext))
                    {
                        // string filename = System.IO.Path.GetFileName(file.FileName);
                        string filename = Guid.NewGuid() + Path.GetExtension(file.FileName);

                        file.SaveAs(Path.Combine(Server.MapPath("~/VideoUpload"), filename));

                        reportVideo = new ReportVideo();

                        reportVideo.VideoName    = filename;
                        reportVideo.ReportId     = Convert.ToInt32(fc["ReportId"]);
                        reportVideo.VideoCaption = fc["vidCaption"].ToString();
                        reportVideo.DateCreated  = DateTime.UtcNow;

                        _applicationDbContext.ReportVideos.Add(reportVideo);
                        await _applicationDbContext.SaveChangesAsync();

                        return(RedirectToAction("ReportDetails", new { Controller = "Report", action = "ReportDetails", title = titleC, page = Convert.ToInt32(fc["ReportId"]), id = iD }));
                    }
                    else
                    {
                        message = ManageMessageId.Error;
                        return(RedirectToAction("FileUpload", new { Controller = "Report", action = "FileUpload", title = titleC, page = Convert.ToInt32(fc["ReportId"]), id = iD, Message = message }));
                    }
                }
                return(RedirectToAction("ReportDetails", new { Controller = "Report", action = "ReportDetails", title = titleC, page = Convert.ToInt32(fc["ReportId"]), id = iD }));
            }
            catch (Exception ex)
            {
                message = ManageMessageId.Error;
                return(RedirectToAction("FileUpload", new { Controller = "Report", action = "FileUpload", title = titleC, page = Convert.ToInt32(fc["ReportId"]), id = iD, Message = message }));
            }

            //return View();
        }
Пример #9
0
        private static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("usage: MarkdownParser input_file html_output_file text_output_file");
                Environment.Exit(-1);
            }

            if (!File.Exists(args[0]))
            {
                Console.WriteLine("{0} does not exist.", args[0]);
                Environment.Exit(-1);
            }

            //convert markdown to html
            var markdownSource = File.ReadAllText(args[0]);
            var htmlSource     = new Markdown().Transform(markdownSource);

            File.WriteAllText(args[1], htmlSource);

            //convert html to txt
            var html2txt = new HtmlToText();
            var text     = html2txt.Convert(args[1]);

            //use OS newlines
            text = Regex.Replace(text, "(?<!\r)\n", Environment.NewLine);
            Console.WriteLine(text);
            File.WriteAllText(args[2], text);
        }
Пример #10
0
        public ActionResult Create(int page)
        {
            var    rolesAssigneed = canLoggedInUserView();
            string roleCanView    = "Legal Team";

            if (rolesAssigneed != null)
            {
                var element = rolesAssigneed.Where(x => x.StartsWith(roleCanView)).FirstOrDefault();
                if (element != roleCanView)
                {
                    return(RedirectToAction("Unauthorized", "Access"));
                }
                else
                {
                    HtmlToText convert = new HtmlToText();
                    var        report  = _applicationDbContext.Reports.SingleOrDefault(i => i.ReportId == page);
                    ViewBag.ReportText = convert.Convert(report.ReportText);
                    ViewBag.ReportId   = page;
                    return(View());
                }
            }
            else
            {
                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            }
            return(RedirectToAction("Login", "Access"));
        }
Пример #11
0
        /// <summary>
        /// Canned functionality to turn a HTML web page returned into a Text document
        /// </summary>
        /// <param name="uRL">URL of web page to get content from</param>
        /// <returns></returns>
        private static string ExtractTextFromWebPage(string uRL)
        {
            HtmlToText convert = new HtmlToText();
            string     s       = convert.Convert(new System.Net.WebClient().DownloadString(uRL));

            return(s);
        }
Пример #12
0
 public void ToHtmlStandard()
 {
     if (!IsHtmlStandard())
     {
         TextProcessor processor = new TextProcessor(document.DocumentNode.InnerText);
         HtmlToText    convert   = new HtmlToText();
         string        content   = convert.Convert(document.DocumentNode.InnerHtml);
         CleanHtml = content.ToHtml();
     }
 }
Пример #13
0
        public void MakePlanText()
        {
            HtmlDocument document = new HtmlDocument();

            document.OptionFixNestedTags = true;
            document.LoadHtml(CleanHtml);
            HtmlToText convert = new HtmlToText();

            PlanText = convert.Convert(document.DocumentNode.InnerHtml);
        }
Пример #14
0
    //将html格式转换为text且长度小于等于80
    public string returnContent(string content)
    {
        HtmlToText convert = new HtmlToText();
        string     str     = convert.Convert(content);

        if (str.Length > 80)
        {
            str = str.Substring(0, 80);
        }
        return(str);
    }
Пример #15
0
 public AboutUsPageViewModel(INavigationService navigationService)
 {
     NavigationService = navigationService;
     htmlToText        = new HtmlToText();
     if (Application.Current.Properties.ContainsKey("AboutUsData"))
     {
         var aboutusData = (AboutUsData)Application.Current.Properties["AboutUsData"];
         AboutUsText   = htmlToText.Convert(Common.GetLanguage() == "ar-AE" ? aboutusData.text_arabic : aboutusData.text);
         IsNodataFound = false;
     }
     AboutUsDataApi();
 }
Пример #16
0
        public ActionResult DisplayReplySection(int page, int randRid)
        {
            var UserId             = User.Identity.GetUserId();
            var loggedUserByUserId = _applicationDbContext.Users.SingleOrDefault(i => i.Id == UserId);

            if (loggedUserByUserId.Career == "General")
            {
                CommentReplyViewModel replyModel = new CommentReplyViewModel();
                HtmlToText            convert    = new HtmlToText();
                var threadById = _applicationDbContext.Threads.Where(m => m.ThreadId == page).SingleOrDefault();


                var ReportByID = _applicationDbContext.Reports.Where(m => m.ReportId == randRid).SingleOrDefault();

                string rawPageTitle = convert.Convert(ReportByID.ReportText).Substring(0, 90);
                int    indexP       = rawPageTitle.LastIndexOf(' ');
                string titleOutput  = rawPageTitle.Substring(0, indexP);

                string PageTitle    = ReportByID.CompanyorIndividual + " : " + titleOutput;
                string sm_PageTitle = Regex.Replace(PageTitle, "[^A-Za-z0-9]", "-");

                //string myString = threadById.ThreadText;

                replyModel.ThreadId   = threadById.ThreadId;
                replyModel.ThreadText = convert.Convert(threadById.ThreadText);
                replyModel.PageTitle  = sm_PageTitle;
                replyModel.ReportId   = ReportByID.ReportId;
                replyModel.RandomId   = Guid.NewGuid().ToString();


                return(PartialView("_ReplyModal", replyModel));
            }
            else
            {
                AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                return(RedirectToAction("Login", "Account"));
            }
        }
Пример #17
0
        // Convert downloaded HTML pages to Text file

        public static void ProcessFile(string path)
        {
            HtmlToText htt = new HtmlToText();

            Console.WriteLine("Processed file '{0}'.", path);
            string       s          = htt.Convert(path);
            string       pathString = @"c:\files\CryptoCrawler\Text\";
            string       fileName   = "NewFile.txt";
            StreamWriter sw         = new StreamWriter(NextAvailableFilename(pathString +
                                                                             fileName));

            sw.Write(s);
            sw.Flush();
            sw.Close();
            //Get Converted Text files
            ProcessTextDirectory(pathString);
        }
        public JsonResult Index(string keyword)
        {
            HtmlToText convert          = new HtmlToText();
            int        ReportId         = 0;
            string     s                = keyword;
            var        searchResultList = new List <SearchResultViewModel>();
            int        result;

            if (int.TryParse(s, out result))
            {
                ReportId = Convert.ToInt32(keyword);
            }
            else
            {
            }

            IQueryable <Report> Reports = _applicationDbContext.Reports.Include(c => c.Category).Include(t => t.Topic).Include(ci => ci.City).Include(st => st.State);


            if (!String.IsNullOrEmpty(keyword))
            {
                Reports = Reports

                          .Where(d => d.CompanyorIndividual.ToLower().Contains(keyword) || d.ReportId == ReportId ||
                                 d.ReportText.ToLower().Contains(keyword) || d.Website.ToLower().Contains(keyword) ||
                                 d.Address.ToLower().Contains(keyword) || d.Category.Name.ToLower().Contains(keyword)).OrderByDescending(d => d.DateCreated);
            }

            foreach (var report in Reports)
            {
                SearchResultViewModel model = new SearchResultViewModel();

                string title  = report.CompanyorIndividual + ":" + convert.Convert(report.ReportText.Substring(0, 90));
                string titleC = Regex.Replace(title, "[^A-Za-z0-9]", "-");

                model.iD       = Guid.NewGuid().ToString();
                model.page     = report.ReportId;
                model.title    = titleC;
                model.company  = report.CompanyorIndividual;
                model.Topic    = report.Topic.Name;
                model.Category = report.Category.Name;
                searchResultList.Add(model);
            }

            return(Json(searchResultList, JsonRequestBehavior.AllowGet));
        }
Пример #19
0
        public void AutoAdjust()
        {
            if (Title.IsNullOrEmptyOrWhiteSpace())
            {
                HtmlToText convert = new HtmlToText();
                string     _text   = convert.Convert(this.Content);
                Title = _text.GetSentences().FirstOrDefault();
            }

            if (Title.ToLower().Contains("[daily]"))
            {
                Repeat = ScheduleType.Daily;
            }
            if (Title.ToLower().Contains("[weekly]"))
            {
                Repeat = ScheduleType.Weekly;
            }
            if (Title.ToLower().Contains("[monthly]"))
            {
                Repeat = ScheduleType.Monthly;
            }
            if (Title.ToLower().Contains("[quaterly]"))
            {
                Repeat = ScheduleType.Quaterly;
            }
            if (Title.ToLower().Contains("[yearly]"))
            {
                Repeat = ScheduleType.Yearly;
            }

            //AutoSetTime
            this.AutoSetTimes();

            //HasTags
            string[] _hasTags = Content.GetHasTags();
            if (_hasTags != null && _hasTags.Count() > 0)
            {
                foreach (string _hasTag in _hasTags)
                {
                    HasTags.Add(_hasTag);
                }
            }
            //Links
            //Links = this.Content.GetUrls().ToList();
        }
Пример #20
0
        public async Task <BookFilesInfo> GetBookContent(BookInfo book)
        {
            if (!_lookup.ContainsKey(book.Id))
            {
                return(null);
            }

            BookFilesInfo content = _lookup[book.Id];

            var tasks = content.FileIds.Select(async id => await ReadBookFile(book, id));

            BookFileInfo[] files = await Task.WhenAll(tasks);

            var html = new HtmlToText();

            book.Description = html.Convert(book.Description);

            var contentWithBytes = new BookFilesInfo(book, files);

            return(contentWithBytes);
        }
Пример #21
0
        public static string HtmlToText(string html, bool shouldUseNarrowGapForPTagHtmlToTextConversion)
        {
            if (string.IsNullOrEmpty(html))
            {
                return(html);
            }
            html = TextConverterHelper.RemoveHtmlLink(html);
            string result;

            using (StringReader stringReader = new StringReader(html))
            {
                using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
                {
                    HtmlToText htmlToText = new HtmlToText();
                    htmlToText.InputEncoding  = Encoding.UTF8;
                    htmlToText.OutputEncoding = Encoding.UTF8;
                    htmlToText.ShouldUseNarrowGapForPTagHtmlToTextConversion = shouldUseNarrowGapForPTagHtmlToTextConversion;
                    TextConvertersInternalHelpers.SetImageRenderingCallback(htmlToText, new ImageRenderingCallback(TextConverterHelper.RemoveImageCallback));
                    htmlToText.Convert(stringReader, stringWriter);
                    result = stringWriter.ToString();
                }
            }
            return(result);
        }
Пример #22
0
        private void SaveAsTextButton_Click(object sender, EventArgs e)
        {
            // Create an instance of the save file dialog box.
            var saveFileDialog1 = new SaveFileDialog
            {
                // ReSharper disable once LocalizableElement
                Filter      = "TXT Files (.txt)|*.txt",
                FilterIndex = 1
            };

            if (Directory.Exists(Settings.Default.SaveDirectory))
            {
                saveFileDialog1.InitialDirectory = Settings.Default.SaveDirectory;
            }

            // Process input if the user clicked OK.
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                Settings.Default.SaveDirectory = Path.GetDirectoryName(saveFileDialog1.FileName);
                var htmlToText = new HtmlToText();
                var text       = htmlToText.Convert(webBrowser1.DocumentText);
                File.WriteAllText(saveFileDialog1.FileName, text);
            }
        }
Пример #23
0
        public async Task <ActionResult> CreateThread([Bind(Include = "ThreadId,ReportId,UserId,ThreadText,DateCreated")] CommentForReportViewModel comment)
        {
            System.Threading.Thread.Sleep(1000);
            HtmlToText      convert = new HtmlToText();
            ManageMessageId?message;

            Thread thread     = new Thread();
            var    reportById = _applicationDbContext.Reports.Where(m => m.ReportId == comment.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]", "-");


            thread.ReportId    = comment.ReportId;
            thread.ThreadText  = comment.ThreadText;
            thread.UserId      = User.Identity.GetUserId();
            thread.DateCreated = DateTime.UtcNow;
            if (comment.ThreadText != null)
            {
                if (ModelState.IsValid)
                {
                    _applicationDbContext.Threads.Add(thread);

                    await _applicationDbContext.SaveChangesAsync();
                }
            }
            else
            {
                message = ManageMessageId.Error;
                return(RedirectToAction("Thread", new { Controller = "Report", action = "Thread", title = sm_PageTitle, page = thread.ReportId, id = RandomId, message }));
            }

            return(RedirectToAction("ReportDetails", new { Controller = "Report", action = "ReportDetails", title = sm_PageTitle, page = thread.ReportId, id = RandomId }));
        }
        public ActionResult Index(int?page)
        {
            UserReportViewModel viewModel = new UserReportViewModel();

            IQueryable <Report> reports = _applicationDbContext.Reports
                                          .Include(t => t.Topic).Include(c => c.Category).Include(r => r.ReportImages)
                                          .Include(reb => reb.Rebuttals).Include(th => th.Threads).Include(rcu => rcu.RipoffCaseUpdates)
                                          .Include(upd => upd.ReportUpdates).Include(v => v.ReportVideos)
                                          .OrderByDescending(d => d.DateCreated);

            var reportList = new List <ReportsWithOwner>();
            var questList  = new List <TopTenQuestionForLatestReportViewModel>();

            foreach (var m in reports)
            {
                var        models  = new ReportsWithOwner();
                HtmlToText convert = new HtmlToText();


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

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

                models.PageTitle           = sm_PageTitle;
                models.ReportId            = m.ReportId;
                models.CompanyorIndividual = m.CompanyorIndividual;
                //string reportText = convert.Convert(m.ReportText);
                models.ReportText   = convert.Convert(m.ReportText);
                models.DateCreated  = m.DateCreated;
                models.CategoryName = m.Category.Name;
                models.TopicName    = m.Topic.Name;

                var User        = UserManager.FindByIdAsync(m.UserId);
                var ReportOwner = User.Result.NameExtension;


                //var CatName = _applicationDbContext.Categories

                models.DisplayName = ReportOwner;

                if (m.ReportImages.Count > 0)
                {
                    models.ReportImagesExist = true;
                    models.ReportImagesCount = m.ReportImages.Count;
                }
                if (m.Rebuttals.Count > 0)
                {
                    models.RebuttalsExist = true;
                    models.RebuttalsCount = m.Rebuttals.Count;
                }
                if (m.Threads.Count > 0)
                {
                    models.ThreadsExist = true;
                    models.ThreadsCount = m.Threads.Count;
                }
                //if ()
                //{
                //    models.CaseUpdatesExist = true;

                //}

                if (m.ReportUpdates.Count > 0)
                {
                    models.ReportUpdateExist = true;
                    models.ReportUpdateCount = m.ReportUpdates.Count;
                }
                if (m.ReportVideos.Count > 0)
                {
                    models.ReportVideosExist = true;
                    models.ReportVideoCount  = m.ReportVideos.Count;
                }
                else
                {
                }

                reportList.Add(models);
            }

            //var topTenQuestion = _applicationDbContext.Questions
            //            .OrderByDescending(dt => dt.DateAsked)
            //            .Take(10);
            //foreach(var top in topTenQuestion)
            //{
            //    TopTenQuestionForLatestReportViewModel questModel = new TopTenQuestionForLatestReportViewModel();
            //    questModel.QuestionId = top.QuestionId;
            //    questModel.QuestionTitle = top.Title;
            //    questModel.QuestionText = top.QuestionText;

            //    var QuestOwner = UserManager.FindByIdAsync(top.UserId);
            //    string QuestionOwner = QuestOwner.Result.NameExtension;
            //    questModel.QuestionOwner = QuestionOwner;
            //    questModel.DateAsked = top.DateAsked.ToString("d,MMMM yy");
            //    questModel.TimeAsked = top.DateAsked.ToString("H:mm tt");

            //    questList.Add(questModel);
            //}

            int pageSize   = 25;
            int pageNumber = page ?? 1;

            //viewModel.TopTenQuestionForLatestReportViewModels = questList;
            viewModel.ReportsWithOwners = reportList.ToPagedList <ReportsWithOwner>(pageNumber, pageSize);

            return(View(viewModel));
        }
Пример #25
0
        public async Task <ActionResult> Index()
        {
            var mainModel    = new FeedbackWithBlog();
            var listFeedback = new List <FeedbackViewModel>();
            var listBlog     = new List <BlogViewModel>();
            var homeModel    = new HomeViewModel();
            var convert      = new HtmlToText();

            var blogs = _applicationDbContext.Blogs.OrderByDescending(d => d.DateCreated).Take(10).ToList();

            foreach (var i in blogs)
            {
                var blogModel = new BlogViewModel();
                blogModel.BlogId      = i.BlogId;
                blogModel.Title       = i.Title;
                blogModel.DateCreated = i.DateCreated;
                listBlog.Add(blogModel);
            }

            var feedbacks = _applicationDbContext.Feedbacks.OrderByDescending(d => d.DateCreated).Take(10).ToList();

            foreach (var i in feedbacks)
            {
                var User     = UserManager.FindByIdAsync(i.UserId);
                var userName = User.Result.NameExtension;

                var model = new FeedbackViewModel()
                {
                    DateCreated = i.DateCreated,
                    Message     = i.Message,
                    UserName    = userName
                };

                listFeedback.Add(model);
            }

            IQueryable <Report> reports = _applicationDbContext.Reports
                                          .OrderByDescending(d => d.DateCreated)
                                          .Take(10);
            var reportList = new List <IndexReportViewModel>();

            foreach (var report in reports)
            {
                var reportModel = new IndexReportViewModel();
                reportModel.ReportId = report.ReportId;
                var User        = UserManager.FindByIdAsync(report.UserId);
                var ReportOwner = User.Result.NameExtension;
                reportModel.DisplayName = ReportOwner;

                string myString     = convert.Convert(report.ReportText).Substring(0, 90);
                int    index        = myString.LastIndexOf(' ');
                string outputString = myString.Substring(0, index);

                reportModel.ReportText  = outputString;
                reportModel.DateCreated = report.DateCreated;

                reportList.Add(reportModel);
            }

            IQueryable <Question> questions = _applicationDbContext.Questions
                                              .OrderByDescending(d => d.DateAsked)
                                              .Take(10);

            var questionList = new List <IndexQuestionViewModel>();

            foreach (var question in questions)
            {
                var questionModel = new IndexQuestionViewModel();
                questionModel.QuestionId = question.QuestionId;
                var User        = UserManager.FindByIdAsync(question.UserId);
                var ReportOwner = User.Result.NameExtension;
                questionModel.DisplayName = ReportOwner;

                questionModel.QuestionText  = question.QuestionText;
                questionModel.DateAsked     = question.DateAsked;
                questionModel.QuestionTitle = question.Title;

                questionList.Add(questionModel);
            }

            ViewBag.Questions = questionList;

            ViewBag.Complaints = reportList;

            mainModel.Posts        = listBlog;
            mainModel.Testimonials = listFeedback;
            return(View(mainModel));
        }
Пример #26
0
        private async void PrivacyPolicyApi()
        {
            try
            {
                IsLoaderBusy = true;
                if (Common.CheckConnection())
                {
                    PrivacyPolicyResponseModel response;
                    try
                    {
                        response = await _webApiRestClient.GetAsync <PrivacyPolicyResponseModel>(ApiUrl.GetPrivacyPolicy);
                    }
                    catch (Exception ex)
                    {
                        response = null;
                        await MaterialDialog.Instance.SnackbarAsync(message : AppResource.error_ServerError, msDuration : 3000);

                        IsLoaderBusy = false;
                    }
                    if (response != null)
                    {
                        if (response.status)
                        {
                            Application.Current.Properties["PrivacyPolicyData"] = response.PrivacyPolicyData;
                            Application.Current.SavePropertiesAsync();
                            PrivacyPolicyText = htmlToText.Convert(Common.GetLanguage() == "ar-AE" ? response.PrivacyPolicyData.text_arabic : response.PrivacyPolicyData.text);
                            IsNodataFound     = false;
                        }
                        else
                        {
                            await MaterialDialog.Instance.SnackbarAsync(message : response.message, msDuration : 3000);
                        }
                    }
                    else
                    {
                        if (Application.Current.Properties.ContainsKey("PrivacyPolicyData"))
                        {
                            var privacyPolicyData = (PrivacyPolicyData)Application.Current.Properties["PrivacyPolicyData"];
                            PrivacyPolicyText = htmlToText.Convert(Common.GetLanguage() == "ar-AE" ? privacyPolicyData.text_arabic : privacyPolicyData.text);
                            IsNodataFound     = false;
                        }
                        else
                        {
                            IsNodataFound = true;
                        }
                    }
                }
                else
                {
                    if (Application.Current.Properties.ContainsKey("PrivacyPolicyData"))
                    {
                        var privacyPolicyData = (PrivacyPolicyData)Application.Current.Properties["PrivacyPolicyData"];
                        PrivacyPolicyText = htmlToText.Convert(Common.GetLanguage() == "ar-AE" ? privacyPolicyData.text_arabic : privacyPolicyData.text);
                        IsNodataFound     = false;
                    }
                    else
                    {
                        IsNoInternetView = true;
                        IsNodataFound    = false;
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                IsLoaderBusy = false;
            }
        }
Пример #27
0
 private async void AboutUsDataApi()
 {
     if (!Application.Current.Properties.ContainsKey("AboutUsData"))
     {
         IsLoaderBusy = true;
     }
     try
     {
         if (Common.CheckConnection())
         {
             AboutUsResponseModel response;
             try
             {
                 response = await _webApiRestClient.GetAsync <AboutUsResponseModel>(ApiUrl.GetAboutus);
             }
             catch (Exception ex)
             {
                 response     = null;
                 IsLoaderBusy = false;
             }
             if (response != null)
             {
                 if (response.status)
                 {
                     if (Application.Current.Properties.ContainsKey("AboutUsData"))
                     {
                         var aboutusData = (AboutUsData)Application.Current.Properties["AboutUsData"];
                         if (response.AboutUsData != aboutusData)
                         {
                             Application.Current.Properties["AboutUsData"] = response.AboutUsData;
                             Application.Current.SavePropertiesAsync();
                             AboutUsText   = htmlToText.Convert(Common.GetLanguage() == "ar-AE" ? response.AboutUsData.text_arabic : response.AboutUsData.text);
                             IsNodataFound = false;
                         }
                     }
                     else
                     {
                         Application.Current.Properties["AboutUsData"] = response.AboutUsData;
                         Application.Current.SavePropertiesAsync();
                         AboutUsText   = htmlToText.Convert(Common.GetLanguage() == "ar-AE" ? response.AboutUsData.text_arabic : response.AboutUsData.text);
                         IsNodataFound = false;
                     }
                 }
                 else
                 {
                     if (!Application.Current.Properties.ContainsKey("AboutUsData"))
                     {
                         await MaterialDialog.Instance.SnackbarAsync(message : response.message, msDuration : 3000);
                     }
                 }
             }
             else
             {
                 if (Application.Current.Properties.ContainsKey("AboutUsData"))
                 {
                     var aboutusData = (AboutUsData)Application.Current.Properties["AboutUsData"];
                     AboutUsText   = htmlToText.Convert(Common.GetLanguage() == "ar-AE" ? aboutusData.text_arabic : aboutusData.text);
                     IsNodataFound = false;
                 }
                 else
                 {
                     IsNodataFound = true;
                 }
             }
         }
         else
         {
             if (Application.Current.Properties.ContainsKey("AboutUsData"))
             {
                 var aboutusData = (AboutUsData)Application.Current.Properties["AboutUsData"];
                 AboutUsText   = htmlToText.Convert(Common.GetLanguage() == "ar-AE" ? aboutusData.text_arabic : aboutusData.text);
                 IsNodataFound = false;
             }
             else
             {
                 IsNodataFound    = false;
                 IsNoInternetView = true;
             }
         }
     }
     catch (Exception ex)
     {
     }
     finally
     {
         IsLoaderBusy = false;
     }
 }
Пример #28
0
        public async Task <ActionResult> Create([Bind(Include = "ReportId,UserId,CompanyorIndividual,Website,TopicId,CategoryId,ReportText,OnlineTransaction,CreditCard,Status,DateCreated,Address,CityId,StateId,ContactNumber,Email,Title,AdviceStatus")] Report report)
        {
            HtmlToText      convert = new HtmlToText();
            ManageMessageId?message;
            int             countryId = 160;

            ViewBag.State    = _applicationDbContext.States.Where(c => c.CountryId == countryId).ToList();
            ViewBag.City     = _applicationDbContext.Cities.ToList();
            ViewBag.Topic    = _applicationDbContext.Topics.ToList();
            ViewBag.Category = _applicationDbContext.Categories.ToList();

            report.UserId       = User.Identity.GetUserId();
            report.DateCreated  = DateTime.UtcNow;
            report.Status       = false;
            report.AdviceStatus = false;
            if (ModelState.IsValid)
            {
                _applicationDbContext.Reports.Add(report);
                await _applicationDbContext.SaveChangesAsync();

                int reportiD = 0;
                reportiD = report.ReportId;

                rId = reportiD;
                string sm_titleC = report.CompanyorIndividual + " : " + convert.Convert(report.ReportText).Substring(0, 90);
                titleC = Regex.Replace(sm_titleC, "[^A-Za-z0-9]", "-");

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

                //page is used instead of ReportId
                //Once the record is inserted , then notify all the subscribers (Clients)
                RecentComplaintsHub.NotifyRecentComplaintsToAllClients();

                var AdminUsers = _applicationDbContext.Users.Where(userType => userType.Career == "Admin").ToList();
                foreach (var user in AdminUsers)
                {
                    var getReportOwnerDisplayName = UserManager.FindByIdAsync(report.UserId);
                    if (UserManager.EmailService != null)
                    {
                        string id = Guid.NewGuid().ToString();


                        var callbackUrl = Url.Action(
                            "ReportDetails",
                            "Report",
                            new { title = titleC, page = report.ReportId, iD = id }, protocol: Request.Url.Scheme);

                        string Body =
                            "<p><h3>Rip-Off NG</h3></p>" +
                            "<p>Hi " + user.NameExtension + ",</p>" +
                            "<p class=\"lead\">Someone posted a complaint on https://www.ripoff.com.ng " +
                            "<p>----------------------------------------------------------------------------------------------------------------------------------------</p>";

                        await UserManager.SendEmailAsync(user.Id, "Rip-Off Ng | There's a complaint about: " + report.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 Admin</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>");
                    }
                }
                return(RedirectToAction("FileUpload", new { Controller = "Report", action = "FileUpload", title = titleC, page = reportiD, id = iD }));
            }

            message = ManageMessageId.Error;
            return(View(message));
        }
Пример #29
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 }));
        }
Пример #30
0
        public ActionResult ReportDetails(int page, string iD)
        {
            FullReportViewModel mainModel = new FullReportViewModel();
            HtmlToText          convert   = new HtmlToText();
            string LoggedInUser           = User.Identity.GetUserId();


            var SingleReport = _applicationDbContext.Reports
                               .Where(i => i.ReportId == page)
                               .Include(t => t.Topic).Include(c => c.Category).Include(r => r.ReportImages)
                               .Include(reb => reb.Rebuttals).Include(th => th.Threads)
                               .Include(upd => upd.ReportUpdates).Include(st => st.State).Include(ci => ci.City)
                               .Include(vi => vi.ReportVideos)/*.Include(l =>l.RipOffLegalTeams)*/
                               .SingleOrDefault();

            var rebuttalList         = new List <RebuttalViewModel>();
            var threadList           = new List <ThreadViewModel>();
            var rptUpdateList        = new List <ReportUpdateViewModel>();
            var caseUpdateList       = new List <RipOffCaseUpdateViewModel>();
            var rptImageList         = new List <ReportImageViewModel>();
            var rptVideoList         = new List <ReportVideoViewModel>();
            var commentList          = new List <CommentViewModel>();
            var legalList            = new List <RipOffLegalTeamViewModel>();
            var updateLegalList      = new List <LegalAdviceViewModel>();
            var relatedCompanyReport = new List <RelatedReportedCompanyViewModel>();


            if (SingleReport != null)
            {
                var User        = UserManager.FindByIdAsync(SingleReport.UserId);
                var ReportOwner = User.Result.NameExtension;

                mainModel.ReportId            = SingleReport.ReportId;
                mainModel.DisplayName         = ReportOwner;
                mainModel.CompanyorIndividual = SingleReport.CompanyorIndividual;
                mainModel.Website             = SingleReport.Website;
                mainModel.Email         = SingleReport.Email;
                mainModel.CategoryName  = SingleReport.Category.Name;
                mainModel.TopicName     = SingleReport.Topic.Name;
                mainModel.ContactNumber = SingleReport.ContactNumber;
                mainModel.Address       = SingleReport.Address;
                mainModel.Title         = SingleReport.Title;
                if (SingleReport.StateId != null || SingleReport.CityId != null)
                {
                    mainModel.CityName  = SingleReport.City.Name;
                    mainModel.StateName = SingleReport.State.Name;
                }
                else
                {
                    //Do nothing
                }
                //HtmlToText convert = new HtmlToText();

                mainModel.ReportText        = SingleReport.ReportText;
                mainModel.OnlineTransaction = SingleReport.OnlineTransaction;
                mainModel.CreditCard        = SingleReport.CreditCard;
                mainModel.ReportDateCreated = SingleReport.DateCreated.ToString("d,MMMM yy");
                mainModel.ReportTimeCreated = SingleReport.DateCreated.ToString("H:mm tt");


                var rebuttals = _applicationDbContext.Rebuttals.Where(r => r.ReportId == SingleReport.ReportId)
                                .Include(c => c.City).Include(s => s.State)
                                .OrderByDescending(d => d.DateCreated);


                foreach (var reb in rebuttals)
                {
                    var rebModel = new RebuttalViewModel();
                    var RebUser  = UserManager.FindByIdAsync(reb.UserId);
                    var RebOwner = RebUser.Result.NameExtension;

                    rebModel.RebuttalDisplayName = RebOwner;
                    rebModel.RebuttalTitle       = reb.Title;
                    rebModel.RebuttalAddress     = reb.Address;
                    rebModel.RebuttalText        = reb.RebuttalText;

                    if (reb.StateId != null || reb.CityId != null)
                    {
                        rebModel.RebuttalCity  = reb.City.Name;
                        rebModel.RebuttalState = reb.State.Name;
                    }

                    rebModel.RebuttalDateCreated = reb.DateCreated.ToString("d,MMMM yy");
                    rebModel.RebuttalTimeCreated = reb.DateCreated.ToString("H:mm tt");

                    rebuttalList.Add(rebModel);
                }
                if (LoggedInUser == null)
                {
                    LoggedInUser = "******";
                }
                else
                {
                    if (LoggedInUser.StartsWith(SingleReport.UserId))
                    {
                        mainModel.RebuttalAccess = true;
                    }
                }

                var thread = _applicationDbContext.Threads.Where(r => r.ReportId == SingleReport.ReportId)
                             .Include(com => com.Comments)
                             .OrderBy(d => d.DateCreated).ToList();

                foreach (var th in thread)
                {
                    var CommenterProfile = _applicationDbContext.UserProfilePhotos.SingleOrDefault(id => id.UserId == th.UserId);
                    var threadModel      = new ThreadViewModel();
                    var threadUser       = UserManager.FindByIdAsync(th.UserId);
                    var threadOwner      = threadUser.Result.NameExtension;

                    if (CommenterProfile == null)
                    {
                        threadModel.ThreadImageName = "person.gif";
                    }
                    else
                    {
                        threadModel.ThreadImageName = CommenterProfile.ImageName;
                    }

                    threadModel.ThreadDisplayName = threadOwner;
                    threadModel.ThreadId          = th.ThreadId;
                    threadModel.ThreadText        = th.ThreadText;
                    threadModel.ThreadDateCreated = th.DateCreated.ToString("d,MMMM yy");
                    threadModel.ThreadTimeCreated = th.DateCreated.ToString("H:mm tt");



                    foreach (Comment com in th.Comments.OrderBy(d => d.DateCreated))
                    {
                        var commentModel      = new CommentViewModel();
                        var ReplyDisplayImage = _applicationDbContext.UserProfilePhotos.SingleOrDefault(id => id.UserId == com.UserId);
                        if (ReplyDisplayImage == null)
                        {
                            commentModel.CommentImageName = "person.gif";
                        }
                        else
                        {
                            commentModel.CommentImageName = ReplyDisplayImage.ImageName;
                        }

                        commentModel.ThreadId           = com.ThreadId;
                        commentModel.CommentText        = com.CommentText;
                        commentModel.CommentDateCreated = com.DateCreated.ToString("d,MMMM yy");
                        commentModel.CommentTimeCreated = com.DateCreated.ToString("H:mm tt");

                        var commentUser  = UserManager.FindByIdAsync(com.UserId);
                        var commentOwner = commentUser.Result.NameExtension;
                        commentModel.CommentDisplayName = commentOwner;

                        commentList.Add(commentModel);
                    }

                    threadList.Add(threadModel);
                }

                IQueryable <ReportUpdate> update = _applicationDbContext.ReportUpdates.Where(r => r.ReportId == SingleReport.ReportId)
                                                   .Include(upd => upd.UpdateAdvices)
                                                   .OrderByDescending(d => d.DateCreated);
                foreach (var r in update)
                {
                    var rptUpdateModel = new ReportUpdateViewModel();

                    rptUpdateModel.ReportUpdateId          = r.ReportUpdateId;
                    rptUpdateModel.ReportUpdateDisplayName = ReportOwner;
                    rptUpdateModel.ReportUpdateText        = r.Update;
                    rptUpdateModel.ReportUpdateDateCreated = r.DateCreated.ToString("d,MMMM yy");
                    rptUpdateModel.ReportUpdateTimeCreated = r.DateCreated.ToString("H:mm tt");

                    foreach (UpdateAdvice upd in r.UpdateAdvices.OrderBy(d => d.DateCreated))
                    {
                        var updateLegalModel = new LegalAdviceViewModel();

                        updateLegalModel.UpdateAdvice   = upd.AdviseText;
                        updateLegalModel.ReportUpdateId = upd.ReportUpdateId;

                        updateLegalList.Add(updateLegalModel);
                    }

                    rptUpdateList.Add(rptUpdateModel);
                }

                IQueryable <ReportImage> image = _applicationDbContext.ReportImages.Where(r => r.ReportId == SingleReport.ReportId)
                                                 .OrderByDescending(d => d.DateCreated);
                foreach (var i in image)
                {
                    var rptImageModel = new ReportImageViewModel();

                    rptImageModel.ImageName        = i.ImageName;
                    rptImageModel.ImageCaption     = i.ImageCaption;
                    rptImageModel.ImageDateCreated = i.DateCreated;

                    rptImageList.Add(rptImageModel);
                }

                IQueryable <ReportVideo> video = _applicationDbContext.ReportVideos.Where(r => r.ReportId == SingleReport.ReportId)
                                                 .OrderByDescending(d => d.DateCreated);
                foreach (var v in video)
                {
                    var rptVideoModel = new ReportVideoViewModel();

                    rptVideoModel.VideoName        = v.VideoName;
                    rptVideoModel.VideoCaption     = v.VideoCaption;
                    rptVideoModel.VideoDateCreated = v.DateCreated;

                    rptVideoList.Add(rptVideoModel);
                }

                IQueryable <RipoffCaseUpdate> caseU = _applicationDbContext.RipoffCaseUpdates.Where(r => r.ApprovedLawyerRequest.LawyerRequest.ReportId == SingleReport.ReportId);
                if (caseU != null)
                {
                    foreach (var c in caseU)
                    {
                        mainModel.CaseUpdateExist = true;
                        var caseModel = new RipOffCaseUpdateViewModel();

                        caseModel.CaseUpdateText = c.UpdateText;


                        caseUpdateList.Add(caseModel);
                    }
                }
                else
                {
                    Exception ex;
                }

                IQueryable <RipOffLegalTeamAdvice> legalAdive = _applicationDbContext.RipOffLegalTeamAdvices.Where(m => m.ReportId == SingleReport.ReportId);
                if (legalAdive != null)
                {
                    foreach (var l in legalAdive)
                    {
                        var legalModel = new RipOffLegalTeamViewModel();
                        mainModel.LegalAdviceExist = true;

                        legalModel.LegalAdvice = convert.Convert(l.LegalAdvice);
                        legalModel.DateCreated = l.DateCreated;

                        legalList.Add(legalModel);
                    }
                }
                else
                {
                }

                string search = SingleReport.CompanyorIndividual;
                IQueryable <Report> reports = _applicationDbContext.Reports.Where(r => r.ReportText.ToLower().Contains(search) || r.Title.ToLower().Contains(search) || r.CompanyorIndividual.ToLower().Contains(search) || r.Website.ToLower().Contains(SingleReport.CompanyorIndividual) || r.Email.ToLower().Contains(SingleReport.CompanyorIndividual) || r.Address.ToLower().Contains(SingleReport.CompanyorIndividual))
                                              .OrderByDescending(d => d.DateCreated);

                foreach (var q in reports)
                {
                    RelatedReportedCompanyViewModel relModel = new RelatedReportedCompanyViewModel();

                    relModel.ReportText = convert.Convert(q.ReportText);
                    relModel.ReportId   = q.ReportId;

                    relatedCompanyReport.Add(relModel);
                }
            }


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

            mainModel.RebuttalViewModels               = rebuttalList;
            mainModel.ThreadViewModels                 = threadList;
            mainModel.ReportUpdateViewModels           = rptUpdateList;
            mainModel.ReportImageViewModels            = rptImageList;
            mainModel.ReportVideoViewModels            = rptVideoList;
            mainModel.CommentViewModels                = commentList;
            mainModel.RipOffLegalTeamViewModels        = legalList;
            mainModel.LegalAdviceViewModels            = updateLegalList;
            mainModel.RelatedReportedCompanyViewModels = relatedCompanyReport;

            ViewBag.PageTitle = sm_PageTitle;
            ViewBag.RandomId  = Guid.NewGuid().ToString();

            string rawUrl = this.Request.RawUrl.ToString();

            ViewBag.absoluteUrl = "https://www.ripoff.com.ng/" + rawUrl;

            return(View(mainModel));
        }