示例#1
0
 /// <summary>
 /// Adds a new category.
 /// </summary>
 /// <param name="category"></param>
 /// <returns></returns>
 public int AddCategory(Category category)
 {
     using (var tran = _session.BeginTransaction())
     {
         _session.Save(category);
         tran.Commit();
         return category.Id;
     }
 }
示例#2
0
        public ContentResult EditCategory(Category category)
        {
            string json;

              if (ModelState.IsValid)
              {
            _blogRepository.EditCategory(category);
            json = JsonConvert.SerializeObject(new
            {
              id = category.Id,
              success = true,
              message = "Changes saved successfully."
            });
              }
              else
              {
            json = JsonConvert.SerializeObject(new
            {
              id = 0,
              success = false,
              message = "Failed to save the changes."
            });
              }

              return Content(json, "application/json");
        }
示例#3
0
 /// <summary>
 /// Update an existing category.
 /// </summary>
 /// <param name="category"></param>
 public void EditCategory(Category category)
 {
     using (var tran = _session.BeginTransaction())
     {
         _session.SaveOrUpdate(category);
         tran.Commit();
     }
 }
 public static MvcHtmlString CategoryLink(this HtmlHelper helper, Category category)
 {
     return helper.ActionLink(category.Name, "Category", "Blog", new { category = category.UrlSlug }, new { title = String.Format("See all posts in {0}", category.Name) });
 }