Exemplo n.º 1
0
        /// <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
            {

            }
        }
Exemplo n.º 2
0
 public int AddCategory(Category category)
 {
     using (var transactionScope = new TransactionScope())
     {
         context.Categories.AddOrUpdate(a => a.Id, category);
         context.SaveChanges();
         transactionScope.Complete();
         return category.Id;
     }
 }
Exemplo n.º 3
0
 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)
         });
 }
Exemplo n.º 4
0
        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
            {

            }
        }
Exemplo n.º 5
0
 public void EditCategory(Category category)
 {
     using (var transactionScope = new TransactionScope())
     {
         context.Categories.AddOrUpdate(c => c.Id, category);
         context.SaveChanges();
         transactionScope.Complete();
     }
 }