public ActionResult MoreNewsFromHandbook(int lout = 1, int CateBig = -1, int CateID = -1) { ViewBag.LayoutID = lout; var listCateBig = new CategoryArticleDao().ListParent(); var listCate = new List <List <CategoryArticle> >(); ViewBag.CateBig = CateBig; ViewBag.CateID = CateID; ViewBag.ListArticleByView = new ArticleDao().ListByViews(); foreach (var item in listCateBig) { var eachList = new CategoryArticleDao().ListByParentID(item.CategoryID); listCate.Add(eachList); } ViewBag.ListCateBig = listCateBig; ViewBag.ListCate = listCate; if (CateID != -1) { var model = new ArticleDao().ListByCateID(CateID); return(View(model)); } else { var model = new ArticleDao().ListByCateBig(CateBig); return(View(model)); } }
public ActionResult HandbookForUser(int lout = 1) { ViewBag.LayoutID = lout; var listCateBig = new CategoryArticleDao().ListParent(); var listCate = new List <List <CategoryArticle> >(); foreach (var item in listCateBig) { var eachList = new CategoryArticleDao().ListByParentID(item.CategoryID); listCate.Add(eachList); } ViewBag.ListCateBig = listCateBig; ViewBag.ListCate = listCate; var arDao = new ArticleDao(); ViewBag.ListArticleNew = arDao.ListByDate(); ViewBag.ListArticleByView = arDao.ListByViews(); var listArticleByCateBig = new List <List <Article> >(); foreach (var item in listCateBig) { var eachList = arDao.ListByCateBig(item.CategoryID); listArticleByCateBig.Add(eachList); } ViewBag.ListArticleByCateBig = listArticleByCateBig; return(View()); }
public ActionResult AddAndEditArticle(FormArticle model) { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Account")); } var accID = int.Parse(User.Identity.Name); var acc = new AccountDao().FindAccountById(accID); var emp = new EmployeeDao().FindById(acc.UserId); var article = new Article(); if (model.typeAction == "edit") { article.ID = model.saveID; article.ModifyDate = DateTime.Now; } else { article.Status = "Request"; article.CreateDate = DateTime.Now; article.CreateID = emp.EmployeeID; article.Views = 0; } article.Description = model.Description; article.ContentArticle = model.ContentArticle; article.CategoryID = model.CategorySmall; article.CategoryParent = model.CategoryBig; article.Title = model.Title; var file = model.Image; if (file != null) { var fileName = Path.GetFileName(file.FileName); file.SaveAs(Server.MapPath("/Assets/Client/Img/Article/" + fileName)); var srcImage = "/Assets/Client/Img/Article/" + fileName; article.Image = srcImage; } if (model.typeAction == "add") { var check = new ArticleDao().Insert(article); var checkSecond = new CategoryArticleDao().IncreaseAmount(article.CategoryID); var checkThird = new CategoryArticleDao().IncreaseAmount(article.CategoryParent.Value); } else { var check = new ArticleDao().Edit(article); } return(RedirectToAction("ListArticleEmployee", "Employee")); }
public JsonResult ListCategorySmallArticle(int parentID) { var listCategory = new CategoryArticleDao().ListByParentID(parentID); if (listCategory == null) { return(Json(new { status = false })); } return(Json(new { list = listCategory, status = true })); }
public ActionResult ArticleDetail(int articleID, int lout = 1) { ViewBag.LayoutID = lout; var listCateBig = new CategoryArticleDao().ListParent(); var listCate = new List <List <CategoryArticle> >(); foreach (var item in listCateBig) { var eachList = new CategoryArticleDao().ListByParentID(item.CategoryID); listCate.Add(eachList); } ViewBag.ListCateBig = listCateBig; ViewBag.ListCate = listCate; var model = new ArticleDao().FindByID(articleID); var check = new ArticleDao().IncreaseView(articleID); return(View(model)); }
public JsonResult ReturnArticle(int articleID) { var article = new ArticleDao().FindByID(articleID); if (article == null) { return(Json(new { status = false })); } var listCate = new CategoryArticleDao().ListByParentID(article.CategoryParent.Value); return(Json(new { status = true, list = listCate, article = article })); }