| | | 1 | | using Services.FidSupplierLinkServices; |
| | | 2 | | |
| | | 3 | | namespace OzonOrdersWeb.Areas.Studio2.ViewModels.FidSupplierLink; |
| | | 4 | | |
| | | 5 | | public sealed class FidSupplierLinkIndexViewModel |
| | | 6 | | { |
| | 0 | 7 | | public FidSupplierLinkOverview Overview { get; init; } = new([], 0, 0, 0, null, null); |
| | 0 | 8 | | public IReadOnlyList<FidProviderOption> Providers { get; init; } = []; |
| | 0 | 9 | | public bool CanEdit { get; init; } |
| | | 10 | | |
| | | 11 | | /// <summary>Строки и счётчики для грида AG Grid (начальная загрузка и «Обновить из фида»).</summary> |
| | 0 | 12 | | public FidSupplierLinkGridData ToGridData() => FidSupplierLinkGridData.From(Overview); |
| | | 13 | | } |
| | | 14 | | |
| | | 15 | | public sealed record FidSupplierLinkGridData( |
| | | 16 | | IReadOnlyList<FidSupplierLinkGridRow> Rows, int LinkedCount, int UnlinkedCount, int OrphanCount, string? FeedError, |
| | | 17 | | IReadOnlyList<string>? NewSupplierNames = null) |
| | | 18 | | { |
| | | 19 | | public static FidSupplierLinkGridData From(FidSupplierLinkOverview overview, IReadOnlyList<string>? newSupplierNames |
| | | 20 | | overview.Rows.Select(FidSupplierLinkGridRow.From).ToList(), |
| | | 21 | | overview.LinkedCount, overview.UnlinkedCount, overview.OrphanCount, overview.FeedError, newSupplierNames); |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | public sealed record FidSupplierLinkGridWarehouse(string Name, long Rows, bool IsEnabled); |
| | | 25 | | |
| | | 26 | | /// <summary>Строка грида связей с фидом: состояние — строкой (для set-фильтра), склады — для справки.</summary> |
| | | 27 | | public sealed record FidSupplierLinkGridRow( |
| | | 28 | | string Name, string? ProviderKey, string? Note, string State, long? Rows, long? FidRowsAtLink, |
| | | 29 | | DateTime? LastImportedAtUtc, IReadOnlyList<FidSupplierLinkGridWarehouse> Warehouses, bool IsAutoCartEnabled) |
| | | 30 | | { |
| | | 31 | | public static FidSupplierLinkGridRow From(FidSupplierLinkRow row) => new( |
| | | 32 | | row.FidSupplierName, row.ProviderKey, row.Note, row.State.ToString(), row.Rows, row.FidRowsAtLink, |
| | | 33 | | row.LastImportedAtUtc, |
| | | 34 | | row.Warehouses.Select(w => new FidSupplierLinkGridWarehouse(w.Name, w.Rows, w.IsEnabled)).ToList(), |
| | | 35 | | row.IsAutoCartEnabled); |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | public sealed record FidProviderOption(string ProviderKey, string DisplayName, string? LogoUrl, string? DirectionTag, st |