示例#1
0
        public ActionResult CategoryRelatedReports(string caturl, int?pageno)
        {
            // check Where it is parent category or child Category

            ReportVM ObjReortVM = new ReportVM();

            var categoryID = db.CategoryMasters.Where(c => c.CategoryUrl == caturl).Select(c => c.CategoryId).FirstOrDefault();
            int catid      = Convert.ToInt32(categoryID);


            var parentcategory = db.CategoryMasters.Where(x => x.CategoryId == catid && x.ParentCategoryId == 0).Select(x => x.CategoryName).FirstOrDefault();

            ViewBag.CategoryName = parentcategory + " " + "Market Research Reports";

            if (!string.IsNullOrEmpty(parentcategory))
            {
                // Reports with Parent and child wised


                ObjectParameter count = new ObjectParameter("p_Count", 0);

                var RelatedReportsOfSamefamilly = (from r in db.spCategoryRelatedReport(catid, pageno ?? 1, count)
                                                   select new ReportVM
                {
                    ReportTitle = r.ReportTitle,
                    CategoryId = r.CategoryId,
                    PublishingDate = Convert.ToDateTime(r.PublishingDate),
                    ReportUrl = r.ReportUrl,
                    PriceSingleUser = r.SinglePrice,
                    FullDescription = r.LongDescription,
                    NumberOfPage = r.NumberOfPages,
                    CategoryName = r.CategoryName,
                    MetaTitle = r.MetaTitle,
                    MetaKeywords = r.Keywords,
                    MetaDescription = r.MetaDescription,
                    CategoryUrl = r.CategoryUrl,
                    ShortCatDesc = r.ShortDescription,
                    LongCatDesc = r.LongDescription,
                    PublisherName = r.PublisherName,
                    ReportImage = DDLGetparents(r.CategoryId)
                }).ToList();
                foreach (var item in RelatedReportsOfSamefamilly)
                {
                    item.ReportImage = DDLGetparents(item.CategoryId);
                }

                var catreports = (from x in RelatedReportsOfSamefamilly
                                  select new ReportVM
                {
                    ReportTitle = x.ReportTitle,
                    CategoryId = x.CategoryId,
                    PublishingDate = Convert.ToDateTime(x.PublishingDate),
                    ReportUrl = x.ReportUrl,
                    PriceSingleUser = x.PriceSingleUser,
                    FullDescription = Regex.Replace(x.FullDescription, @"<[^>]+>|&nbsp;", "").Trim(),
                    NumberOfPage = x.NumberOfPage,
                    CategoryName = x.CategoryName,
                    MetaTitle = x.MetaTitle,
                    MetaKeywords = x.MetaKeywords,
                    MetaDescription = x.MetaDescription,
                    CategoryUrl = x.CategoryUrl,
                    ShortCatDesc = x.ShortCatDesc,
                    LongCatDesc = x.LongCatDesc,
                    PublisherId = x.PublisherId,
                    PublisherName = x.PublisherName,
                    ReportImage = x.ReportImage
                }).ToList();

                var reports = new StaticPagedList <ReportVM>(catreports, pageno ?? 1, 10, Convert.ToInt32(count.Value));

                ObjReortVM = (from c in db.CategoryMasters
                              where c.CategoryId == catid
                              select new ReportVM
                {
                    ShortCatDesc = c.ShortDescription,
                    LongCatDesc = c.LongDescription
                }).FirstOrDefault();
                //ViewBag.Totalreports = Convert.ToInt32(count.Value);
                ViewBag.ShortDesc   = ObjReortVM.ShortCatDesc;
                ViewBag.LongDesc    = ObjReortVM.LongCatDesc;
                ViewBag.Title       = parentcategory + " Market Research Report and Industry Analysis Market Research Report and Industry Analysis & Forecast - Market Research Trade";
                ViewBag.Description = "";
                ViewBag.Keywords    = "";
                return(View(reports));
            }
            else
            {
                // Only CategoryWised Reports
                var childCatName = db.CategoryMasters.Where(x => x.CategoryId == catid).Select(x => x.CategoryName).FirstOrDefault();
                ViewBag.CategoryName = childCatName + " " + "Market Research Reports";
                var Relatedreports = (from r in db.ReportMasters
                                      join c in db.CategoryMasters on r.CategoryId equals c.CategoryId
                                      join p in db.PublisherMasters on r.PublishereId equals p.PublisherId
                                      where c.CategoryId == catid
                                      orderby r.CreatedDate descending
                                      select new ReportVM
                {
                    ReportTitle = r.ReportTitle,
                    ReportUrl = r.ReportUrl,
                    CategoryId = r.CategoryId,
                    CategoryName = c.CategoryName,
                    ShortCatDesc = c.ShortDescription,
                    LongCatDesc = c.LongDescription,
                    PublisherName = p.ContactName,
                    FullDescription = r.LongDescritpion.Substring(0, 300),
                    PublishingDate = r.PublishingDate,
                    PublisherId = r.PublishereId,
                    CategoryUrl = c.CategoryUrl,
                    PublishingUrl = p.publisherUrl
                }).ToList();

                foreach (var item in Relatedreports)
                {
                    item.ReportImage = DDLGetparents(item.CategoryId);
                }

                var reports = (from x in Relatedreports
                               select new ReportVM
                {
                    ReportTitle = x.ReportTitle,
                    ReportUrl = x.ReportUrl,
                    CategoryId = x.CategoryId,
                    CategoryName = x.CategoryName,
                    ShortCatDesc = x.ShortCatDesc,
                    LongCatDesc = x.LongCatDesc,
                    FullDescription = Regex.Replace(x.FullDescription, @"<[^>]+>|&nbsp;", "").Trim(),
                    PublishingDate = x.PublishingDate,
                    PublisherId = x.PublisherId,
                    PublisherName = x.PublisherName,
                    CategoryUrl = x.CategoryUrl,
                    PublishingUrl = x.PublishingUrl
                }).ToPagedList(pageno ?? 1, 10);

                //ObjectParameter count = new ObjectParameter("p_Count", 0);

                //var RelatedReportsOfSamefamilly = (from r in db.ChildCategoryRelatedReport(catid, pageno ?? 1, count).ToList()
                //                                   select new ReportVM
                //                                   {
                //                                       ReportTitle = r.ReportTitle,
                //                                       CategoryId = r.CategoryId,
                //                                       PublishingDate = Convert.ToDateTime(r.PublishingDate),
                //                                       ReportUrl = r.ReportUrl,
                //                                       PriceSingleUser = r.PriceSingleUser,
                //                                       FullDescription = r.FullDescription,
                //                                       NumberOfPage = r.NumberOfPage,
                //                                       CategoryName = r.CategoryName,
                //                                       MetaTitle = r.MetaTitle,
                //                                       MetaKeywords = r.MetaKeywords,
                //                                       MetaDescription = r.MetaDescription,
                //                                       CategoryUrl = r.CategoryUrl,
                //                                       ShortCatDesc = r.ShortDescription,
                //                                       LongCatDesc = r.LongDescription,
                //                                       PublisherId = r.PublisherId,
                //                                       PublisherName = r.CompanyName
                //                                   }).ToList();

                //var catreports = (from x in RelatedReportsOfSamefamilly
                //                  select new ReportVM
                //                  {
                //                      ReportTitle = x.ReportTitle,
                //                      CategoryId = x.CategoryId,
                //                      PublishingDate = Convert.ToDateTime(x.PublishingDate),
                //                      ReportUrl = x.ReportUrl,
                //                      PriceSingleUser = x.PriceSingleUser,
                //                      FullDescription = Regex.Replace(x.FullDescription, @"<[^>]+>|&nbsp;", "").Trim(),
                //                      NumberOfPage = x.NumberOfPage,
                //                      CategoryName = x.CategoryName,
                //                      MetaTitle = x.MetaTitle,
                //                      MetaKeywords = x.MetaKeywords,
                //                      MetaDescription = x.MetaDescription,
                //                      CategoryUrl = x.CategoryUrl,
                //                      ShortCatDesc = x.ShortCatDesc,
                //                      LongCatDesc = x.LongCatDesc,
                //                      PublisherId = x.PublisherId,
                //                      PublisherName = x.PublisherName
                //                  }).ToList();

                //var reports = new StaticPagedList<ReportVM>(catreports, pageno ?? 1, 10, Convert.ToInt32(count.Value));
                ViewBag.Title       = ViewBag.CategoryName + " Market Research Report and Industry Analysis & Forecast - Market Research Trade";
                ViewBag.Description = "";
                ViewBag.Keywords    = "";
                return(View(reports));
            }
        }