/// <summary> /// /// </summary> /// <returns></returns> public ActionResult AddEditCategory(int categoryId = -1) { try { Category model = null; if (categoryId == -1) { model = new Category(); } else { model = _blogRepository.Category(categoryId); } return PartialView("../Blog/_AddEdit_Category", model); } catch (Exception ex) { //CatchException.CatchTheException(ex); throw; } finally { } }
public int AddCategory(Category category) { using (var transactionScope = new TransactionScope()) { context.Categories.AddOrUpdate(a => a.Id, category); context.SaveChanges(); transactionScope.Complete(); return category.Id; } }
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) }); }
public JsonResult AddEditCategory(Category model) { try { int id = _blogRepository.AddCategory(model); return Json(id, JsonRequestBehavior.AllowGet); //return PartialView("../Blog/_AddEdit_Category", model); } catch (Exception ex) { //CatchException.CatchTheException(ex); throw; } finally { } }
public void EditCategory(Category category) { using (var transactionScope = new TransactionScope()) { context.Categories.AddOrUpdate(c => c.Id, category); context.SaveChanges(); transactionScope.Complete(); } }