/// <summary> /// Gets list of all attachments model for given document type and document Id. /// </summary> /// <param name="documentType">Document type for attachment</param> /// <param name="documentId">Document Id for attachment</param> /// <returns>List of attachment models</returns> public IEnumerable <Attachment> GetAttachmentsForDocument(DocumentType documentType, string documentId) { if (string.IsNullOrWhiteSpace(documentId)) { throw new ArgumentNullException(nameof(documentId), "Nieprawidłowe parametry"); } if (documentType == DocumentType.Budget) { BudgetManager.GetBudgetById(documentId, IncludeLevel.None); } else if (documentType == DocumentType.Invoice) { InvoiceManager.GetInvoiceById(documentId, IncludeLevel.None); } var attachments = Context.Attachments .Where(x => x.Status == Status.Opened) .Where(x => x.DocumentType == documentType && x.DocumentId == documentId); return(attachments); }