/// <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; } }
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"); }
/// <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) }); }