public ActionResult Add()
        {
            var vCategory = new DocumentCategoryIM()
            {
                Active     = true,
                Importance = 0
            };

            return(PartialView("_Add", vCategory));
        }
        public JsonResult Edit(DocumentCategoryIM vm)
        {
            if (!ModelState.IsValid)
            {
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }
            //var newCategory = _categoryServices.GetById(vm.Id);
            //newCategory.Title = vm.Title;
            //newCategory.SeoName = vm.SeoName;
            //newCategory.Importance = vm.Importance;
            //newCategory.Active = vm.Active;
            //newCategory.UpdatedBy = Site.CurrentUserName;
            //newCategory.UpdatedDate = DateTime.Now;
            var newCategory = _mapper.Map <DocumentCategoryIM, DocumentCategory>(vm);

            _categoryServices.Update(newCategory);

            //var pageMeta = _pageMetaServices.GetPageMeta(ModelType.DocumentCATEGORY, vm.Id.ToString());
            //pageMeta = pageMeta ?? new PageMeta();

            //pageMeta.ObjectId = vm.Id.ToString();
            //pageMeta.Title = string.IsNullOrEmpty(vm.SEOTitle) ? vm.Title : vm.SEOTitle;
            //pageMeta.Keyword = string.IsNullOrEmpty(vm.Keywords) ? vm.Title : vm.Keywords.Replace(',', ',');
            //pageMeta.Description = vm.SEODescription;
            //pageMeta.ModelType = ModelType.DocumentCATEGORY;

            //if (pageMeta.Id > 0)
            //{
            //    _pageMetaServices.Update(pageMeta);
            //}
            //else
            //{
            //    _pageMetaServices.Create(pageMeta);
            //}


            //   var category = _mapper.Map<DocumentCategoryVM>(newCategory);
            AR.Id   = newCategory.Id;
            AR.Data = RenderPartialViewToString("_CategoryItem", newCategory);

            AR.SetSuccess(String.Format(Messages.AlertUpdateSuccess, EntityNames.DocumentCategory));
            return(Json(AR, JsonRequestBehavior.DenyGet));
        }
        public JsonResult Add(DocumentCategoryIM vm)
        {
            if (!ModelState.IsValid)
            {
                AR.Setfailure(GetModelErrorMessage());
                return(Json(AR, JsonRequestBehavior.DenyGet));
            }

            var newCategory = _mapper.Map <DocumentCategoryIM, DocumentCategory>(vm);
            //newCategory.CreatedBy = Site.CurrentUserName;
            //newCategory.CreatedDate = DateTime.Now;

            var result = _categoryServices.Create(newCategory);

            //if (result != null)
            //{
            //    var pageMeta = new PageMeta()
            //    {
            //        ObjectId = result.ToString(),
            //        Title = string.IsNullOrEmpty(vm.SEOTitle) ? vm.Title : vm.SEOTitle,
            //        Keyword = string.IsNullOrEmpty(vm.Keywords) ? vm.Title : vm.Keywords.Replace(',', ','),
            //        Description = vm.SEODescription,
            //        ModelType = ModelType.DOCUMENTCATEGORY
            //    };
            //    _pageMetaServices.Create(pageMeta);
            //}


            int count;
            var pageSize = SettingsManager.Doc.PageSize;
            var list     = _categoryServices.GetPagedElements(0, pageSize, string.Empty, out count);

            AR.Data = RenderPartialViewToString("_CategoryList", list);
            AR.SetSuccess(String.Format(Messages.AlertCreateSuccess, EntityNames.DocumentCategory));
            return(Json(AR, JsonRequestBehavior.DenyGet));
        }