public ActionResult AddContentCategory(ContentCategory contentCate)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.ContentCategories.InsertOnSubmit(contentCate);
     db.SubmitChanges();
     return RedirectToAction("ListContentCategories");
 }
        public ActionResult Edit(int id, ContentCategory category, FormCollection collection)
        {
            try
            {
                if (!ModelState.IsValid){ 
                    ViewData["Categories"] = CustomSelectList.CreateListCategories(true);
                    ViewData["Status"] = CustomSelectList.CreateEntityStatus();
                    return View(category);

                };
                // TODO: Add update logic here
                new CategoryService().Update(id, category);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Create(ContentCategory category, FormCollection collection)
        {
            try
            {
                if (!ModelState.IsValid) {
                    ViewData["Categories"] = CustomSelectList.CreateListCategories(true);
                    return View(category);
                }

                new CategoryService().Create(category);

               
                return RedirectToAction("List");
            }
            catch(Exception ex){
                ModelState.AddModelError("Exception", ex);
            }
            ViewData["Categories"] = CustomSelectList.CreateListCategories(true);
            return View(category);
        }
 public ActionResult EditContentCategory(int id, ContentCategory contentCate)
 {
     DBNLDataContext db = new DBNLDataContext();
     ContentCategory updContentCate = db.ContentCategories.Where(p => p.ID == id).SingleOrDefault();
     updContentCate.CategoryName = contentCate.CategoryName;
     updContentCate.Key = contentCate.Key;
     updContentCate.ParentCategoryId = contentCate.ParentCategoryId;
     db.SubmitChanges();
     return RedirectToAction("ListContentCategories");
 }
 partial void DeleteContentCategory(ContentCategory instance);
 partial void UpdateContentCategory(ContentCategory instance);
 partial void InsertContentCategory(ContentCategory instance);
		private void detach_ContentCategories(ContentCategory entity)
		{
			this.SendPropertyChanging();
			entity.ContentCategory1 = null;
		}