public ActionResult Publicer(FormCollection data) { try { NewsDao bdDao = new NewsDao(); News bd = bdDao.FindByID(Convert.ToInt64(data["NewsID"].ToString())); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; bd.ModifiedBy = us.UserName; bd.ModifiedDate = Hepper.GetDateServer(); bd.PublishedDate = Hepper.GetDateServer(); int Status = Convert.ToInt32(data["Status"]); bd.Status = Status; bd.ContentHtml = data["ContentHtml"].ToString(); if (bdDao.Update(bd) > 0) { SetAlert(@Resources.ResourceAdmin.AdminEditRecordSucess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminEditRecordFailed, "danger"); } } catch { ModelState.AddModelError("", Resources.ResourceAdmin.ErrorGetRecordMessage); } return(View()); }
public ActionResult Detail(long ID) { ViewBag.Tags = Session["tag"]; ViewBag.Cate = null; if (Session["tag"] == null) { var catID = Convert.ToInt64(Session["CategoryID"]); CategoryDao ctDao = new CategoryDao(); ViewBag.Cate = ctDao.FindByID(catID); var items = GetClientCategoryViewModel(); ViewBag.CatePare = items.Find(x => x.ID == catID); } else { ViewBag.Tags = Session["tag"]; } NewsDao nDao = new NewsDao(); News objNew = nDao.FindByID(ID); objNew.ViewCount = objNew.ViewCount + 1; nDao.Update(objNew); return(View(objNew)); }
public ActionResult DetailTag(long id, string tagId) { ViewBag.Tags = tagId; NewsDao nDao = new NewsDao(); News objNew = nDao.FindByID(id); objNew.ViewCount = objNew.ViewCount + 1; nDao.Update(objNew); return(View(objNew)); }
public ActionResult Edit(long id) { NewsDao dbDAO = new NewsDao(); News objNew = null; objNew = dbDAO.FindByID(id); List <string> cateID = HepperString.GetListByKey(objNew.CategoryID, ","); PopulateParentIDDropDownList(HepperString.TolistLong(cateID.ToArray())); return(View(objNew)); }
// GET: Admin/Category/Details/5 public ActionResult Details(long id) { NewsDao dbDAO = new NewsDao(); ViewBag.lstCate = GetClientCategoryViewModel(); News cat = null; try { cat = dbDAO.FindByID(id); } catch { ModelState.AddModelError("", Resources.ResourceAdmin.ErrorGetRecordMessage); } return(View(cat)); }
public ActionResult Publicer(long id) { NewsDao dbDAO = new NewsDao(); News objNew = null; //SetParentIDViewBag(); try { objNew = dbDAO.FindByID(id); List <string> cateID = HepperString.GetListByKey(objNew.CategoryID, ","); PopulateParentIDDropDownList(HepperString.TolistLong(cateID.ToArray())); } catch { ModelState.AddModelError("", Resources.ResourceAdmin.ErrorGetRecordMessage); } return(View(objNew)); }
public ActionResult Edit(FormCollection data) { ViewBag.UpTopNew = data["UpTopNew"].ToString(); ViewBag.UpTopHot = data["UpTopHot"].ToString(); //SetParentIDViewBag(HepperString.TolistLong(data.GetValues("CategoryID"))); PopulateParentIDDropDownList(HepperString.TolistLong(data.GetValues("CategoryID"))); try { NewsDao bdDao = new NewsDao(); News objNews = bdDao.FindByID(Convert.ToInt64(data["NewsID"].ToString())); UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION]; objNews.Name = data["Name"].ToString(); objNews.Title = data["Title"].ToString(); objNews.MetaTite = data["MetaTite"].ToString(); objNews.MetakeyWords = data["MetakeyWords"].ToString(); objNews.MetaDescription = data["MetaDescription"].ToString(); objNews.Description = data["Description"].ToString(); objNews.ContentHtml = data["ContentHtml"].ToString(); objNews.Image = data["Image"].ToString(); objNews.UpTopNew = Convert.ToDateTime(ViewBag.UpTopNew); objNews.UpTopHot = Convert.ToDateTime(ViewBag.UpTopHot); bool ShowShare = true; if (data.GetValues("ShowShare").Equals("false")) { ShowShare = false; } bool ShowConment = true; if (data.GetValues("ShowConment").Equals("false")) { ShowConment = false; } objNews.ShowShare = ShowShare; objNews.ShowConment = ShowConment; objNews.Source = data["Source"].ToString(); objNews.Status = 0; objNews.ModifiedBy = us.UserName; objNews.Tags = data["Tags"].ToString(); objNews.ModifiedDate = Hepper.GetDateServer(); objNews.LanguageID = "vi"; string[] cateIDs = data.GetValues("CategoryID"); string sCatID = ""; foreach (var sID in cateIDs) { sCatID += sID + ","; } if (sCatID.Length > 0) { sCatID = sCatID.Remove(sCatID.Length - 1, 1); } objNews.CategoryID = sCatID; //collection.CreateBy = us.UserName; //collection.ModifiedBy = us.UserName; if (bdDao.Update(objNews) > 0) { SetAlert(@Resources.ResourceAdmin.AdminEditRecordSucess, "success"); return(RedirectToAction("Index")); } else { SetAlert(@Resources.ResourceAdmin.AdminEditRecordFailed, "danger"); } return(RedirectToAction("Index")); } catch { SetAlert(@Resources.ResourceAdmin.AdminEditRecordFailed, "danger"); //Response.Write(e.Message); return(View()); } }