public ActionResult DetailContent(int id)
        {
            ContentDAO contentDAO = new ContentDAO();
            var        content    = contentDAO.GetContent(id);

            return(View(content));
        }
 public ActionResult Create(Content content, string trangthai)
 {
     SetViewBag();
     if (ModelState.IsValid == true)
     {
         if (trangthai == "Mở")
         {
             content.Status = true;
         }
         else
         {
             content.Status = false;
         }
         content.CreateDate = DateTime.Now;
         ContentDAO contentDAO = new ContentDAO();
         var        id         = contentDAO.ThemContent(content);
         if (id > 0)
         {
             TempData["msg"] = MessageBox.Show("Thêm Thành Công");
             return(RedirectToAction("Create", "Content"));
         }
         else
         {
             ModelState.AddModelError("", "Không Thêm User Thành Công");
         }
     }
     return(View("Create"));
 }
        // Chi tiết Content
        public ActionResult Detail(long id)
        {
            var model = new ContentDAO().GetByID(id);

            ViewBag.Tags = new ContentDAO().ListTag(id);
            return(View(model));
        }
Пример #4
0
        public ActionResult Tag(string tagID, int pageIndex = 1, int pageSize = 10)
        {
            var model = new ContentDAO().GetAllContentByTag(tagID, pageIndex, pageSize);

            // tổng số dòng
            int totalRecords = 0;

            ViewBag.Total = totalRecords;
            ViewBag.Page  = pageIndex;
            // lấy ra Tag hiện tại theo id Tag truyền vào
            ViewBag.Tag = new ContentDAO().GetTagByID(tagID);

            //chỉ cho tối đa 5 trang thôi
            int maxPage = 5;
            // tổng số trang, mỗi trang có tối đa 2 dònng.
            // làm tròn lại (Ceil: 4.4 => 5)
            int totalPage = (int)Math.Ceiling((double)(totalRecords / pageSize));

            ViewBag.TotalPage = totalPage;
            ViewBag.MaxPage   = maxPage;
            ViewBag.First     = 1;
            ViewBag.Last      = totalPage;
            ViewBag.Next      = pageIndex + 1;
            ViewBag.Prev      = pageIndex - 1;

            return(View(model));
        }
        public ActionResult NewsByCategory(long id)
        {
            ViewBag.CategoryN = new CategoryDAO().GetByID(id);
            var model = new ContentDAO().ListNewsByCate(id);

            return(View(model));
        }
        public ActionResult NewsDetail(long newsid)
        {
            var model = new ContentDAO().GetByID(newsid);

            ViewBag.CategoryN = new CategoryDAO().GetByID(model.CategoryID.Value);
            return(View(model));
        }
Пример #7
0
        public JsonResult ChangeStatus(int Id)
        {
            var dao = new ContentDAO();
            var stt = dao.ChangeStatus(Id);

            return(Json(new { res = stt }));
        }
Пример #8
0
        public ActionResult UpdateContent(int id)
        {
            var model = new ContentDAO().ContentDetail(id);

            SetViewBag();
            return(View(model));
        }
Пример #9
0
        public JsonResult DeleteContent(int Id)
        {
            var  dao = new ContentDAO();
            bool msg = dao.DeleteContent(Id);

            return(Json(new { mes = msg }));
        }
Пример #10
0
        public ActionResult GetDetail(long id)
        {
            var model = new ContentDAO().GetContentByID(id);

            ViewBag.Tags = new ContentDAO().GetTagByContent(model.ID);
            return(View(model));
        }
 public ActionResult Edit(Content contentChange, string trangthai)
 {
     SetViewBagEditNews();
     if (ModelState.IsValid)
     {
         if (trangthai == "Mở")
         {
             contentChange.Status = true;
         }
         else
         {
             contentChange.Status = false;
         }
         contentChange.ModifiedBy   = BaseController.NguoiDungHienTai.UserAccount;
         contentChange.ModifiedDate = DateTime.Now.ToString();
         ContentDAO contentDAO = new ContentDAO();
         var        id         = contentDAO.Sua(contentChange);
         if (id == 1)
         {
             TempData["msg"] = MessageBox.Show("Edit Thành Công");
             return(RedirectToAction("Index", "Content"));
         }
         else
         {
             ModelState.AddModelError("", "Edit không thành công");
         }
     }
     return(View("Edit"));
 }
Пример #12
0
        public ActionResult DetailNewsContent(long iddetailconn)
        {
            ContentDAO content = new ContentDAO();
            Content    cont    = content.ViewDetail((int)iddetailconn);

            return(View(cont));
        }
Пример #13
0
        public JsonResult GetContentByID(int Id)
        {
            var dao  = new ContentDAO();
            var data = dao.GetContentByID(Id);

            return(Json(new { data = data }, JsonRequestBehavior.AllowGet));
        }
Пример #14
0
        public PartialViewResult ListCNews(long idconn)
        {
            ContentDAO     content = new ContentDAO();
            List <Content> listCon = content.ListConCategory(idconn);

            return(PartialView(listCon));
        }
        public ActionResult Tags(string tagID, int page = 1, int pageSize = 1)
        {
            var model = new ContentDAO().ListAllContentByTag(tagID, page, pageSize);

            ViewBag.Tag = new ContentDAO().GetTag(tagID);
            return(View(model));
        }
