コード例 #1
0
        // GET: Latest News Data
        public IActionResult Index([FromQuery(Name = "p")] string p = "1", [FromQuery(Name = "s")] string s = "10")
        {
            try
            {
                //set default pagination values
                ViewBag.PageNo   = 1;
                ViewBag.PageSize = 10;
                if (!string.IsNullOrEmpty(p) && !string.IsNullOrEmpty(s))
                {
                    ViewBag.PageNo   = Int32.Parse(p);
                    ViewBag.PageSize = Int32.Parse(s);
                }

                ViewBag.PageSkip = (ViewBag.PageNo - 1) * ViewBag.PageSize;
                int      PageSkip            = ViewBag.PageSkip;
                int      PageSize            = ViewBag.PageSize;
                DateTime LatestNewsDateRange = DateTime.Now.AddDays(-1);
                ViewBag.TotalRecords = _context.vwPostsApproved.Where(s => s.ApprovalsDateAdded > LatestNewsDateRange).Count();
                if (ViewBag.TotalRecords == 0)
                {
                    //go back further
                    LatestNewsDateRange  = DateTime.Now.AddDays(-5);
                    ViewBag.TotalRecords = _context.vwPostsApproved.Where(s => s.ApprovalsDateAdded > LatestNewsDateRange).Count();
                }

                var CategoryData = _context.vwPostsApproved.Where(s => s.ApprovalsDateAdded > LatestNewsDateRange).OrderByDescending(s => s.ApprovalsDateAdded).Skip(PageSkip).Take(PageSize).ToList();

                string VisitorIP = functions.FormatVisitorIP(_sessionManager.SessionIP, _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString());

                string OtherInfo = null; //add any other info here

                if (_systemConfiguration.logSearches)
                {
                    //log search
                    string StatType    = "LatestNews";
                    string ActionValue = "Latest News";
                    functions.LogSiteStat(StatType, ActionValue, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), OtherInfo);
                }

                //log visit
                string LogName = "LatestNews";
                functions.VisitLog(_systemConfiguration.visitLogTypes.Split(",")[2], LogName, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo);

                //Set Meta SEO
                ViewData["ContentDescription"] = functions.GetSiteLookupData("MetaDescription");
                ViewData["ContentKeywords"]    = functions.GetSiteLookupData("MetaKeywords");
                ViewBag.Title = "Latest News, " + functions.GetSiteLookupData("MetaTitle");

                return(View(CategoryData));
            }
            catch (Exception ex)
            {
                //Log Error
                _logger.LogInformation("Get Latest News Error: " + ex.ToString());
                TempData["ErrorMessage"] = "There was an error processing your request. Please try again. If this error persists, please send an email.";
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #2
0
        public IActionResult Index()
        {
            ViewData["ContentDescription"] = functions.GetSiteLookupData("MetaDescription");
            ViewData["ContentKeywords"]    = functions.GetSiteLookupData("MetaKeywords");
            ViewBag.CategoriesData         = _context.Categories.Where(s => s.IsPublished == 1).OrderBy(s => s.CategoryName);

            return(View());
        }
コード例 #3
0
        public IActionResult E404()
        {
            // Set Meta Data
            ViewData["Title"]              = "Page Not Found";
            ViewData["ContentKeywords"]    = functions.GetSiteLookupData("MetaKeywords");
            ViewData["ContentDescription"] = functions.GetSiteLookupData("MetaDescription");

            return(View());
        }
コード例 #4
0
ファイル: DonateController.cs プロジェクト: akassama/net-news
        public IActionResult Index()
        {
            if (!_systemConfiguration.showDonateLink)
            {
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.ShowDonate = (_systemConfiguration.showDonateLink) ? "true" : "false";

            //Set Meta SEO
            ViewData["ContentDescription"] = functions.GetSiteLookupData("SiteName") + "Donate Page";
            ViewData["ContentKeywords"]    = functions.GetSiteLookupData("MetaKeywords");

            return(View());
        }
コード例 #5
0
ファイル: RadioController.cs プロジェクト: akassama/net-news
        public IActionResult Index()
        {
            //log visit
            string VisitorIP = functions.FormatVisitorIP(_sessionManager.SessionIP, _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString());
            string OtherInfo = null; //add any other info here
            string PageName  = "Radio Stations";

            functions.VisitLog(_systemConfiguration.visitLogTypes.Split(",")[2], PageName, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo);

            ViewData["Title"] = "Radio Stations";
            ViewData["ContentDescription"] = functions.GetSiteLookupData("SiteName");
            ViewData["ContentKeywords"]    = functions.GetSiteLookupData("MetaKeywords");

            return(View());
        }
コード例 #6
0
        public IActionResult Index()
        {
            try
            {
                //log visit
                string VisitorIP    = functions.FormatVisitorIP(_sessionManager.SessionIP, _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString());
                string OtherInfo    = null; //add any other info here
                string CategoryName = "All Categories";
                functions.VisitLog(_systemConfiguration.visitLogTypes.Split(",")[2], CategoryName, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo);

                ViewData["Title"] = CategoryName;
                ViewData["ContentDescription"] = functions.GetSiteLookupData("SiteName") + " " + CategoryName;
                ViewData["ContentKeywords"]    = CategoryName;

                var data = _context.Categories.OrderBy(s => s.CategoryOrder);

                return(View(data));
            }
            catch (Exception ex)
            {
                //Log Error
                _logger.LogInformation("Get All Categories Error: " + ex.ToString());
                TempData["ErrorMessage"] = "There was an error processing your request. Please try again. If this error persists, please send an email.";
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #7
0
ファイル: SearchController.cs プロジェクト: akassama/net-news
        public IActionResult Index([FromQuery(Name = "p")] string p = "1", [FromQuery(Name = "s")] string s = "10", [FromQuery(Name = "q")] string q = null)
        {
            if (string.IsNullOrEmpty(q) || q == "Index")
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (q.Length < 2)
            {
                TempData["ErrorMessage"] = "Query too short...";
                return(RedirectToAction("Index", "Home"));
            }

            try
            {
                ViewBag.SearchValue = q;

                //set default pagination values
                ViewBag.PageNo   = 1;
                ViewBag.PageSize = 10;
                if (!string.IsNullOrEmpty(p) && !string.IsNullOrEmpty(s))
                {
                    ViewBag.PageNo   = Int32.Parse(p);
                    ViewBag.PageSize = Int32.Parse(s);
                }

                ViewBag.PageSkip = (ViewBag.PageNo - 1) * ViewBag.PageSize;
                int PageSkip = ViewBag.PageSkip;
                int PageSize = ViewBag.PageSize;
                ViewBag.TotalRecords = _context.vwPostsApproved.Where(s => s.PostTitle.Contains(q) || s.PostExtract.Contains(q) || s.PostContent.Contains(q) || s.PostTags.Contains(q)).Count();

                var SearchData = _context.vwPostsApproved.Where(s => s.PostTitle.Contains(q) || s.PostExtract.Contains(q) || s.PostContent.Contains(q) || s.PostTags.Contains(q)).OrderByDescending(s => s.ApprovalsDateAdded).Skip(PageSkip).Take(PageSize).ToList();

                if (_systemConfiguration.logSearches)
                {
                    //log search
                    string StatType    = "Search";
                    string ActionValue = q;
                    string VisitorIP   = functions.FormatVisitorIP(_sessionManager.SessionIP, _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString());
                    string OtherInfo   = null; //add any other info here
                    functions.LogSiteStat(StatType, ActionValue, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), OtherInfo);
                }

                //Set Meta SEO
                ViewData["Title"] = "Search results for " + q;
                ViewData["ContentDescription"] = "Search results for " + q;
                ViewData["ContentKeywords"]    = q + "," + functions.GetSiteLookupData("MetaKeywords");

                return(View(SearchData));
            }
            catch (Exception ex)
            {
                //Log Error
                _logger.LogInformation("Get Search Details Error: " + ex.ToString());
                TempData["ErrorMessage"] = "There was an error processing your request. Please try again. If this error persists, please send an email.";
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #8
0
        public IActionResult Index([FromQuery(Name = "subject")] string subject)
        {
            ViewBag.Subject = subject;

            //log visit
            string VisitorIP = functions.FormatVisitorIP(_sessionManager.SessionIP, _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString());
            string OtherInfo = null; //add any other info here

            functions.VisitLog(_systemConfiguration.visitLogTypes.Split(",")[3], null, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo);

            //Set Meta SEO
            ViewData["Title"] = functions.GetSiteLookupData("SiteName") + "Contact Us";
            ViewData["ContentDescription"] = functions.GetSiteLookupData("SiteName") + "Contact Us Page";
            ViewData["ContentKeywords"]    = functions.GetSiteLookupData("MetaKeywords");

            return(View());
        }
コード例 #9
0
ファイル: HomeController.cs プロジェクト: akassama/net-news
        public IActionResult Index()
        {
            ViewBag.ShowDonate            = (_systemConfiguration.showDonateLink) ? "true" : "false";
            ViewBag.TotalVideoGallery     = _context.vwPostsApproved.Count(s => s.PostType == "Gallery" || s.PostType == "Video");
            ViewBag.MorePosts             = _context.vwPostsApproved.Skip(12).Count();
            ViewBag.WebsiteName           = functions.GetSiteLookupData("SiteName");
            ViewBag.WeatherWidgetLink     = _systemConfiguration.weatherLocationUrl;
            ViewBag.WeatherWidgetLocation = _systemConfiguration.weatherLocationText;
            ViewBag.ForexWidgetLink       = _systemConfiguration.forexWidgetUrl;
            ViewBag.CovidWidgetClassId    = _systemConfiguration.covidWidgetClassId;

            ViewData["ContentDescription"] = functions.GetSiteLookupData("MetaDescription");
            ViewData["ContentKeywords"]    = functions.GetSiteLookupData("MetaKeywords");
            ViewBag.Title = functions.GetSiteLookupData("MetaTitle");

            ViewBag.IsHome = "True";

            //log visit
            string VisitorIP = functions.FormatVisitorIP(_sessionManager.SessionIP, _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString());
            string OtherInfo = null; //add any other info here

            functions.VisitLog(_systemConfiguration.visitLogTypes.Split(",")[0], null, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo);

            return(View());
        }
コード例 #10
0
        public IActionResult Index()
        {
            //if already logged in, redirect home
            if (_sessionManager.IsLoggedIn)
            {
                return(RedirectToAction("Index", "Admin"));
            }

            //log visit
            string VisitorIP = functions.FormatVisitorIP(_sessionManager.SessionIP, _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString());
            string OtherInfo = null; //add any other info here

            functions.VisitLog(_systemConfiguration.visitLogTypes.Split(",")[8], null, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo);

            // Set Meta Data
            ViewData["Title"]              = "Sign In";
            ViewData["ContentKeywords"]    = functions.GetSiteLookupData("MetaKeywords");
            ViewData["ContentDescription"] = functions.GetSiteLookupData("MetaDescription");
            ViewData["PostAuthor"]         = "";

            return(View());
        }
コード例 #11
0
        //GET: PasswordReset/Index/id
        public IActionResult Index([FromQuery(Name = "id")] string id)
        {
            ViewBag.ShowForm  = "false";
            ViewData["Title"] = "Reset Password";
            try
            {
                //if query string is empty
                if (string.IsNullOrEmpty(id))
                {
                    TempData["ErrorMessage"] = "Bad url parameter";
                    return(View());
                }

                //if no id available in reset table
                if (_context.PasswordForgot.Any(s => s.ResetID == id))
                {
                    DateTime CurrentDate = DateTime.Now;
                    DateTime ResetDate   = Convert.ToDateTime(_context.PasswordForgot.Where(s => s.ResetID == id).FirstOrDefault().ResetDate);
                    double   Difference  = (CurrentDate - ResetDate).TotalDays;

                    //return reset password view
                    if (Difference < 1)
                    {
                        ViewBag.ShowForm = "true";
                        ViewBag.ResetID  = id;
                        return(View());
                    }
                    else
                    {
                        TempData["ErrorMessage"] = "Reset link has expired";
                        return(View());
                    }
                }
                else
                {
                    TempData["ErrorMessage"] = "Invalid url id";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                //Log Error
                _logger.LogInformation("Password Reset Error: " + ex.ToString());
                TempData["ErrorMessage"] = "There was an error processing your request. Please try again. If this error persists, please send an email to " + functions.GetSiteLookupData("SupportEmail");
                return(RedirectToAction("Index", "Home"));
            }
        }
コード例 #12
0
        // GET: Category Data
        public async Task <IActionResult> Index(string id, [FromQuery(Name = "p")] string p = "1", [FromQuery(Name = "s")] string s = "10")
        {
            if (string.IsNullOrEmpty(id) || id == "Index")
            {
                return(RedirectToAction("Index", "Home"));
            }

            try
            {
                ViewBag.Category = id;
                string ShortCategoryName = functions.ConvertCase(id, "TitleTrim");
                var    DBQuery           = _context.Categories.Where(s => s.ShortCategoryName == ShortCategoryName);
                //if category not found
                if (!DBQuery.Any())
                {
                    TempData["ErrorMessage"] = "Category not found";
                    return(RedirectToAction("Index", "Home"));
                }
                string CategoryID = DBQuery.FirstOrDefault().CategoryID;
                ViewBag.CategoryID = CategoryID;

                //set default pagination values
                ViewBag.PageNo   = 1;
                ViewBag.PageSize = 10;
                if (!string.IsNullOrEmpty(p) && !string.IsNullOrEmpty(s))
                {
                    ViewBag.PageNo   = Int32.Parse(p);
                    ViewBag.PageSize = Int32.Parse(s);
                }

                ViewBag.PageSkip = (ViewBag.PageNo - 1) * ViewBag.PageSize;
                int PageSkip = ViewBag.PageSkip;
                int PageSize = ViewBag.PageSize;
                ViewBag.TotalRecords = _context.vwPostsApproved.Where(s => s.PostCategory == CategoryID).Count();

                var CategoryData = _context.vwPostsApproved.Where(s => s.PostCategory == CategoryID).OrderByDescending(s => s.ApprovalsDateAdded).Skip(PageSkip).Take(PageSize).ToListAsync();

                string VisitorIP = functions.FormatVisitorIP(_sessionManager.SessionIP, _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString());
                string OtherInfo = null; //add any other info here

                if (_systemConfiguration.logSearches)
                {
                    //log category
                    string StatType    = "Category";
                    string ActionValue = CategoryID;
                    functions.LogSiteStat(StatType, ActionValue, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), OtherInfo);
                }

                //log visit
                string CategoryName = _context.Categories.Where(s => s.CategoryID == CategoryID).FirstOrDefault().CategoryName;
                functions.VisitLog(_systemConfiguration.visitLogTypes.Split(",")[2], CategoryName, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo);

                ViewData["Title"] = functions.ConvertCase(id, "SplitUpper");
                ViewData["ContentDescription"] = functions.GetSiteLookupData("SiteName") + " " + id + " Category";
                ViewData["ContentKeywords"]    = id;

                return(View(await CategoryData));
            }
            catch (Exception ex)
            {
                //Log Error
                _logger.LogInformation("Get Category Error: " + ex.ToString());
                TempData["ErrorMessage"] = "There was an error processing your request. Please try again. If this error persists, please send an email.";
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #13
0
        public IActionResult Index(string id)
        {
            if (string.IsNullOrEmpty(id) || id == "Index")
            {
                return(RedirectToAction("Index", "Home"));
            }

            try
            {
                var postModel = _context.vwPostsApproved
                                .FirstOrDefault(m => m.PostPermalink == id);
                if (postModel == null)
                {
                    //check if PostPermalink contained in another PostPermalink
                    if (_context.vwPostsApproved.Any(s => s.PostPermalink.Contains(id)))
                    {
                        string PostPermalink = _context.vwPostsApproved.Where(s => s.PostPermalink.Contains(id)).OrderByDescending(s => s.ApprovalsDateAdded).FirstOrDefault().PostPermalink;
                        return(RedirectToAction("Index", "Posts", new { id = PostPermalink }));
                    }

                    //check if PostPermalink trimmed contained in another PostPermalink
                    id = id.Substring(0, id.Length - 10); //remove last 10 characters
                    if (_context.vwPostsApproved.Any(s => s.PostPermalink.Contains(id)))
                    {
                        string PostPermalink = _context.vwPostsApproved.Where(s => s.PostPermalink.Contains(id)).OrderByDescending(s => s.ApprovalsDateAdded).FirstOrDefault().PostPermalink;
                        return(RedirectToAction("Index", "Posts", new { id = PostPermalink }));
                    }
                    return(NotFound());
                }

                if (Convert.ToBoolean(functions.GetSiteLookupData("EnableFaceBookComments")))
                {
                    ViewData["FacebookCommentId"] = functions.GetSiteLookupData("FacebookCommentAppId");
                }

                ViewBag.FaceBookComments = Convert.ToBoolean(functions.GetSiteLookupData("EnableFaceBookComments"));

                string PostID = _context.vwPostsApproved.Where(s => s.PostPermalink == id).FirstOrDefault().PostID;
                ViewBag.PostID = PostID;
                string PostTitle  = _context.vwPostsApproved.Where(s => s.PostPermalink == id).FirstOrDefault().PostTitle;
                string PostAuthor = _context.vwPostsApproved.Where(s => s.PostPermalink == id).FirstOrDefault().PostAuthor;
                string PostType   = _context.vwPostsApproved.Where(s => s.PostPermalink == id).FirstOrDefault().PostType;
                string VisitorIP  = functions.FormatVisitorIP(_sessionManager.SessionIP, _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString());
                string OtherInfo  = null; //add any other info here

                //log post view
                functions.LogPostView(PostID, PostAuthor, PostType, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), OtherInfo);

                //log visit
                functions.VisitLog(_systemConfiguration.visitLogTypes.Split(",")[1], PostTitle, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo);

                //get ShareThis url
                ViewBag.ShareThisUrl = functions.GetSiteLookupData("ShareThisUrl");

                ViewBag.ConnectionString = _systemConfiguration.connectionString;

                ViewData["Title"]              = PostTitle;
                ViewData["ContentKeywords"]    = postModel.MetaKeywords;
                ViewData["ContentDescription"] = PostTitle;
                ViewData["PostAuthor"]         = PostAuthor;

                //Set properties
                ViewData["PropertyDescription"] = "By " + functions.GetAccountData(PostAuthor, "FullName") + ", " + functions.FormatLongText(PostTitle, 120);
                ViewData["PropertySection"]     = _context.Categories.Where(s => s.CategoryID == postModel.PostCategory).FirstOrDefault().CategoryName;
                ViewData["PropertyUpdatedTime"] = postModel.UpdateDate;

                return(View(postModel));
            }
            catch (Exception ex)
            {
                //Log Error
                _logger.LogInformation("Get Post Details Error: " + ex.ToString());
                TempData["ErrorMessage"] = "There was an error processing your request. Please try again. If this error persists, please send an email.";
            }

            return(RedirectToAction("Index", "Home"));
        }