public ActionResult Edit(int id, ContentCategoryViewModels collection)
 {
     try
     {
         if (id > 0)
         {
             if (ModelState.IsValid)
             {
                 if (collection.Id == collection.ParentId)
                 {
                     ModelState.AddModelError(string.Empty, "شما نمیتوانید دسته بندی مورد نظر را بعنوان والد خود انتخاب کنید.");
                 }
                 //else if (collection.ParentId.HasValue && _categoryService.HasProvider(collection.ParentId.Value))
                 //{
                 //    ModelState.AddModelError(string.Empty, "والد انتخابی برای این دسته بندی شامل ویژگی می باشد. شما نمیتوانید از والد انتخابی استفاده نمایید.");
                 //}
                 else
                 {
                     var model = _mapper.Map <ContentCategory>(collection);
                     model.UpdaterId = LogedInAdmin.Id;
                     _contentCategoryService.Update(model);
                     return(RedirectToAction("Index"));
                 }
             }
             else
             {
                 ModelState.AddModelError(string.Empty, GeneralMessages.DefectiveEntry);
             }
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.EmptyId);
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         if (ex.InnerException != null && ex.InnerException.Source.Equals(GeneralMessages.ExceptionSource))
         {
             ModelState.AddModelError(string.Empty, ex.Message);
         }
         else
         {
             ModelState.AddModelError(string.Empty, GeneralMessages.UnexpectedError);
         }
     }
     collection.CategoryTree = _mapper.Map <List <TreeModel> >(_contentCategoryService.Find(new ContentCategory()));
     return(View(collection));
 }