Пример #16
0
        // GET: Admin/Content
        public ActionResult Index()
        {
            var dao   = new ContentDAO();
            var model = dao.ListAll();

            return(View(model));
        }
        public ActionResult Remove(int id)
        {
            ContentDAO contentDAO = new ContentDAO();

            contentDAO.Remove(id);
            return(RedirectToAction("Index", "Content"));
        }
Пример #18
0
        // GET: Admin/Content
        public ActionResult Index()
        {
            var            dao   = new ContentDAO();
            List <Content> model = dao.listContentAdmin();

            return(View(model));
        }
Пример #19
0
        public ActionResult UpdateContent(Content model)
        {
            if (ModelState.IsValid)
            {
                var dao = new ContentDAO();
                if (model.TopHot == true)
                {
                    bool TopHotExist = dao.TopHotForUpdate(model.ID);
                    if (!TopHotExist)
                    {
                        UserLogin userlogin = (UserLogin)Session["USER_SESSION"];
                        model.ModifiedBy   = userlogin.UserName;
                        model.ModifiedDate = DateTime.Now;
                        string metatitle = CastString.Cast(model.Name);
                        model.MetaTitle = metatitle;
                        bool result = dao.UpdateContent(model);
                        if (result)
                        {
                            SetAltert("Cập nhật thành công", 0);
                            return(RedirectToAction("Index", "Content"));
                        }
                        else
                        {
                            //Trường hợp cập nhật không thành công
                            SetAltert("Cập nhật không thành công, vui lòng thử lại", 2);
                        }
                    }
                    else
                    {
                        SetAltert("Tạm thời không thể thiết lập tin này là TopHot, vì đang có tin TopHop", 2);
                    }
                }
                else
                {
                    UserLogin userlogin = (UserLogin)Session["USER_SESSION"];
                    model.ModifiedBy   = userlogin.UserName;
                    model.ModifiedDate = DateTime.Now;
                    string metatitle = CastString.Cast(model.Name);
                    model.MetaTitle = metatitle;
                    bool result = dao.UpdateContent(model);
                    if (result)
                    {
                        SetAltert("Cập nhật thành công", 0);
                        return(RedirectToAction("Index", "Content"));
                    }
                    else
                    {
                        //Trường hợp cập nhật không thành công
                        SetAltert("Cập nhật không thành công, vui lòng thử lại", 2);
                    }
                }
            }
            else
            {
            }

            SetViewBag();
            return(View());
        }
Пример #20
0
        public ActionResult Edit(long id)
        {
            SetViewBag();
            var dao     = new ContentDAO();
            var Content = dao.GetContentByID(id);

            return(View(Content));
        }
Пример #21
0
        // GET: Admin/Content
        public ActionResult Index(string searchString, int page = 1, int pageSize = 10)
        {
            var DAO   = new ContentDAO();
            var model = DAO.ListAllContent(searchString, page, pageSize);

            ViewBag.SearchString = searchString;
            return(View(model));
        }
Пример #22
0
        public ActionResult Edit(long id)
        {
            var dao     = new ContentDAO();
            var content = dao.GetByID(id); //lấy giá trị id truyền vào Content

            SetViewBag(content.CategoryID);
            return(View(content));
        }
Пример #23
0
        // GET: Admin/Content
        public ActionResult Index(string search, int page = 1, int pageSize = 4)
        {
            var dao   = new ContentDAO();
            var model = dao.ListAllPaging(search, page, pageSize); //truyền page và pageSize vàoo

            ViewBag.search = search;
            return(View(model));
        }
Пример #24
0
        public ActionResult Edit(long ID)
        {
            var DAO     = new ContentDAO();
            var content = DAO.getByID(ID);

            setViewBag(content.CategoryID);
            return(View());
        }
Пример #25
0
        public ActionResult Edit(long id)
        {
            var dao     = new ContentDAO();
            var content = dao.GetById(id);

            SetViewBag(content.IDContentCategory);
            return(View());
        }
Пример #26
0
        public ActionResult Details(int id)
        {
            var newsdetail      = new ContentDAO().GetContentByID(id);
            var categoryCurrent = new NewsCategoryDAO().GetDetailByID((int)newsdetail.CategoryID);

            ViewBag.CategoryCurrent = categoryCurrent;
            return(View(newsdetail));
        }
        public ActionResult Edit(long id)
        {
            var dao     = new ContentDAO();
            var content = dao.GetByID(id);

            Setviewbag(content.CategoryID);
            return(View(content));
        }
Пример #28
0
        public ActionResult ViewContentDetail(long id)
        {
            var dao   = new ContentDAO();
            int ID    = Convert.ToInt32(id);
            var model = dao.ContentDetail(ID);

            return(View(model));
        }
        public ActionResult Edit(int idContentEdit)
        {
            SetViewBagEditNews();
            ContentDAO contentDAO    = new ContentDAO();
            var        ContentChange = contentDAO.TimContent(idContentEdit);

            return(View(ContentChange));
        }
        // GET: Admin/Content
        public ActionResult Index(string searchString, int page = 1, int pagesize = 10)
        {
            var dao   = new ContentDAO();
            var model = dao.ListAllPage(searchString, page, pagesize);

            ViewBag.SearchString = searchString;
            return(View(model));
        }