| | | 1 | | using OzonDomains.Models; |
| | | 2 | | using OzonRepositories.Data; |
| | | 3 | | using Services.EmailRoutingServices; |
| | | 4 | | |
| | | 5 | | namespace Services.DataServices; |
| | | 6 | | |
| | | 7 | | public class EmailMessageInboxDataServices : IDataServices |
| | | 8 | | { |
| | | 9 | | private readonly EmailMessageInboxRepository _repository; |
| | | 10 | | |
| | 8 | 11 | | public EmailMessageInboxDataServices(EmailMessageInboxRepository repository) |
| | | 12 | | { |
| | 8 | 13 | | _repository = repository; |
| | 8 | 14 | | } |
| | | 15 | | |
| | | 16 | | public Task<EmailMessageInbox?> GetByExternalId(string messageExternalId) |
| | | 17 | | { |
| | 5 | 18 | | return _repository.GetByExternalId(messageExternalId); |
| | | 19 | | } |
| | | 20 | | |
| | | 21 | | public Task<EmailMessageInbox?> GetByUid(string uid) |
| | | 22 | | { |
| | 5 | 23 | | return _repository.GetByUid(uid); |
| | | 24 | | } |
| | | 25 | | |
| | | 26 | | public async Task<InboxKnownMessages> GetKnownInboxMessagesAsync() |
| | | 27 | | { |
| | 7 | 28 | | return new InboxKnownMessages |
| | 7 | 29 | | { |
| | 7 | 30 | | ExternalIds = await _repository.GetAllKnownExternalIdsAsync(), |
| | 7 | 31 | | Uids = await _repository.GetAllKnownUidsAsync() |
| | 7 | 32 | | }; |
| | 7 | 33 | | } |
| | | 34 | | |
| | | 35 | | public Task<int> AddInboxMessage(EmailMessageInbox value) |
| | | 36 | | { |
| | 2 | 37 | | return _repository.Add(value); |
| | | 38 | | } |
| | | 39 | | |
| | | 40 | | public Task<int> UpdateInboxMessage(EmailMessageInbox value) |
| | | 41 | | { |
| | 2 | 42 | | return _repository.Update(value); |
| | | 43 | | } |
| | | 44 | | |
| | | 45 | | public Task<List<EmailMessageInbox>> GetPaged(int page, int pageSize) |
| | | 46 | | { |
| | 0 | 47 | | return _repository.GetPaged(page, pageSize); |
| | | 48 | | } |
| | | 49 | | |
| | | 50 | | public Task<int> GetCount() |
| | | 51 | | { |
| | 0 | 52 | | return _repository.GetCount(); |
| | | 53 | | } |
| | | 54 | | |
| | | 55 | | public Task<HashSet<string>> GetExternalIdsReceivedAfterAsync(DateTime sinceUtc) |
| | | 56 | | { |
| | 0 | 57 | | return _repository.GetExternalIdsReceivedAfterAsync(sinceUtc); |
| | | 58 | | } |
| | | 59 | | |
| | | 60 | | public Task<EmailMessageInbox?> GetMessage(int id) |
| | | 61 | | { |
| | 0 | 62 | | return _repository.GetAsync(id); |
| | | 63 | | } |
| | | 64 | | |
| | | 65 | | public Task<List<EmailMessageInbox>> GetAll() |
| | | 66 | | { |
| | 0 | 67 | | return _repository.Get(); |
| | | 68 | | } |
| | | 69 | | |
| | | 70 | | public async Task<int> SaveChanges() |
| | | 71 | | { |
| | 0 | 72 | | return await _repository.SaveChanges(); |
| | 0 | 73 | | } |
| | | 74 | | } |