private void ValidateOrgDocViewModel(OrganizationDocumentViewModel orgDocViewModel)
 {
     if (orgDocViewModel.Document == null)
         ModelState.AddModelError("Document", "Please select a document to upload.");
     if (orgDocViewModel.OrganizationDocumentName.Trim().IsNotNull())
     {
         var orgDocName = _wcfService.InvokeService<IOrganizationService, LibraryAsset>((svc) => svc.CheckDocExists(orgDocViewModel.OrganizationDocumentName.Trim()));
         if (orgDocName.IsNotNull())
             ModelState.AddModelError("OrganizationDocumentName", "Document name already exists.");
     }
 }
 public ActionResult OrganizationDocs()
 {
     var orgDocsViewModel = new OrganizationDocumentViewModel() { OrganizationDocumentViewModels = new List<OrganizationDocumentViewModel>() };
     var libAssets = GetOrganizationDocsFromDb();
     foreach (var libAsset in libAssets)
     {
         var orgDocViewModel = new OrganizationDocumentViewModel();
         orgDocViewModel.ImagePath = libAsset.AssetPath;
         orgDocViewModel.CreatedDate = libAsset.CreatedDate;
         orgDocViewModel.DocumentDescription = libAsset.AssetDescription;
         orgDocViewModel.OrganizationDocumentName = libAsset.AssetName;
         orgDocViewModel.OrganizationDocumentId = libAsset.Id;
        // Config
         orgDocsViewModel.OrganizationDocumentViewModels.Add(orgDocViewModel);
         // orgDocsViewModel = orgDocViewModel;
     }
     return View(orgDocsViewModel);
 }
 public ActionResult AddOrgDoc(OrganizationDocumentViewModel orgDocViewModel, string buttonType)
 {
     if (buttonType.EqualsIgnoreCase("Next"))
         return RedirectToAction("AddRole", "Dashboard");
     else
     {
         ValidateOrgDocViewModel(orgDocViewModel);
         if (orgDocViewModel != null && ModelState.IsValid)
         {
             var libraryFolder = _wcfService.InvokeService<IOrganizationService, LibraryFolder>((svc) => svc.GetDocLibraryFolder(SessionContext.CurrentUser.OrganizationId.Value));
             orgDocViewModel.OrganizationDocumentViewModels = new List<OrganizationDocumentViewModel>();
             var libAsset = GetLibraryAsset(orgDocViewModel.Document, orgDocViewModel.OrganizationDocumentName, orgDocViewModel.DocumentDescription, libraryFolder.Id);
             var libraryAssetFromDb = _wcfService.InvokeService<IOrganizationService, LibraryAsset>((svc) => svc.AddDocLibraryAsset(libAsset));
             orgDocViewModel.ImagePath = SaveImageToDisk(libraryFolder, orgDocViewModel.Document, libraryAssetFromDb.AssetName);
             orgDocViewModel.CreatedDate = libraryAssetFromDb.CreatedDate;
             orgDocViewModel.OrganizationDocumentViewModels.Add(orgDocViewModel);
         }
         return RedirectToAction("OrganizationDocs");
     }
 }