private async Task <IEnumerable <T> > GetDocuments <T>(DocumentType documentType, bool loadImags = true) where T : IDocument { var items = await GetDocuments(documentType); List <Image> images = null; if (loadImags) { images = await GetImages(); } var typedItems = items.Select(x => { try { T docObje = x.Deserialize <T>(new CreationConverter()); docObje.Document = x; if (loadImags) { x.Images = images.Where(i => i.DocumentId == x.Id).ToList(); } return(docObje); } catch (Exception) { return(default(T)); } }); return(typedItems); }
public async Task <IEnumerable <Document> > GetDocuments(DocumentType documentType = null) { var items = Get <Document>(name: ClassLookup.Document); if (documentType != null) { items = items.Where(x => x.DocumentTypeId == documentType); } return(items); }