public ActionResult Edit(Guid documentID) { ScansRepository scansRepository = new ScansRepository(); ScanBrowser scans = ScanBrowserFactory.Create(); DocumentEditViewModel viewModel = new DocumentEditViewModel() { AllowDocumentDisplay = true, Details = _repository.GetDocumentDetails(documentID), Categories = _dictRepository.GetCategories().ToList(), Senders = _dictRepository.GetSenders().ToList(), Types2 = _dictRepository.GetTypes2().ToList(), ScanSelectorModel = new ScanSelectorViewModel() { AvailableScans = scansRepository.GetAvailableScans().ToList(), AllScansCount = scans.GetScansCount(true), KnownScansCount = scans.GetScansCount(false) } }; #region Check if user can display this document if (viewModel.Details.Document == null) { viewModel.AllowDocumentDisplay = false; viewModel.DenyMessage = "Dokument nie istnieje."; } else if (!AppContext.GetCIDs().Contains(viewModel.Details.Document.ClientID)) { viewModel.AllowDocumentDisplay = false; viewModel.DenyMessage = "Nie masz uprawnieñ do tego dokumentu."; } else { if (viewModel.Details.Document.ClientID != AppContext.GetCID()) { AppContext.ChangeClient(viewModel.Details.Document.ClientID); } } #endregion if (viewModel.Details.InfoTypeOne != null && viewModel.Details.InfoTypeOne.CategoryID.HasValue) { viewModel.Types = _dictRepository.GetTypes(viewModel.Details.InfoTypeOne.CategoryID.Value).ToList(); } return(View(viewModel)); }
// [Authorize] public ActionResult Index(Guid?documentID) { DictionaryRepository dictRepository = new DictionaryRepository(); ScanBrowser scans = ScanBrowserFactory.Create(); ScansViewModel viewModel = new ScansViewModel(); viewModel.AllScansCount = scans.GetScansCount(true); viewModel.KnownScansCount = scans.GetScansCount(false); viewModel.AvailableScans = _repository.GetAvailableScans().ToList();//Context.AvailableScans.OrderByDescending(s=>s.ImportDate).ToList(); viewModel.Categories = dictRepository.GetCategories().ToList(); viewModel.Types2 = dictRepository.GetTypes2().ToList(); viewModel.Senders = dictRepository.GetSenders().OrderBy(s => s.LastName).ThenBy(s => s.FirstName).ToList(); if (documentID.HasValue) { viewModel.DocumentID = documentID; } return(View(viewModel)); }