Ejemplo n.º 1
0
 //
 // GET: /Article/Details/5
 public ActionResult Details(int id)
 {
     using (var db = new ArticleEntities())
     {
         return View(db.Articles.Find(id));
     }
 }
Ejemplo n.º 2
0
        private List<Article> GetLastArticles(int count)
        {
            var articlesDb = new ArticleEntities();

            return articlesDb.Articles
                .OrderByDescending(a => a.CreateDate)
                .ThenBy(a => a.DisplayOrder)
                .Where(a => a.IsDraft != true)
                .Take(count)
                .ToList();
        }
Ejemplo n.º 3
0
 public ActionResult Delete(int id, Article article)
 {
     try
     {
         using (var db = new ArticleEntities())
         {
             db.Entry(article).State = EntityState.Deleted;
             db.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     catch
     {
         return View();
     }
 }
Ejemplo n.º 4
0
 public ActionResult Create(Article article)
 {
     try
     {
         using (var db = new ArticleEntities())
         {
             article.CreateDate = DateTime.Now;
             article.EditDate = DateTime.Now;
             article.EditUser = User.Identity.Name;
             article.Text = HttpUtility.UrlDecode(article.Text, System.Text.Encoding.Default);
             db.Articles.Add(article);
             db.SaveChanges();
         }
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Ejemplo n.º 5
0
 public ActionResult Index()
 {
     using (var db = new ArticleEntities())
     {
         return View(db.Articles.ToList());
     }
 }
Ejemplo n.º 6
0
 public ActionResult Edit(int id, Article article)
 {
     try
     {
         using (var db = new ArticleEntities())
         {
             article.EditDate = DateTime.Now;
             article.EditUser = User.Identity.Name;
             article.Text = HttpUtility.UrlDecode(article.Text, System.Text.Encoding.Default);
             db.Entry(article).State = EntityState.Modified;
             db.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     catch
     {
         return View();
     }
 }