Пример #1
0
        public ActionResult c(int id, int?p)
        {
            int            pageindex = p ?? 1;
            int            pagesize  = 20;
            int            total     = 0;
            JavaDLL        dll       = new JavaDLL();
            DataSet        userds    = dll.getAllUser();
            ArticleEx      mod       = new ArticleEx();
            Article        art       = dll.getArticleNotRead(id);
            List <Comment> comments  = dll.getComments(id, pagesize, pageindex, out total);
            //linq级联查询
            var comment = from u in userds.Tables[0].AsEnumerable()
                          join c in comments on u["name"].ToString() equals c.uid
                          orderby c.cdate descending
                          select new Comment {
                id = c.id, aid = c.aid, sid = u["name"].ToString(), uid = u["nickname"].ToString(), comment = Convert.ToBoolean(u["valid"]) ? c.comment : "<span>用户被屏蔽,内容自动删除</span>", cdate = c.cdate, device = c.device, head = u["head"].Equals(DBNull.Value) ? "/images/head.jpg" : u["head"].ToString()
            };

            comments = comment.ToList <Comment>();
            PagedList <Comment> page = comments.AsQueryable().ToPagedList(pageindex, pagesize);

            page.TotalItemCount   = total;
            page.CurrentPageIndex = pageindex;
            mod.id       = id;
            mod.category = art.category;
            mod.title    = art.title;
            mod.comments = page;
            return(View(mod));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            ArticleEx articleEx = db.Articles.Find(id);

            db.Articles.Remove(articleEx);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult DeleteConfirmed(int?id)
        {
            ArticleExContext db      = new ArticleExContext();
            ArticleEx        article = db.Articles.Find(id);

            db.Articles.Remove(article);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #4
0
 public ActionResult Edit([Bind(Include = "Id,Title,ImageURL,Text,Author,PublishTime,Published")] ArticleEx articleEx)
 {
     if (ModelState.IsValid)
     {
         db.Entry(articleEx).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(articleEx));
 }
Пример #5
0
        public ActionResult Create([Bind(Include = "Id,Title,ImageURL,Text,Author,PublishTime,Published")] ArticleEx articleEx)
        {
            if (ModelState.IsValid)
            {
                db.Articles.Add(articleEx);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(articleEx));
        }
Пример #6
0
 public ActionResult Create(ArticleEx article)
 {
     if (ModelState.IsValid)
     {
         ArticleExContext db = new ArticleExContext();
         db.Articles.Add(article);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View());
 }
Пример #7
0
 public ActionResult Edit(ArticleEx article)
 {
     if (ModelState.IsValid)
     {
         ArticleExContext db = new ArticleExContext();
         db.Entry(article).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(RedirectToAction("Index"));
 }
Пример #8
0
        // GET: Novi/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArticleEx articleEx = db.Articles.Find(id);

            if (articleEx == null)
            {
                return(HttpNotFound());
            }
            return(View(articleEx));
        }
Пример #9
0
        //action metoda za uređivanje postojecih clanaka

        public ActionResult Edit(int?Id)
        {
            if (Id == null)
            {
                return(HttpNotFound());
            }
            ArticleExContext db      = new ArticleExContext();
            ArticleEx        article = db.Articles.Find(Id);

            if (article == null)
            {
                return(HttpNotFound());
            }
            return(View(article));
        }
Пример #10
0
 //delete action metoda -prikazuje detalje i trazi potvrdu brisanja
 //http get metoda
 public ActionResult Delete(int?id)
 {
     if (id == null)
     {
         return(HttpNotFound());
     }
     else
     {
         ArticleExContext db      = new ArticleExContext();
         ArticleEx        article = db.Articles.Find(id);
         if (article == null)
         {
             return(HttpNotFound());
         }
         return(View(article));
     }
 }