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"));
            }
        }
        private void BuildMenuConventionsCGP(Guid idFirmInstitutionCGP)
        {
            try
            {
                ElectronicSafeDocumentBL.DocumentType[] arrays = new ElectronicSafeDocumentBL.DocumentType[]
                {
                    ElectronicSafeDocumentBL.DocumentType.CPART,ElectronicSafeDocumentBL.DocumentType.CINT,ElectronicSafeDocumentBL.DocumentType.CCOURT,ElectronicSafeDocumentBL.DocumentType.CCOMP
                };

                List<DocumentCategoryViewModel> listCategoryViewModels = new List<DocumentCategoryViewModel>();
                for (var i = 0; i < arrays.Length; i++)
                {
                    IList<ElectronicSafeDocument> lstElectronicSafeDocs = ElectronicSafeDocumentBL.GetConventionDocuments(idFirmInstitutionCGP, arrays[i]);
                    if (lstElectronicSafeDocs != null)
                    {
                        var docCat = new DocumentCategoryViewModel()
                        {
                            Label = string.Format("convention_{0}", arrays[i].ToString().ToLower()),
                            DocumentCategoryNumber = lstElectronicSafeDocs.Count,
                            Route = (object)new { documentTypeCode = arrays[i] },
                            Code = arrays[i].ToString().ToLower()
                        };
                        listCategoryViewModels.Add(docCat);
                    }
                }
                SessionManager.Set<List<DocumentCategoryViewModel>>(DOCUMENTS_CONVENTIONS_CGP, listCategoryViewModels);
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                Business.Log.Log.AppendException(ex);
            }
        }
        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>());
        }
        private void BuildMenuAvenantCGP(Guid idFirmInstitutionCGP)
        {
            try
            {
                IList<ElectronicSafeDocument> lstElectronicSafeDocs = ElectronicSafeDocumentBL.GetConventionDocuments(idFirmInstitutionCGP, ElectronicSafeDocumentBL.DocumentType.AVENANT);
                var docCat = new DocumentCategoryViewModel()
                {
                    Label = "avenants",
                    DocumentCategoryNumber = lstElectronicSafeDocs.Count,
                    Route = (object)new { documentTypeCode = ElectronicSafeDocumentBL.DocumentType.AVENANT },
                    Code = ElectronicSafeDocumentBL.DocumentType.AVENANT.ToString().ToLower()
                };

                SessionManager.Set<DocumentCategoryViewModel>(DOCUMENTS_AVENANTS_CGP, docCat);
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                Business.Log.Log.AppendException(ex);
            }
        }