public TTarget GetContent <TTarget>(DocumentIndexModel indexItem, bool filterOnCulture = true) where TTarget : ContentData { if (indexItem == null || string.IsNullOrEmpty(indexItem.Id)) { return(default(TTarget)); } Guid result; if (Guid.TryParse(((IEnumerable <string>)indexItem.Id.Split('|')).FirstOrDefault <string>(), out result)) { LoaderOptions loaderOptions; if (filterOnCulture) { loaderOptions = this.GetLoaderOptions(indexItem.Language); } else { loaderOptions = new LoaderOptions(); loaderOptions.Add <LanguageLoaderOption>(LanguageLoaderOption.Fallback((CultureInfo)null)); } LoaderOptions settings = loaderOptions; TTarget content = null; this._contentRepository.TryGet <TTarget>(result, settings, out content); return(content); } return(default(TTarget)); }
public async Task <IActionResult> Index() { var years = _documents.GetYears(); var model = new DocumentIndexModel { DocumentsCount = await _documents.DocumentsCount(), CertificatesCount = await _documents.CertificatesCount(), FailureNotificationsCount = await _documents.FailureNotificationsCount(), Years = years }; return(View(model)); }
public async Task <IActionResult> Index(DocumentIndexModel model) { var title = $"{ViewData["Title"]} - {model.Category}".Replace(" ", ""); var location = FileUploader.ProcessFormFile(_azureSettings.StorageAccount, _azureSettings.StorageAccountPassword, model.File, "documents", ModelState, title, true).Result.ToString(); _handler.Upsert( new DocumentModel() { Location = location, Type = Document.DocType.FromFileName(location), Category = model.Category, DeleteAllOthers = true } ); return(RedirectToAction(nameof(Index))); }
public IActionResult LoadDocuments(int contractId) { var result = _documents.GetDocumentsByContractId(contractId)?.Select(d => new DocumentListingModel { Id = d.Id, Year = d.Contract.Year, ContractId = d.Contract.Id, ContractNumber = d.Contract.ContractNumber, ClientId = d.Client.Id, ClientName = d.Client.Name, ExploitationPlace = d.Client.ExploitationPlace, DeviceId = d.Device.Id, DeviceType = d.Device.Type, DeviceName = d.Device.Name, SerialNumber = d.Device.SerialNumber, RegistrationNumber = d.Device.RegistrationNumber, VerificationMethodic = d.Device.VerificationMethodic?.Name, DocumentNumber = d.DocumentNumber, CalibrationDate = (d as CertificateDTO)?.CalibrationDate.ToString("dd-MM-yyyy"), CalibrationExpireDate = (d as CertificateDTO)?.CalibrationExpireDate.ToString("dd-MM-yyyy"), DocumentType = (d is CertificateDTO) ? "Свидетельство" : "Извещение о непригодности", DocumentDate = (d as FailureNotificationDTO)?.DocumentDate.ToString("dd-MM-yyyy"), CreatedOn = d.CreatedOn.ToString("dd-MM-yyyy hh:mm"), UpdatedOn = d.UpdatedOn?.ToString("dd-MM-yyyy hh:mm") ?? d.CreatedOn.ToString("dd-MM-yyyy hh:mm"), CreatedBy = d.CreatedBy, UpdatedBy = d.UpdatedBy ?? d.CreatedBy, FilePath = d.DocumentFile.Path }); var model = new DocumentIndexModel { Documents = result }; return(PartialView("_DocumentsTable", model)); }