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()); }
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")); }
// 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([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")); }
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()); }
public IActionResult Index() { HttpContext.Session.SetString("SessionName", "Laiman"); var SessionName = HttpContext.Session.GetString("SessionName"); ViewBag.device = _detectionService.Device.Type; ViewBag.browser = _detectionService.Browser.Name; ViewBag.platform = _detectionService.Platform.Name; ViewBag.engine = _detectionService.Engine.Name; var visitor_ip = _accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString(); ViewBag.ip = functions.FormatVisitorIP(visitor_ip); ViewBag.country = functions.GetIpInfo("188.130.155.151", "Country"); ViewBag.session = SessionName; string product_id = "9DG52SMLA21F"; //Get current ViewedProducts session var ViewedProducts = (HttpContext.Session.GetString("ViewedProducts") != null) ? HttpContext.Session.GetString("ViewedProducts") : ""; //if not viewed already if (!functions.IsProductViewed(product_id, ViewedProducts)) { //if not null set to session data else set to empty HttpContext.Session.SetString("ViewedProducts", ViewedProducts + ",product_id_" + product_id.ToString()); ViewBag.view = "Logged View"; } else { ViewBag.view = "Not Logged"; } ViewBag.cartData = HttpContext.Session.GetString("ShoppingCart"); return(View(_detectionService)); }
public async Task <IActionResult> Details(string id) { try { //Check if string pass in not empty if (!string.IsNullOrEmpty(id)) { //if product does not exists, return home if (!_context.Products.Any(s => s.UniqueProductName == id)) { return(RedirectToAction("Index", "Home")); } //get product id from product unique name string product_id = _context.Products.Where(s => s.UniqueProductName == id).FirstOrDefault().ProductID; var productsModel = await _context.Products.FirstOrDefaultAsync(m => m.ProductID == product_id); //check if empty result if (productsModel == null) { //TODO setup Notfound page return(NotFound()); } //Get all product images ViewBag.ProductImages = _context.ProductImages.Where(s => s.ProductID == product_id).OrderBy(s => s.ID); //Get product video (if any) ViewBag.ProductVideos = _context.ProductVideos.Where(s => s.ProductID == product_id).OrderBy(s => s.ID); //Get all product colors ViewBag.ProductColors = _context.ProductColors.Where(s => s.ProductID == product_id); //Get all product sizes ViewBag.ProductSizes = _context.ProductSizes.Where(s => s.ProductID == product_id); //log product view to ProductViews table //Get current ViewedProducts session var ViewedProducts = (HttpContext.Session.GetString("ViewedProducts") != null) ? HttpContext.Session.GetString("ViewedProducts") : ""; //if not viewed already if (!functions.IsProductViewed(product_id, ViewedProducts)) { //TODO get visitor id var visitor_id = "Test-Visitor"; var visitor_ip = functions.FormatVisitorIP(_accessor.HttpContext?.Connection?.RemoteIpAddress?.ToString()); functions.LogProductView(product_id, visitor_id, visitor_ip, _detectionService.Browser.Name.ToString(), _detectionService.Device.Type.ToString(), null); //if not null set to session data else set to empty HttpContext.Session.SetString("ViewedProducts", ViewedProducts + ",product_id_" + product_id.ToString()); } //Return view with product model data return(View(productsModel)); } } catch (Exception ex) { //TODO Log error Console.WriteLine(ex); } //return home if bad parameter passed return(RedirectToAction("Index", "Home")); }
// 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")); }