public void DeleteDocumentCategory(DocumentCategory documentCategory)
        {
            var documents = DocumentService.GetDocuments().Where(d => d.DocumentCategory.DocumentCategoryId == documentCategory.DocumentCategoryId).ToArray();
            for (int i = 0; i < documents.Count(); i++) {

                documents[i].DocumentCategory = null;
                DocumentService.UpdateDocument(documents[i]);
            }

            DocumentCategoryRepository.Delete(documentCategory);
            SaveDocumentCategory();
        }
        public ActionResult Create(CreateViewModel createViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(createViewModel);
            }

            var documentCategory = new DocumentCategory()
            {
                Name = createViewModel.Name,
                Description = createViewModel.Description,
            };
            DocumentCategoryService.CreateDocumentCategory(documentCategory);
            TempData["DocumentCategoryId"] = documentCategory.DocumentCategoryId;
            TempData["DocumentCategoryName"] = documentCategory.Name;
            TempData["Message"] = DocumentCategoriesMessage.CreateSuccess;
            return RedirectToAction("index", "documentcategories");
        }
 public void UpdateDocumentCategory(DocumentCategory documentCategory)
 {
     DocumentCategoryRepository.Update(documentCategory);
     SaveDocumentCategory();
 }
 public void CreateDocumentCategory(DocumentCategory documentCategory)
 {
     DocumentCategoryRepository.Add(documentCategory);
     SaveDocumentCategory();
 }