public ActionResult SaveDocumentCategory(DocumentCategoryViewModel postedDocumentCategoryVm)
        {
            try
            {
                DocumentCategory postedDocumentCategory = postedDocumentCategoryVm.ToEntity();
                int idDocumentCategory = 0;
                if (!string.IsNullOrEmpty(postedDocumentCategory.Label))
                {
                    var docCateg = new DocumentCategory()
                    {
                        Label = postedDocumentCategory.Label,
                        idFirmInstitution = SessionManager.GetFirmInstitutionSession().idFirmInstitution,
                        IdDocumentCategoryParent = postedDocumentCategory.IdDocumentCategoryParent,
                        DateCreated = DateTime.Now,
                        IsMandatory = postedDocumentCategory.IsMandatory,
                        IsDocumentDefault = postedDocumentCategory.IsMandatory ? postedDocumentCategory.IsMandatory : postedDocumentCategory.IsDocumentDefault,
                        IsRenseignerDateExp = postedDocumentCategory.IsRenseignerDateExp
                    };


                    DocumentCategoryBL.AddDocumentCategory(docCateg);
                    idDocumentCategory = docCateg.idDocumentCategory;
                }

                var documentCategory = new DocumentCategory();
                var lst = new List<DocumentCategory>();
                /* create sub document category */
                if (postedDocumentCategory.IdDocumentCategoryParent.HasValue && postedDocumentCategory.IdDocumentCategoryParent.Value > 0)
                {
                    documentCategory = DocumentCategoryBL.GetById(postedDocumentCategory.IdDocumentCategoryParent.Value);
                    if (documentCategory.DocumentCategory1 != null)
                    {
                        lst = documentCategory.DocumentCategory1.Where(x => !x.IsDeleted).ToList();
                    }
                    return PartialView("DocumentSubCategoryGridPartial", lst);
                }

                return PartialView("MainPartialGrid", GetDocCategory());
            }
            catch (Exception ex)
            {
               // return Content(LanguageData.GetContent("Rubric_error") + ex.Message);
                return Content("KO:" + LanguageData.GetContent("Rubric_error"));
            }
        }
        public ActionResult SaveEditDocumentCategory(DocumentCategoryViewModel postedDocumentCategoryVm)
        {
            try
            {
                DocumentCategory postedDocumentCategory = postedDocumentCategoryVm.ToEntity();
                if (postedDocumentCategory.idDocumentCategory > 0)
                {
                    var docCateg = DocumentCategoryBL.GetById(postedDocumentCategory.idDocumentCategory);
                    //docCateg.
                    if (docCateg != null)
                    {
                        docCateg.Label = postedDocumentCategory.Label;
                        docCateg.IsMandatory = postedDocumentCategory.IsMandatory;
                        docCateg.IsDocumentDefault = postedDocumentCategory.IsMandatory ? postedDocumentCategory.IsMandatory : postedDocumentCategory.IsDocumentDefault;
                        docCateg.IsRenseignerDateExp = postedDocumentCategory.IsRenseignerDateExp;

                        DocumentCategoryBL.UpdateDocumentCategory(docCateg);
                    }

                    var documentCategory = new DocumentCategory();
                    var lst = new List<DocumentCategory>();

                    /* Edit sub document category */
                    if (postedDocumentCategory.IdDocumentCategoryParent.HasValue &&
                        postedDocumentCategory.IdDocumentCategoryParent.Value > 0)
                    {
                        documentCategory = DocumentCategoryBL.GetById(postedDocumentCategory.IdDocumentCategoryParent.Value);
                        if (documentCategory.DocumentCategory1 != null)
                        {
                            lst = documentCategory.DocumentCategory1.ToList();
                        }
                        return PartialView("DocumentSubCategoryGridPartial", lst);
                    }

                    /* Edit main document category */
                    return PartialView("MainPartialGrid", GetDocCategory());
                }
            }
            catch (Exception ex)
            {
                // return Content(LanguageData.GetContent("Rubric_error") + ex.Message);
                return Content("KO:" + LanguageData.GetContent("Rubric_error"));
            }
            return PartialView("DocumentSubCategoryGridPartial", new List<DocumentCategory>());
        }