Exemplo n.º 1
0
        public ActionResult DeleteNews(string actiondelete)
        {
            if (Session["Quantri-website-Quantrivien"] == null)
            {
                Response.Redirect("/");
            }
            _9d_new item = accountContext._9d_news.Where(c => c.news_id == Convert.ToInt32(actiondelete)).FirstOrDefault();

            item.delete_flag = true;
            try
            {
                accountContext.SubmitChanges();
            }
            catch (Exception)
            {
                throw;
            }
            return(RedirectToAction("Newsmanager", "Home"));
        }
Exemplo n.º 2
0
        public ActionResult Newspost(FormCollection collection)
        {
            if (Session["Quantri-website-Quantrivien"] == null)
            {
                Response.Redirect("/");
            }

            string name        = collection["newsName"].ToString();
            string description = collection["newsDescription"].ToString();
            string content     = collection["newsContent"].ToString();
            string urlimage    = collection["newsImages"].ToString();
            int    type        = Convert.ToInt32(collection["MovieType"].ToString());

            if (name == "" || description == "" || content == "" || urlimage == "")
            {
                TempData["errornews"] = "Vui lòng nhập đủ thông tin.";
                return(View());
            }

            _9d_new news = new _9d_new();

            news.news_title        = name;
            news.type              = type;
            news.news_descriptions = description;
            news.news_content      = content;
            news.created_at        = DateTime.Now;
            news.created_by        = "Admin";
            news.delete_flag       = false;
            news.news_images       = urlimage;
            news.news_ascii        = Utility.RemoveAscii(Utility.RemoveSign4VietnameseString(name));
            accountContext._9d_news.InsertOnSubmit(news);
            try
            {
                accountContext.SubmitChanges();
                return(RedirectToAction("Newsmanager"));
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        //
        // GET: /News/

        public ActionResult Index(string nameascii)
        {
            if (nameascii == "")
            {
                return(RedirectToAction("Index", "Home"));
            }


            _9d_new news = accountContext._9d_news.Where(c => c.news_ascii == nameascii && c.delete_flag == false).FirstOrDefault();

            ViewBag.newstitle       = news.news_title;
            ViewBag.newsascii       = news.news_ascii;
            ViewBag.newsimages      = news.news_images;
            ViewBag.newsdescription = news.news_descriptions;
            ViewBag.newscontent     = news.news_content;
            ViewBag.newscreateat    = news.created_at;
            ViewBag.newscreateby    = news.created_by;
            List <_9d_new> listNews = accountContext._9d_news.Where(c => c.delete_flag == false).OrderByDescending(c => c.created_at).ToList();

            return(View(listNews));
        }