public IActionResult Index(string id) { DateTime TodaysDate = DateTime.Now; try { var data = _context.Adverts.Where(s => s.ExpiryDate >= TodaysDate).OrderByDescending(x => Guid.NewGuid()).Take(1);//get random advert if (!string.IsNullOrEmpty(id)) { data = _context.Adverts.Where(s => s.AdvertPermalink == id); } //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(",")[4], null, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo); return(View(data)); } catch (Exception ex) { //Log Error _logger.LogInformation("Get Adverts 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")); }
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")); }
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()); }
// 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")); }
public IActionResult Index() { DateTime TodaysDate = DateTime.Now; var data = _context.Jobs.Where(s => s.ExpiryDate >= TodaysDate); //Set Meta SEO ViewData["ContentDescription"] = "Find jobs in The Gambia"; ViewData["ContentKeywords"] = "Jobs, Gambia Jobs, Find jobs in Gambia, Employment, Employment in Gambia"; //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(",")[6], null, VisitorIP, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null, OtherInfo); return(View(data)); }
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()); }
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()); }
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()); }
// 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")); }
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")); }