public async Task <List <Message> > GetAttachments(AttachmentKind kind, int conversationId, string whoAccessedId, int offset, int count) { var conversation = await conversationRepository.GetByIdAsync(conversationId); if (conversation == null) { throw new KeyNotFoundException("Wrong conversation to get attachments from."); } //only member of conversation could request messages of non-public conversation. if (!await usersConversationsRepository.Exists(whoAccessedId, conversationId) && !conversation.IsPublic) { throw new UnauthorizedAccessException("You are unauthorized to do such an action."); } var deleted = await deletedMessages.AsQuerableAsync( new GetDeletedMessagesOfUserSpec(whoAccessedId)); var messages = await messagesRepository.ListAsync( new GetSpecificAttachmentsSpec (deleted, conversationId, kind, offset, count)); return((from msg in messages select msg.ToMessage()).ToList()); }