示例#1
0
 public ViewModelCategory Delete(ViewModelCategory vCategory)
 {
     try
     {
         var thisCate = _iCategoryRepository.Find(vCategory.Id);
         if (thisCate != null)
         {
             if (thisCate.ParentId != null)
             {
                 var allChildren = _iCategoryRepository.All.Where(x => x.ParentId == vCategory.Id).ToList();
                 foreach (var i in allChildren)
                 {
                     i.ParentId = thisCate.ParentId;
                     _iCategoryRepository.InsertOrUpdate(i);
                 }
                 _iCategoryRepository.Save();
             }
             _iCategoryRepository.Delete(vCategory.Id);
             _iCategoryRepository.Save();
         }
         return vCategory;
     }
     catch (Exception e)
     {
         return null;
     }
 }
 public ActionResult RetrieveNode(ViewModelCategory vm)
 {
     var current = _iCategoryService.GetDetail(vm.Id);
     vm.ParentId = current.ParentId;
     _iCategoryService.InsertOrUpdate(vm);
     return Json("Succeed!", JsonRequestBehavior.AllowGet);
 }
 public ActionResult DeleteNode(ViewModelCategory vm)
 {
     _iCategoryService.Delete(vm);
     return Json("Succeed!", JsonRequestBehavior.AllowGet);
 }
 public ActionResult AddChildNode(ViewModelCategory vm)
 {
     _iCategoryService.InsertOrUpdate(vm);
     return Json("Succeed!",JsonRequestBehavior.AllowGet);
 }
示例#5
0
        public void InsertOrUpdate(ViewModelCategory vCategory)
        {
            try
            {
                _iCategoryRepository.InsertOrUpdate(Mapper.Map<ViewModelCategory, Category>(vCategory));
                _iCategoryRepository.Save();
            }
            catch (Exception e)
            {

            }
        }
示例#6
0
 public void AddCategory(ViewModelCategory vCategory)
 {
     _iCategoryRepository.InsertOrUpdate(Mapper.Map<ViewModelCategory, Category>(vCategory));
     _iCategoryRepository.Save();
 }