public ActionResult NewsDetails(string html) { int categoryRowId = 0; Category cat = new Category(); ArticleModel model = new ArticleModel(); using (var db = new DIYFE.EF.DIYFEEntities()) { model.Article = db.Articles.Include("ArticleComments").Where(a => a.URLLink == html + ".html").FirstOrDefault(); } if (model.Article == null) { cat = DIYFEHelper.GetCatigroy(model.Article.CategoryRowId); model.Article = new DIYFE.EF.Article(); model.Comments = new List<DIYFE.EF.ArticleComment>(); //model.Article.ArticleComments = new List<ArticleComment>(); } else { DIYFELib.Tracking.InsertArticleViewRequest(model.Article.ArticleId); } // model.Comments = la.ArticleComments(model.Article.ArticleId); //model.MostViewed = la.MostViewed(11, 20); // model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(categoryRowId, linkPrefix); model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(cat, linkPrefix); ////PageModel.Title = model.Article.Title; ////PageModel.Description = model.Article.Description; ////PageModel.Author = model.Article.Author; ////PageModel.Keywords = model.Article.Keywords; return View(model); }
protected override void OnResultExecuting(ResultExecutingContext ctx) { base.OnResultExecuting(ctx); string _ipAddress; string _sessionId; _ipAddress = ctx.HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (string.IsNullOrEmpty(_ipAddress)) { _ipAddress = ctx.HttpContext.Request.ServerVariables["REMOTE_ADDR"]; } if (Request.Cookies["sessionKey"] != null) { _sessionId = Request.Cookies["sessionKey"].Value; } else { Response.Cookies.Add(new System.Web.HttpCookie("sessionKey", ctx.HttpContext.Session.SessionID)); Response.Cookies["sessionKey"].Expires = DateTime.Now.AddHours(12); _sessionId = ctx.HttpContext.Session.SessionID; } Tracking track = new Tracking(); track.IP = _ipAddress; track.Session = _sessionId; track.URL = ctx.HttpContext.Request.Url.PathAndQuery; track.CreatedDate = DateTime.Now; using (var db = new DIYFE.EF.DIYFEEntities()) { db.Trackings.Add(track); db.SaveChanges(); } ViewBag.PageModel = PageModel; }
public ActionResult Index(int? page) { ArticleListModel model = new ArticleListModel(); PageModel.Title = ""; PageModel.Description = ""; PageModel.Author = ""; PageModel.Keywords = ""; //ListAccess la = new ListAccess(); //model.MostViewed = la.MostViewed(11, 20); string url = HttpContext.Request.RawUrl; //int catigoryRowId = DIYFEHelper.GetCatigoryRowId(url); //model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(catigoryRowId, linkPrefix); using (var db = new DIYFE.EF.DIYFEEntities()) { // model.ProjectList = db.Articles.Where(a => a.ArticleTypeId == 2).OrderBy(a => a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).ToList(); //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 4).OrderBy(a => a.CreatedDate).ToList(); model.PagedArticle = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 4).OrderBy(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); } //model.ArticleList = la.ArticleList(catigoryId, 1); return View(model); }
public ActionResult FirstLevCategoryList(string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, int? page) { ProjectListModel model = new ProjectListModel(); //model.MostViewed = la.MostViewed(11, 20); //model.CrumbLinkList = new List<CustomHtmlLink>(); //AppStatic.Categories.Where(c => c.CategoryUrl == categoryUrl); PageModel.Title = ""; PageModel.Description = ""; PageModel.Author = ""; PageModel.Keywords = ""; string url = HttpContext.Request.RawUrl; Category cat = DIYFEHelper.GetCatigory(categoryUrl, subCategoryUrl, subSubCategoryUrl); //int categoryRowId = DIYFEHelper.GetCatigoryRowId(categoryUrl, "", ""); model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(cat, linkPrefix); model.RelatedTreeView = DIYFEHelper.GenerateRelatedTreeView(cat, linkPrefix); using (var db = new DIYFE.EF.DIYFEEntities()) { model.PagedArticle = db.Articles.Include("ArticleComments") .Include("ArticleStatus.StatusType") .Where(a => a.ArticleTypeId == 2 && a.Category.CategoryId == cat.CategoryId) .OrderBy(a => a.ArticleStatus.Any(aStat => aStat.StatusId == 1)) .ToPagedList(page ?? 1, pageSize); } return View(model); }
public ActionResult AddArticle(Article article) { var data = new object(); article.CreatedDate = DateTime.Now; article.UpdateDate = DateTime.Now; try { using (var db = new DIYFE.EF.DIYFEEntities()) { db.Articles.Add(article); db.SaveChanges(); } StaticConfig.LoadStaticCache(); data = new { success = true }; } catch (Exception ex) { if (ex.InnerException.Message != null) { data = new { success = false, message = ex.InnerException.Message }; } else { data = new { success = false, message = ex.Message + " Another reason why EF sucks" }; } return Json(data); } return Json(data); }
public ActionResult ArticleDetails(string articleType, string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, string articleName) { int categoryRowId = 0; ArticleModel model = new ArticleModel(); Category cat = new Category(); using (var db = new DIYFE.EF.DIYFEEntities()) { model.Article = db.Articles.Include("ArticleComments").Where(a => a.URLLink == articleName + ".html").FirstOrDefault(); model.Article.ViewRequests++; db.Entry(model.Article).State = System.Data.EntityState.Modified; db.SaveChanges(); } if (model.Article != null) { cat = StaticConfig.GetCatigroy(model.Article.CategoryRowId); model.CrumbLinkList = StaticConfig.GenerateCrumbLinks(cat, articleType); model.RelatedTreeView = StaticConfig.GenerateRelatedTreeView(cat, articleType); PageModel.Title = model.Article.Title; PageModel.Description = model.Article.Description; PageModel.Author = model.Article.Author; PageModel.Keywords = model.Article.Keywords; } else { //JUST TO GET BY -- REPLACE WITH 404 SOULATION model.CrumbLinkList = StaticConfig.GenerateCrumbLinks(new Category(), articleType); model.Article = new Article(); model.Comments = new List<ArticleComment>(); //model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(model.Article.CategoryRowId, linkPrefix); PageModel.Title = ""; PageModel.Description = ""; PageModel.Author = ""; PageModel.Keywords = ""; } // model.Comments = la.ArticleComments(model.Article.ArticleId); //model.MostViewed = la.MostViewed(11, 20); // model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(categoryRowId, linkPrefix); model.RelatedTreeView = StaticConfig.GenerateTreeViewThirdLev(cat, articleType); ////PageModel.Title = model.Article.Title; ////PageModel.Description = model.Article.Description; ////PageModel.Author = model.Article.Author; ////PageModel.Keywords = model.Article.Keywords; return View(model); }
public ActionResult Index(int? projectStatus, int? page) { ProjectListModel model = new ProjectListModel(); PageModel.Title = ""; PageModel.Description = ""; PageModel.Author = ""; PageModel.Keywords = ""; //ListAccess la = new ListAccess(); //NOTE: THIS QUERY IS TAKING FOREVER FOR SOME REASON //model.MostViewed = la.MostViewed(11, 20); //model.MostViewed = new List<CustomHtmlLink>(); //string url = HttpContext.Request.RawUrl; //int catigoryRowId = DIYFEHelper.GetCatigoryRowId(url); //model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(catigoryRowId, linkPrefix); using (var db = new DIYFE.EF.DIYFEEntities()) { model.PagedArticle = db.Articles .Include("ArticleComments") .Include("ArticleStatus.StatusType") .Where(a => a.ArticleTypeId == 2) .OrderBy(a => a.ArticleStatus.Any(aStat => aStat.StatusId == 1)) .ToPagedList(page ?? 1, pageSize); } if (projectStatus != null) { using (var db = new DIYFE.EF.DIYFEEntities()) { model.PagedArticle = db.Articles .Include("ArticleComments") .Include("ArticleStatus.StatusType") .Where(a => a.ArticleTypeId == 2 && a.ArticleStatus.Any(aStat => aStat.StatusId == projectStatus)) .OrderByDescending(a => a.CreatedDate) .ToPagedList(page ?? 1, pageSize); } //List<DIYFE.EF.Article> tempList = model.ProjectList.ToList(); //model.ProjectList = tempList.Where(a => a.ArticleStatus.Any(arts => arts.StatusId == projectStatus)).ToList(); //model.ProjectList.Concat(tempList.Where(a => !model.ProjectList.Contains(a))); } //model.ArticleList = la.ArticleList(catigoryId, 1); return View(model); }
public ActionResult WeeklyMenu() { PageModel.Title = "Contact About Boostrap Project"; PageModel.Description = "Bootstrap Template Project"; PageModel.Author = "Bootstrap"; PageModel.Keywords = "Boostrap project, starter project, soe keywords, keywords"; PageModel.ActiveTopNavLink = "MainNavContact"; WeeklyMenu Model = new WeeklyMenu(); using (var db = new DIYFE.EF.DIYFEEntities()) { Model.ShoppingList = db.IngredientShoppings.ToList(); Model.DailyRecipes = db.DailyRecipes.ToList(); Model.SeasonalRecipes = db.SeasonalRecipes.ToList(); } return(View(Model)); }
public ActionResult SendContactEmail(ContactMailModel model) { var data = new object(); try { var email = EmailMessageFactory.GetContactEmail(model); var result = EmailClient.SendEmail(email); if (!String.IsNullOrEmpty(model.NewsLetter)) { try { NewsLetter letter = new NewsLetter() { Email = model.Email, DateCreated = DateTime.Now }; using (var db = new DIYFE.EF.DIYFEEntities()) { db.NewsLetters.Add(letter); db.SaveChanges(); } } catch (Exception ex) { data = new { success = false, message = "Message Was Sent...but failed to join news letter." }; return(Json(data)); } } } catch (Exception ex) { data = new { success = false, message = "Failed to send comment. Please trying contacting us directly." }; return(Json(data)); } data = new { success = true }; return(Json(data)); }
public ActionResult AddCategory(DIYFE.EF.Category category) { var data = new object(); using (var db = new DIYFE.EF.DIYFEEntities()) { if (category.ThirdLevCategoryId == 0 && category.SecondLevCategoryId != 0) { category.ThirdLevCategoryId = db.Categories.Max(c => c.ThirdLevCategoryId).Value; } if (category.SecondLevCategoryId == 0) { category.SecondLevCategoryId = db.Categories.Max(c => c.SecondLevCategoryId).Value; } if (category.CategoryId == 0) { category.CategoryId = db.Categories.Max(c => c.CategoryId); } db.Categories.Add(category); db.SaveChanges(); data = new { success = true }; //allCats = db.Categories.ToList(); } AppStatic.LoadStaticCache(); //Category cat = new Category(); //if (cat.InsertCategory(category)) //{ // AppStatic.LoadStaticCache(); // data = new { success = true }; //} //else //{ // data = new { success = false, message = "Failed to insert new category." }; // return Json(data); //} return(Json(data)); }
public ActionResult AddCategory(DIYFE.EF.Category category) { var data = new object(); using (var db = new DIYFE.EF.DIYFEEntities()) { if (category.ThirdLevCategoryId == 0 && category.SecondLevCategoryId != 0) { category.ThirdLevCategoryId = db.Categories.Max(c => c.ThirdLevCategoryId).Value; } if (category.SecondLevCategoryId == 0) { category.SecondLevCategoryId = db.Categories.Max(c => c.SecondLevCategoryId).Value; } if (category.CategoryId == 0) { category.CategoryId = db.Categories.Max(c => c.CategoryId); } db.Categories.Add(category); db.SaveChanges(); data = new { success = true }; //allCats = db.Categories.ToList(); } AppStatic.LoadStaticCache(); //Category cat = new Category(); //if (cat.InsertCategory(category)) //{ // AppStatic.LoadStaticCache(); // data = new { success = true }; //} //else //{ // data = new { success = false, message = "Failed to insert new category." }; // return Json(data); //} return Json(data); }
public ActionResult Index() { ArticleListModel model = new ArticleListModel(); using (var db = new DIYFE.EF.DIYFEEntities()) { // model.ProjectList = db.Articles.Include("ArticleStatus").OrderBy(a => a.UpdateDate).Take(5).ToList(); //Projects needing funding model.ArticleList = db.Articles.Include("ArticleStatus").ToList(); //model.ProjectList = db.Articles.Include("ArticleStatus").Where(a => a.ArticleStatus.Any(arts => arts.StatusId == 4)).Take(5).ToList(); ////Projects recently updated //model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 2).OrderBy(a => a.UpdateDate).Take(5).ToList()); ////Post recently added //model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 1).OrderBy(a => a.CreatedDate).Take(5).ToList()); ////News recently added //model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 4).OrderBy(a => a.CreatedDate).Take(5).ToList()); ////model.ProjectList = db.Articles.Include() ////var articles = db.Articles.Where(a => a.ArticleTypeId == 2 && a.ArticleStatus.Any(ar => ar.StatusId==3)); } return(View(model)); }
public ActionResult Index() { ArticleListModel model = new ArticleListModel(); using (var db = new DIYFE.EF.DIYFEEntities()) { // model.ProjectList = db.Articles.Include("ArticleStatus").OrderBy(a => a.UpdateDate).Take(5).ToList(); //Projects needing funding model.ArticleList = db.Articles.Include("ArticleStatus").ToList(); //model.ProjectList = db.Articles.Include("ArticleStatus").Where(a => a.ArticleStatus.Any(arts => arts.StatusId == 4)).Take(5).ToList(); ////Projects recently updated //model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 2).OrderBy(a => a.UpdateDate).Take(5).ToList()); ////Post recently added //model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 1).OrderBy(a => a.CreatedDate).Take(5).ToList()); ////News recently added //model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 4).OrderBy(a => a.CreatedDate).Take(5).ToList()); ////model.ProjectList = db.Articles.Include() ////var articles = db.Articles.Where(a => a.ArticleTypeId == 2 && a.ArticleStatus.Any(ar => ar.StatusId==3)); } return View(model); }
// // GET: /Service/ public ActionResult PostComment(ArticleComment comment) { var data = new object(); try { using (var db = new DIYFE.EF.DIYFEEntities()) { db.ArticleComments.Add(comment); db.SaveChanges(); } } catch (Exception ex) { data = new { success = false, message = "Failed to insert new comment." }; return Json(data); } data = new { success = true, obj = comment }; return Json(data); }
// // GET: /Service/ public ActionResult PostComment(ArticleComment comment) { var data = new object(); try { using (var db = new DIYFE.EF.DIYFEEntities()) { db.ArticleComments.Add(comment); db.SaveChanges(); } } catch (Exception ex) { data = new { success = false, message = "Failed to insert new comment." }; return(Json(data)); } data = new { success = true, obj = comment }; return(Json(data)); }
public ActionResult AddToDay(int dayId, int recipeId) { var data = new object(); RecipeDay rd = new RecipeDay { DayId = dayId, RecipeId = recipeId, Active = true }; try { using (var db = new DIYFE.EF.DIYFEEntities()) { db.Entry(rd).State = System.Data.EntityState.Added; db.SaveChanges(); } data = new { success = true }; } catch (Exception ex) { if (ex.InnerException.Message != null) { data = new { success = false, message = ex.InnerException.Message }; } else { data = new { success = false, message = ex.Message + " Another reason why EF sucks" }; } return Json(data); } return Json(data); }
public ActionResult ProjectDetails(string html) { //int categoryRowId = 0; ArticleModel model = new ArticleModel(); using (var db = new DIYFE.EF.DIYFEEntities()) { model.Article = db.Articles.Include("ArticleComments").Where(a => a.URLLink == html + ".html").FirstOrDefault(); } if (model.Article != null) { Category cat = DIYFEHelper.GetCatigroy(model.Article.CategoryRowId); DIYFELib.Tracking.InsertArticleViewRequest(model.Article.ArticleId); // model.Comments = la.ArticleComments(model.Article.ArticleId); // model.MostViewed = la.MostViewed(11, 20); model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(cat, linkPrefix); model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(cat, linkPrefix); PageModel.Title = model.Article.Title; PageModel.Description = model.Article.Description; PageModel.Author = model.Article.Author; PageModel.Keywords = model.Article.Keywords; } else { //JUST TO GET BY -- REPLACE WITH 404 SOULATION model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(new Category(), linkPrefix); //model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(model.Article.CategoryRowId, linkPrefix); PageModel.Title = ""; PageModel.Description = ""; PageModel.Author = ""; PageModel.Keywords = ""; } return(View(model)); }
public ActionResult NewsDetails(string html) { int categoryRowId = 0; Category cat = new Category(); ArticleModel model = new ArticleModel(); using (var db = new DIYFE.EF.DIYFEEntities()) { model.Article = db.Articles.Include("ArticleComments").Where(a => a.URLLink == html + ".html").FirstOrDefault(); } if (model.Article == null) { cat = DIYFEHelper.GetCatigroy(model.Article.CategoryRowId); model.Article = new DIYFE.EF.Article(); model.Comments = new List <DIYFE.EF.ArticleComment>(); //model.Article.ArticleComments = new List<ArticleComment>(); } else { DIYFELib.Tracking.InsertArticleViewRequest(model.Article.ArticleId); } // model.Comments = la.ArticleComments(model.Article.ArticleId); //model.MostViewed = la.MostViewed(11, 20); // model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(categoryRowId, linkPrefix); model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(cat, linkPrefix); ////PageModel.Title = model.Article.Title; ////PageModel.Description = model.Article.Description; ////PageModel.Author = model.Article.Author; ////PageModel.Keywords = model.Article.Keywords; return(View(model)); }
public ActionResult Search(string searchVal, int?page) { ArticleListModel model = new ArticleListModel(); PageModel.Title = ""; PageModel.Description = searchVal; PageModel.Author = ""; PageModel.Keywords = ""; // string url = HttpContext.Request.RawUrl; //int categoryRowId = DIYFEHelper.GetCatigoryRowId(categoryUrl, "", ""); using (var db = new DIYFE.EF.DIYFEEntities()) { //BASED ON CAT //mo model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleType.ArticleTypeName == "post" && a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, 10); //CHECK PAGING //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 1); //model.PagedArticle = model.ArticleList.Concat(db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleTypeId == 2)).OrderBy(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); } //model.PagedArticle = model.ArticleList.ToPagedList(page ?? 1, pageSize); return(View(model)); }
public ActionResult AddShoppingItem(int ingredientId) { var data = new object(); IngredientShopping rd = new IngredientShopping { IngredientId = ingredientId }; try { using (var db = new DIYFE.EF.DIYFEEntities()) { db.Entry(rd).State = System.Data.EntityState.Added; db.SaveChanges(); } data = new { success = true }; } catch (Exception ex) { if (ex.InnerException.Message != null) { data = new { success = false, message = ex.InnerException.Message }; } else { data = new { success = false, message = ex.Message + " Another reason why EF sucks" }; } return Json(data); } return Json(data); }
public ActionResult AddToDay(int dayId, int recipeId) { var data = new object(); RecipeDay rd = new RecipeDay { DayId = dayId, RecipeId = recipeId, Active = true }; try { using (var db = new DIYFE.EF.DIYFEEntities()) { db.Entry(rd).State = System.Data.EntityState.Added; db.SaveChanges(); } data = new { success = true }; } catch (Exception ex) { if (ex.InnerException.Message != null) { data = new { success = false, message = ex.InnerException.Message }; } else { data = new { success = false, message = ex.Message + " Another reason why EF sucks" }; } return(Json(data)); } return(Json(data)); }
public ActionResult ProjectDetails(string html) { //int categoryRowId = 0; ArticleModel model = new ArticleModel(); using (var db = new DIYFE.EF.DIYFEEntities()) { model.Article = db.Articles.Include("ArticleComments").Where(a => a.URLLink == html + ".html").FirstOrDefault(); } if (model.Article != null) { Category cat = DIYFEHelper.GetCatigroy(model.Article.CategoryRowId); DIYFELib.Tracking.InsertArticleViewRequest(model.Article.ArticleId); // model.Comments = la.ArticleComments(model.Article.ArticleId); // model.MostViewed = la.MostViewed(11, 20); model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(cat, linkPrefix); model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(cat, linkPrefix); PageModel.Title = model.Article.Title; PageModel.Description = model.Article.Description; PageModel.Author = model.Article.Author; PageModel.Keywords = model.Article.Keywords; } else { //JUST TO GET BY -- REPLACE WITH 404 SOULATION model.CrumbLinkList = DIYFEHelper.GenerateCrumbLinks(new Category(), linkPrefix); //model.RelatedTreeView = DIYFEHelper.GenerateTreeViewThirdLev(model.Article.CategoryRowId, linkPrefix); PageModel.Title = ""; PageModel.Description = ""; PageModel.Author = ""; PageModel.Keywords = ""; } return View(model); }
public static void LoadStaticCache() { List<DIYFE.EF.Category> allCats = new List<DIYFE.EF.Category>(); using (var db = new DIYFE.EF.DIYFEEntities()) { allCats = db.Categories.ToList(); } HttpContext.Current.Application["Categories"] = allCats; List<DIYFE.EF.ContentSection> contentSections = new List<ContentSection>(); using (var db = new DIYFE.EF.DIYFEEntities()) { contentSections = db.ContentSections.ToList(); } HttpContext.Current.Application["ContentSections"] = contentSections; //BUILD TOP NAVIGATION ITEMS HTML #region string topNav = "<div id=\"navWrap\"><div class=\"content\"><div id=\"header\"><nav id=\"nav\"><div class=\"nav-holder\"><div class=\"nav-frame\"><ul class=\"nav\" style=\"display: block;\">"; string subNav = "<div class=\"content\"><div class=\"subnav\">"; int topNavIndex = 0; foreach (Category firstCat in allCats.Where(c => c.SecondLevCategoryId == 0 && c.TopNavIndex > 0).OrderBy(c => c.TopNavIndex)) { topNav += "<li><a rel=\"sub" + topNavIndex.ToString() + "\" href=\"" + BaseSiteUrl + "post/" + firstCat.CategoryUrl + "\"><div><span>" + firstCat.CategoryName + "</span></div></a></li>"; subNav += "<ul id=\"sub" + topNavIndex.ToString() + "\" class=\"submenu\" style=\"display: none;\">"; foreach (Category secondCat in allCats.Where(c => c.CategoryId == firstCat.CategoryId && c.SecondLevCategoryId > 0 && c.ThirdLevCategoryId == 0).OrderBy(c => c.SubNavIndex)) { subNav += "<li><a href=\"" + BaseSiteUrl + "post/" + firstCat.CategoryUrl + "/" + secondCat.SecondLevCategoryUrl + "\">" + secondCat.SecondLevCategoryName + "</a></li>"; } subNav += "</ul>"; topNavIndex++; } topNav += "</ul><div id=\"searchWrap\"><div class=\"searchGlass\"></div><div id=\"searchTextBox\"><input id=\"searchText\" type=\"text\"></div></div></div></nav></div></div></div>"; subNav += "</div></div>"; HtmlString hString = new HtmlString(topNav + subNav); #endregion HttpContext.Current.Application["TopNavHtml"] = hString; }
public static List <CustomHtmlLink> RelatedArticleLinks(Category cat, string linkPrefix, int categoryLevel) { List <CustomHtmlLink> linkList = new List <CustomHtmlLink>(); List <Article> articles = new List <Article>(); using (var db = new DIYFE.EF.DIYFEEntities()) { switch (categoryLevel) { case 1: articles = db.Articles.Where(a => a.Category.CategoryId == cat.CategoryId && a.Category.SecondLevCategoryId == 0 && a.Category.ThirdLevCategoryId == 0 ).ToList(); // whereSql = "WHERE CategoryId = " + cat.CategoryId; break; case 2: articles = db.Articles.Where(a => a.Category.SecondLevCategoryId == cat.SecondLevCategoryId && a.Category.ThirdLevCategoryId == 0 ).ToList(); //whereSql = "WHERE SecondLevCategoryId = " + cat.SecondLevCategoryId + " AND CategoryId= " + cat.CategoryId + " AND ThirdLevCategoryId = 0"; break; case 3: articles = db.Articles.Where(a => a.Category.ThirdLevCategoryId == cat.ThirdLevCategoryId).ToList(); // whereSql = "WHERE ThirdLevCategoryId = " + cat.ThirdLevCategoryId; break; case 4: articles = db.Articles.Where(a => a.Category.CategoryId == cat.CategoryId).ToList(); //whereSql = "WHERE CategoryId = " + cat.CategoryId; break; default: break; } } foreach (Article a in articles) { string articleType = ""; switch (a.ArticleTypeId) { case 1: articleType = "post/"; break; case 2: articleType = "project/"; break; case 3: articleType = "blog/"; break; case 4: articleType = "news/"; break; default: articleType = "home/"; break; } string ahref = StaticConfig.BaseSiteUrl + articleType + cat.CategoryUrl + "/"; //MvcHtmlString ahref = new MvcHtmlString("<a href=\"" + AppStatic.BaseSiteUrl + article.Category.CategoryUrl + "/"); if (!String.IsNullOrEmpty(cat.SecondLevCategoryUrl)) { ahref += cat.SecondLevCategoryUrl + "/"; } if (!String.IsNullOrEmpty(cat.ThirdLevCategoryUrl)) { ahref += cat.ThirdLevCategoryUrl + "/"; } ahref += a.URLLink; CustomHtmlLink htmlLink = new CustomHtmlLink { LinkText = a.Name, Href = ahref, Title = a.Title }; linkList.Add(htmlLink); } return(linkList); }
public ActionResult Index() { ArticleListModel model = new ArticleListModel(); model.ProjectList = new List <DIYFE.EF.Article>(); using (var db = new DIYFE.EF.DIYFEEntities()) { // model.ProjectList = db.Articles.Include("ArticleStatus").OrderBy(a => a.UpdateDate).Take(5).ToList(); //Projects needing funding model.ProjectList = db.Articles.Include("ArticleStatus").Where(a => a.ArticleStatus.Any(arts => arts.StatusId == 4)).Take(5).ToList(); //Projects recently updated model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 2).OrderBy(a => a.UpdateDate).Take(5).ToList()); //Post recently added model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 1).OrderBy(a => a.CreatedDate).Take(5).ToList()); //News recently added model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 4).OrderBy(a => a.CreatedDate).Take(5).ToList()); //model.ProjectList = db.Articles.Include() //var articles = db.Articles.Where(a => a.ArticleTypeId == 2 && a.ArticleStatus.Any(ar => ar.StatusId==3)); } model.ProjectList = model.ProjectList.Distinct().ToList(); PageModel.Title = "DiyFe"; PageModel.Description = ""; PageModel.Author = "Do it yourself for everyone."; PageModel.Keywords = "DIY, DIYFE, do it yourself, homesteading, transition"; //PageModel.ActiveTopNavLink = "MainNavHome"; //Test error handeling //throw new Exception(); #region Check Valid Domain and Email //EmailValidation.Validate validate = new EmailValidation.Validate(); //EmailValidation.DnsMx //string[] domainNames = new string[] { "hotmail.com", "", "none.com", "tetsicala.ca" }; //foreach (string dName in domainNames) //{ // if (validate.Domain(dName)) // { // var test = true; // } //} //string[] emailNames = new string[] { "mx1.hotmail.com" }; //foreach (string eName in emailNames) //{ // if (validate.Email(eName)) // { // var test = true; // } //} //string[] s = EmailValidation.DnsMx.GetMXRecords("hotmail.com"); //foreach (string cm in s) //{ // var temp = cm; //} #endregion #region Send Email // Get the settings from the App.Config file //var loginUrl = "WebSiteURL"; // Create the mail object //var email = EmailMessageFactory.GetWelcomeEmail( // "*****@*****.**", // "jdoe123", // "John Doe", // "nerdyp@ss", // loginUrl, // AppStatic.EmailSenderAddress); //// Send the message //var result = EmailClient.SendEmail(email); //// Check the result //if (result.Failed) //{ // Console.WriteLine(result.Exception.Message); //} //else //{ // Console.WriteLine("Sent mail:"); // Console.Write(result.Message.Body); //} #endregion string testStaticAppVar = AppStatic.ApplicationVar; return(View(model)); }
public ActionResult ArticleList(string articleType, string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, int?page) { ArticleListModel model = new ArticleListModel(); PageModel.Title = ""; PageModel.Description = ""; PageModel.Author = ""; PageModel.Keywords = ""; string url = HttpContext.Request.RawUrl; //int categoryRowId = DIYFEHelper.GetCatigoryRowId(categoryUrl, "", ""); Category cat = StaticConfig.GetCatigory(categoryUrl, subCategoryUrl, subSubCategoryUrl); model.CrumbLinkList = StaticConfig.GenerateCrumbLinks(cat, articleType); model.RelatedTreeView = StaticConfig.GenerateRelatedTreeView(cat, articleType); model.PageLinkBase = StaticConfig.BaseSiteUrl + articleType; if (categoryUrl != "") { model.PageLinkBase += "/" + cat.CategoryUrl; } if (subCategoryUrl != "") { model.PageLinkBase += "/" + cat.SecondLevCategoryUrl; } if (subSubCategoryUrl != "") { model.PageLinkBase += "/" + cat.ThirdLevCategoryUrl; } //model.PageLinkBase = model.CrumbLinkList.Last().Href; //model.RelatedTreeView = StaticConfig.TreeView(cat, model.PageLinkBase); using (var db = new DIYFE.EF.DIYFEEntities()) { //BASED ON CAT //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.Category.CategoryId == cat.CategoryId).OrderBy(a => a.CreatedDate); if (categoryUrl != "") { model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.Category.CategoryId == cat.CategoryId && a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); //model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); if (subSubCategoryUrl != "") { model.Into = db.Articles.Where(a => a.URLLink == subSubCategoryUrl).FirstOrDefault(); } else if (subCategoryUrl != "") { model.Into = db.Articles.Where(a => a.URLLink == subCategoryUrl).FirstOrDefault(); } else { model.Into = db.Articles.Where(a => a.URLLink == categoryUrl).FirstOrDefault(); } } else { model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleType.ArticleTypeName == articleType && a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); } model.Into = new Article(); model.Into.Title = "Text of H1 in work"; //CHECK PAGING //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 1); //model.PagedArticle = model.ArticleList.Concat(db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleTypeId == 2)).OrderBy(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); } //model.PagedArticle = model.ArticleList.ToPagedList(page ?? 1, pageSize); return(View(model)); }
public static List<CustomHtmlLink> RelatedArticleLinks(Category cat, string linkPrefix, int categoryLevel) { List<CustomHtmlLink> linkList = new List<CustomHtmlLink>(); List<Article> articles = new List<Article>(); using (var db = new DIYFE.EF.DIYFEEntities()) { switch (categoryLevel) { case 1: articles = db.Articles.Where(a => a.Category.CategoryId == cat.CategoryId && a.Category.SecondLevCategoryId == 0 && a.Category.ThirdLevCategoryId == 0 ).ToList(); // whereSql = "WHERE CategoryId = " + cat.CategoryId; break; case 2: articles = db.Articles.Where(a => a.Category.SecondLevCategoryId == cat.SecondLevCategoryId && a.Category.ThirdLevCategoryId == 0 ).ToList(); //whereSql = "WHERE SecondLevCategoryId = " + cat.SecondLevCategoryId + " AND CategoryId= " + cat.CategoryId + " AND ThirdLevCategoryId = 0"; break; case 3: articles = db.Articles.Where(a => a.Category.ThirdLevCategoryId == cat.ThirdLevCategoryId).ToList(); // whereSql = "WHERE ThirdLevCategoryId = " + cat.ThirdLevCategoryId; break; case 4: articles = db.Articles.Where(a => a.Category.CategoryId == cat.CategoryId).ToList(); //whereSql = "WHERE CategoryId = " + cat.CategoryId; break; default: break; } } foreach (Article a in articles) { string articleType = ""; switch (a.ArticleTypeId) { case 1: articleType = "post/"; break; case 2: articleType = "project/"; break; case 3: articleType = "blog/"; break; case 4: articleType = "news/"; break; default: articleType = "home/"; break; } string ahref = AppStatic.BaseSiteUrl + articleType + cat.CategoryUrl + "/"; //MvcHtmlString ahref = new MvcHtmlString("<a href=\"" + AppStatic.BaseSiteUrl + article.Category.CategoryUrl + "/"); if (!String.IsNullOrEmpty(cat.SecondLevCategoryUrl)) { ahref += cat.SecondLevCategoryUrl + "/"; } if (!String.IsNullOrEmpty(cat.ThirdLevCategoryUrl)) { ahref += cat.ThirdLevCategoryUrl + "/"; } ahref += a.URLLink; CustomHtmlLink htmlLink = new CustomHtmlLink { LinkText = a.Name, Href = ahref, Title = a.Title }; linkList.Add(htmlLink); } return linkList; }
public static void LoadStaticCache() { //EXAMPLE OF HOW TO USE WITH A ORM TOOL //using (var context = new MDMContext()) //{ // HttpContext.Current.Application["communicationType"] = context.CommunicationType.ToList(); //} HttpContext.Current.Application["someVarName"] = "This is a test. Normally a list of objects but since no DB connection is made it's only a string...le sigh, poor string."; DIYFELib.ListAccess la = new DIYFELib.ListAccess(); //List<Category> allCats = la.AllCategory(); List<DIYFE.EF.Category> allCats = new List<DIYFE.EF.Category>(); using (var db = new DIYFE.EF.DIYFEEntities()) { allCats = db.Categories.ToList(); } HttpContext.Current.Application["Categories"] = allCats; List<DIYFE.EF.ContentSection> contentSections = new List<ContentSection>(); using (var db = new DIYFE.EF.DIYFEEntities()) { contentSections = db.ContentSections.ToList(); } HttpContext.Current.Application["ContentSections"] = contentSections; //BUILD TOP NAVIGATION ITEMS HTML #region string topNavString = "<ul role=\"navigation\" class=\"nav pull-right\">"; foreach (Category firstCat in allCats.Where(c => c.SecondLevCategoryId == 0 && c.TopNavIndex > 0).OrderBy(c => c.TopNavIndex)) { topNavString += "<li class=\"dropdown\" id=\"MainNav-Mfg\">"; topNavString += "<a data-toggle=\"dropdown\" class=\"dropdown-toggle\" href=\"" + BaseSiteUrl + "post/" + firstCat.CategoryUrl + "\")>" + firstCat.CategoryName + "<b class=\"caret\"></b></a>"; topNavString += "<ul class=\"dropdown-menu\">"; foreach (Category secondCat in allCats.Where(c => c.CategoryId == firstCat.CategoryId && c.SecondLevCategoryId > 0 && c.ThirdLevCategoryId == 0).OrderBy(c => c.SubNavIndex)) { if (allCats.Where(c => c.CategoryId == firstCat.CategoryId && c.SecondLevCategoryId == secondCat.SecondLevCategoryId && c.ThirdLevCategoryId > 0).Count() > 0) { topNavString += "<li class=\"dropdown-submenu\">"; topNavString += "<a href=\"" + BaseSiteUrl + "post/" + firstCat.CategoryUrl + "/" + secondCat.SecondLevCategoryUrl + "\">" + secondCat.SecondLevCategoryName + "</a>"; topNavString += "<ul class=\"dropdown-menu\">"; //LOOP OVER THIRD LEVEL foreach (Category thirdCat in allCats.Where(c => c.CategoryId == firstCat.CategoryId && c.SecondLevCategoryId == secondCat.SecondLevCategoryId && c.ThirdLevCategoryId > 0).OrderBy(c => c.SubNavIndex)) { topNavString += "<li><a href=\"" + BaseSiteUrl + "post/" + firstCat.CategoryUrl + "/" + secondCat.SecondLevCategoryUrl + "/" + thirdCat.ThirdLevCategoryUrl + "\">" + thirdCat.ThirdLevCategoryName + "</a></li>"; } topNavString += "</ul></li>"; } else { topNavString += "<li><a href=\"" + BaseSiteUrl + "post/" + firstCat.CategoryUrl + "/" + secondCat.SecondLevCategoryUrl + "\">" + secondCat.SecondLevCategoryName + "</a></li>"; } } topNavString += "</ul></li>"; } topNavString += "</ul>"; #endregion HtmlString hString = new HtmlString(topNavString); HttpContext.Current.Application["TopNavHtml"] = hString; }
public ActionResult ArticleList(string articleType, string categoryUrl, string subCategoryUrl, string subSubCategoryUrl, int? page) { ArticleListModel model = new ArticleListModel(); PageModel.Title = ""; PageModel.Description = ""; PageModel.Author = ""; PageModel.Keywords = ""; string url = HttpContext.Request.RawUrl; //int categoryRowId = DIYFEHelper.GetCatigoryRowId(categoryUrl, "", ""); Category cat = StaticConfig.GetCatigory(categoryUrl, subCategoryUrl, subSubCategoryUrl); model.CrumbLinkList = StaticConfig.GenerateCrumbLinks(cat, articleType); model.RelatedTreeView = StaticConfig.GenerateRelatedTreeView(cat, articleType); model.PageLinkBase = StaticConfig.BaseSiteUrl + articleType; if (categoryUrl != ""){ model.PageLinkBase += "/" + cat.CategoryUrl; } if (subCategoryUrl != "") { model.PageLinkBase += "/" + cat.SecondLevCategoryUrl; } if (subSubCategoryUrl != "") { model.PageLinkBase += "/" + cat.ThirdLevCategoryUrl; } //model.PageLinkBase = model.CrumbLinkList.Last().Href; //model.RelatedTreeView = StaticConfig.TreeView(cat, model.PageLinkBase); using (var db = new DIYFE.EF.DIYFEEntities()) { //BASED ON CAT //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.Category.CategoryId == cat.CategoryId).OrderBy(a => a.CreatedDate); if (categoryUrl != "") { model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.Category.CategoryId == cat.CategoryId && a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); //model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); if (subSubCategoryUrl != "") { model.Into = db.Articles.Where(a => a.URLLink == subSubCategoryUrl).FirstOrDefault(); } else if (subCategoryUrl != "") { model.Into = db.Articles.Where(a => a.URLLink == subCategoryUrl).FirstOrDefault(); } else { model.Into = db.Articles.Where(a => a.URLLink == categoryUrl).FirstOrDefault(); } } else { model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleType.ArticleTypeName == articleType && a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); } model.Into = new Article(); model.Into.Title = "Text of H1 in work"; //CHECK PAGING //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 1); //model.PagedArticle = model.ArticleList.Concat(db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleTypeId == 2)).OrderBy(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); } //model.PagedArticle = model.ArticleList.ToPagedList(page ?? 1, pageSize); return View(model); }
public ActionResult WeeklyMenu() { PageModel.Title = "Contact About Boostrap Project"; PageModel.Description = "Bootstrap Template Project"; PageModel.Author = "Bootstrap"; PageModel.Keywords = "Boostrap project, starter project, soe keywords, keywords"; PageModel.ActiveTopNavLink = "MainNavContact"; WeeklyMenu Model = new WeeklyMenu(); using (var db = new DIYFE.EF.DIYFEEntities()) { Model.ShoppingList = db.IngredientShoppings.ToList(); Model.DailyRecipes = db.DailyRecipes.ToList(); Model.SeasonalRecipes = db.SeasonalRecipes.ToList(); } return View(Model); }
public ActionResult SendContactEmail(ContactMailModel model) { var data = new object(); try { var email = EmailMessageFactory.GetContactEmail(model); var result = EmailClient.SendEmail(email); if (!String.IsNullOrEmpty(model.NewsLetter)) { try { NewsLetter letter = new NewsLetter() { Email = model.Email, DateCreated = DateTime.Now }; using (var db = new DIYFE.EF.DIYFEEntities()) { db.NewsLetters.Add(letter); db.SaveChanges(); } } catch (Exception ex) { data = new { success = false, message = "Message Was Sent...but failed to join news letter." }; return Json(data); } } } catch (Exception ex) { data = new { success = false, message = "Failed to send comment. Please trying contacting us directly." }; return Json(data); } data = new { success = true }; return Json(data); }
public ActionResult ClearWeek() { var data = new object(); try { using (var db = new DIYFE.EF.DIYFEEntities()) { db.ClearWeek(); db.SaveChanges(); } data = new { success = true }; } catch (Exception ex) { if (ex.InnerException.Message != null) { data = new { success = false, message = ex.InnerException.Message }; } else { data = new { success = false, message = ex.Message + " Another reason why EF sucks" }; } return Json(data); } return Json(data); }
public ActionResult RemoveShoppingItem(int ingredientId) { var data = new object(); try { using (var db = new DIYFE.EF.DIYFEEntities()) { IngredientShopping deltedItem = db.IngredientShoppings.Where(i => i.IngredientId == ingredientId).FirstOrDefault(); if (deltedItem != null) { db.Entry(deltedItem).State = System.Data.EntityState.Deleted; db.SaveChanges(); }; } data = new { success = true }; } catch (Exception ex) { if (ex.InnerException.Message != null) { data = new { success = false, message = ex.InnerException.Message }; } else { data = new { success = false, message = ex.Message + " Another reason why EF sucks" }; } return Json(data); } return Json(data); }
public ActionResult SignUpNewLetter(string email) { var data = new object(); try { NewsLetter letter = new NewsLetter() { Email = email, DateCreated = DateTime.Now }; using (var db = new DIYFE.EF.DIYFEEntities()) { db.NewsLetters.Add(letter); db.SaveChanges(); } } catch (Exception ex) { data = new { success = false, message = "Failed to join news letter." }; return Json(data); } data = new { success = true }; return Json(data); }
public ActionResult DailyRecipeRemove(int recipeDayId) { var data = new object(); try { using (var db = new DIYFE.EF.DIYFEEntities()) { RecipeDay deltedRecipe = db.RecipeDays.Where(rd => rd.RecipeDayId == recipeDayId).FirstOrDefault(); if (deltedRecipe != null) { db.Entry(deltedRecipe).State = System.Data.EntityState.Deleted; db.SaveChanges(); }; } data = new { success = true }; } catch (Exception ex) { if (ex.InnerException.Message != null) { data = new { success = false, message = ex.InnerException.Message }; } else { data = new { success = false, message = ex.Message + " Another reason why EF sucks" }; } return Json(data); } return Json(data); }
public ActionResult Search(string searchVal, int? page) { ArticleListModel model = new ArticleListModel(); PageModel.Title = ""; PageModel.Description = searchVal; PageModel.Author = ""; PageModel.Keywords = ""; // string url = HttpContext.Request.RawUrl; //int categoryRowId = DIYFEHelper.GetCatigoryRowId(categoryUrl, "", ""); using (var db = new DIYFE.EF.DIYFEEntities()) { //BASED ON CAT //mo model.PagedArticle = db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleType.ArticleTypeName == "post" && a.ArticleStatus.Any(aStat => aStat.StatusId == 1)).OrderByDescending(a => a.CreatedDate).ToPagedList(page ?? 1, 10); //CHECK PAGING //model.ArticleList = db.Articles.Include("ArticleComments").Where(a => a.ArticleTypeId == 1); //model.PagedArticle = model.ArticleList.Concat(db.Articles.Include("ArticleComments").Include("ArticleStatus.StatusType").Where(a => a.ArticleTypeId == 2)).OrderBy(a => a.CreatedDate).ToPagedList(page ?? 1, pageSize); } //model.PagedArticle = model.ArticleList.ToPagedList(page ?? 1, pageSize); return View(model); }
public ActionResult Index() { ArticleListModel model = new ArticleListModel(); model.ProjectList = new List<DIYFE.EF.Article>(); using (var db = new DIYFE.EF.DIYFEEntities()) { // model.ProjectList = db.Articles.Include("ArticleStatus").OrderBy(a => a.UpdateDate).Take(5).ToList(); //Projects needing funding model.ProjectList = db.Articles.Include("ArticleStatus").Where(a => a.ArticleStatus.Any(arts => arts.StatusId == 4)).Take(5).ToList(); //Projects recently updated model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 2).OrderBy(a => a.UpdateDate).Take(5).ToList()); //Post recently added model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 1).OrderBy(a => a.CreatedDate).Take(5).ToList()); //News recently added model.ProjectList.AddRange(db.Articles.Include("ArticleStatus").Where(a => a.ArticleTypeId == 4).OrderBy(a => a.CreatedDate).Take(5).ToList()); //model.ProjectList = db.Articles.Include() //var articles = db.Articles.Where(a => a.ArticleTypeId == 2 && a.ArticleStatus.Any(ar => ar.StatusId==3)); } model.ProjectList = model.ProjectList.Distinct().ToList(); PageModel.Title = "DiyFe"; PageModel.Description = ""; PageModel.Author = "Do it yourself for everyone."; PageModel.Keywords = "DIY, DIYFE, do it yourself, homesteading, transition"; //PageModel.ActiveTopNavLink = "MainNavHome"; //Test error handeling //throw new Exception(); #region Check Valid Domain and Email //EmailValidation.Validate validate = new EmailValidation.Validate(); //EmailValidation.DnsMx //string[] domainNames = new string[] { "hotmail.com", "", "none.com", "tetsicala.ca" }; //foreach (string dName in domainNames) //{ // if (validate.Domain(dName)) // { // var test = true; // } //} //string[] emailNames = new string[] { "mx1.hotmail.com" }; //foreach (string eName in emailNames) //{ // if (validate.Email(eName)) // { // var test = true; // } //} //string[] s = EmailValidation.DnsMx.GetMXRecords("hotmail.com"); //foreach (string cm in s) //{ // var temp = cm; //} #endregion #region Send Email // Get the settings from the App.Config file //var loginUrl = "WebSiteURL"; // Create the mail object //var email = EmailMessageFactory.GetWelcomeEmail( // "*****@*****.**", // "jdoe123", // "John Doe", // "nerdyp@ss", // loginUrl, // AppStatic.EmailSenderAddress); //// Send the message //var result = EmailClient.SendEmail(email); //// Check the result //if (result.Failed) //{ // Console.WriteLine(result.Exception.Message); //} //else //{ // Console.WriteLine("Sent mail:"); // Console.Write(result.Message.Body); //} #endregion string testStaticAppVar = AppStatic.ApplicationVar; return View(model); }