< Summary

Information
Class: Services.FeedPriceServices.FeedPriceResult
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/FeedPriceServices/FeedPriceModels.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 77
Line coverage: 100%
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
get_ArticleKeys()100%11100%
get_Current()100%11100%
get_History()100%11100%
get_Error()100%11100%
get_Found()100%11100%
get_ForOrder()100%11100%
WithOrder(...)100%11100%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/FeedPriceServices/FeedPriceModels.cs

#LineLine coverage
 1namespace Services.FeedPriceServices;
 2
 3/// <summary>Один согласованный снимок фида: текущие данные и история.</summary>
 4public sealed record FeedPriceSnapshot(
 5    IReadOnlyList<FeedCurrentRow> Current,
 6    IReadOnlyList<FeedHistoryRow> History);
 7
 8/// <summary>
 9/// Текущие строки фида по ключам одной пачки. Ключ без строк в <see cref="Rows"/> есть, но список пуст (его нет в фиде)
 10/// ключи из <see cref="Failed"/> получить не удалось — строк по ним нет и им нельзя доверять как «нет в фиде».
 11/// </summary>
 12public sealed record FeedRowsResult(
 13    IReadOnlyDictionary<string, IReadOnlyList<FeedCurrentRow>> Rows,
 14    IReadOnlySet<string> Failed);
 15
 16/// <summary>Строка «сейчас»: склад кабинета с остатком и цена артикула в этом кабинете (цена общая для всех складов).</
 17public sealed class FeedCurrentRow
 18{
 19    public string Cabinet { get; init; } = string.Empty;
 20    public string CabinetName => FeedCabinets.DisplayName(Cabinet);
 21    public string Article { get; init; } = string.Empty;
 22    public string? Warehouse { get; init; }
 23    public int? Stock { get; init; }
 24    public string? StockSupplier { get; init; }
 25    public decimal? Price { get; init; }
 26    public decimal? OldPrice { get; init; }
 27    public decimal? MinPrice { get; init; }
 28    public decimal? PurchasePrice { get; init; }
 29    public string? PriceWarehouse { get; init; }
 30    public string? PriceSupplier { get; init; }
 31    public long? RunId { get; init; }
 32    public DateTimeOffset UpdatedAt { get; init; }
 33
 34    /// <summary>Склад, с которого рассчитана цена кабинета.</summary>
 35    public bool IsPriceWarehouse =>
 36        !string.IsNullOrEmpty(Warehouse) && string.Equals(Warehouse, PriceWarehouse, StringComparison.OrdinalIgnoreCase)
 37}
 38
 39/// <summary>Строка истории: цена артикула в одном прогоне сборки кабинета.</summary>
 40public sealed class FeedHistoryRow
 41{
 42    public long RunId { get; init; }
 43    public DateTimeOffset AssembledAt { get; init; }
 44    public string AssembledBy { get; init; } = string.Empty;
 45    public string Cabinet { get; init; } = string.Empty;
 46    public string CabinetName => FeedCabinets.DisplayName(Cabinet);
 47    public string Article { get; init; } = string.Empty;
 48    public decimal? Price { get; init; }
 49    public decimal? OldPrice { get; init; }
 50    public long? TotalStock { get; init; }
 51
 52    /// <summary>Изменение цены к предыдущему прогону этого кабинета; null, если сравнивать не с чем.</summary>
 53    public decimal? PriceDelta { get; set; }
 54}
 55
 56/// <summary>Ответ для модалки: ошибка БД возвращается в модели, чтобы окно не падало.</summary>
 57public sealed class FeedPriceResult
 58{
 2459    public IReadOnlyList<string> ArticleKeys { get; init; } = Array.Empty<string>();
 2760    public IReadOnlyList<FeedCurrentRow> Current { get; init; } = Array.Empty<FeedCurrentRow>();
 2461    public IReadOnlyList<FeedHistoryRow> History { get; init; } = Array.Empty<FeedHistoryRow>();
 1062    public string? Error { get; init; }
 363    public bool Found => Current.Count > 0;
 64
 65    /// <summary>Строка, подходящая клиенту и складу заказа; заполняется только для запроса по заказу.</summary>
 566    public FeedOrderPick? ForOrder { get; init; }
 67
 68    /// <summary>Копия ответа с выбранной строкой: закешированный общий ответ не меняется.</summary>
 269    public FeedPriceResult WithOrder(FeedOrderPick pick) => new()
 270    {
 271        ArticleKeys = ArticleKeys,
 272        Current = Current,
 273        History = History,
 274        Error = Error,
 275        ForOrder = pick
 276    };
 77}