Exemplo n.º 1
0
 public ActionResult Edit(Article article)
 {
     if (ModelState.IsValid)
     {
         article.Author = CurrentUser();
         if (article.ManuallySetLastUpdated != null)
         {
             article.LastUpdated = article.ManuallySetLastUpdated.Value;
         }
         daoTemplate.Save(article);
         return Redirect("/Article/Details/" + article.Id);
     }
     return View(article);
 }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            ViewData["categories"] = CategoryService.FindRootCategories().Where(cat => cat.IsVisible && cat.ParentIsVisible);

            var criteria = DetachedCriteria.For(typeof (Article));
            criteria.Add(Restrictions.Eq(Article.PlacementProperty, ArticlePlacement.News));
            criteria.AddOrder(Order.Desc(Article.LastUpdatedProperty));
            criteria.SetMaxResults(1);
            var articles = daoTemplate.FindByCriteria<Article>(criteria);
            if (articles.Count > 0)
                ViewData["news"] = articles[0];
            else
                ViewData["news"] = new Article();

            SetNewsArticleToViewData();

            return View();
        }
Exemplo n.º 3
0
 public void TestArticle()
 {
     ISession session = GetConfiguration().BuildSessionFactory().OpenSession();
     Article article = new Article() {Text = "123", Title = "56"};
     session.Save(article);
 }