< Summary

Information
Class: Services.DataServices.OzonPushNotificationDataService
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/DataServices/OzonPushNotificationDataService.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 100
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
AddAsync()100%210%
GetByIdAsync()100%210%
GetByPostingNumberAsync()100%210%
GetByMessageTypeAsync()100%210%
UpdateAsync()100%210%
GetRecentAsync()100%210%
GetBySellerIdAsync()100%210%
GetFilteredAsync()100%210%
GetDistinctMessageTypesAsync()100%210%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/DataServices/OzonPushNotificationDataService.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Threading;
 4using System.Threading.Tasks;
 5using OzonDomains.Models;
 6using OzonRepositories.Data;
 7
 8namespace Services.DataServices
 9{
 10    /// <summary>
 11    /// Сервис доступа к данным push-уведомлений Ozon.
 12    /// Обёртка над <see cref="OzonPushNotificationRepository"/> в соответствии
 13    /// с паттерном DataService, принятым в проекте (тонкий слой делегирования).
 14    /// </summary>
 15    public class OzonPushNotificationDataService
 16    {
 17        private readonly OzonPushNotificationRepository _repository;
 18
 019        public OzonPushNotificationDataService(OzonPushNotificationRepository repository)
 20        {
 021            _repository = repository;
 022        }
 23
 24        /// <summary>
 25        /// Добавляет новую запись о push-уведомлении в базу данных.
 26        /// </summary>
 27        public async Task<int> AddAsync(OzonPushNotification notification, CancellationToken ct = default)
 028            => await _repository.AddAsync(notification, ct);
 29
 30        /// <summary>
 31        /// Возвращает запись по первичному ключу.
 32        /// </summary>
 33        public async Task<OzonPushNotification?> GetByIdAsync(long id, CancellationToken ct = default)
 034            => await _repository.GetByIdAsync(id, ct);
 35
 36        /// <summary>
 37        /// Возвращает все уведомления по номеру отправления.
 38        /// </summary>
 39        public async Task<List<OzonPushNotification>> GetByPostingNumberAsync(
 40            string postingNumber,
 41            CancellationToken ct = default)
 042            => await _repository.GetByPostingNumberAsync(postingNumber, ct);
 43
 44        /// <summary>
 45        /// Возвращает уведомления заданного типа в указанном диапазоне дат.
 46        /// </summary>
 47        public async Task<List<OzonPushNotification>> GetByMessageTypeAsync(
 48            string messageType,
 49            DateTime? from = null,
 50            DateTime? to = null,
 51            CancellationToken ct = default)
 052            => await _repository.GetByMessageTypeAsync(messageType, from, to, ct);
 53
 54        /// <summary>
 55        /// Обновляет запись о push-уведомлении.
 56        /// Вызывается фоновым заданием Hangfire после завершения бизнес-логики обработчика.
 57        /// </summary>
 58        public async Task<int> UpdateAsync(OzonPushNotification notification, CancellationToken ct = default)
 059            => await _repository.UpdateAsync(notification, ct);
 60
 61        /// <summary>
 62        /// Возвращает последние N уведомлений.
 63        /// </summary>
 64        public async Task<List<OzonPushNotification>> GetRecentAsync(
 65            int count = 100,
 66            CancellationToken ct = default)
 067            => await _repository.GetRecentAsync(count, ct);
 68
 69        /// <summary>
 70        /// Возвращает уведомления по идентификатору продавца в указанном диапазоне дат.
 71        /// </summary>
 72        public async Task<List<OzonPushNotification>> GetBySellerIdAsync(
 73            long sellerId,
 74            DateTime? from = null,
 75            DateTime? to = null,
 76            CancellationToken ct = default)
 077            => await _repository.GetBySellerIdAsync(sellerId, from, to, ct);
 78
 79        /// <summary>
 80        /// Возвращает уведомления с комбинированной фильтрацией.
 81        /// </summary>
 82        public async Task<List<OzonPushNotification>> GetFilteredAsync(
 83            string? messageType = null,
 84            long? sellerId = null,
 85            string? processingStatus = null,
 86            string? postingNumber = null,
 87            DateTime? from = null,
 88            DateTime? to = null,
 89            int take = 500,
 90            CancellationToken ct = default)
 091            => await _repository.GetFilteredAsync(messageType, sellerId, processingStatus, postingNumber, from, to, take
 92
 93        /// <summary>
 94        /// Возвращает все уникальные типы уведомлений, присутствующие в базе.
 95        /// </summary>
 96        public async Task<List<string>> GetDistinctMessageTypesAsync(CancellationToken ct = default)
 097            => await _repository.GetDistinctMessageTypesAsync(ct);
 98    }
 99}
 100