| | | 1 | | @using System.Text.Json |
| | | 2 | | @{ |
| | 0 | 3 | | var notifications = new List<object>(); |
| | | 4 | | |
| | | 5 | | string? Take(string key) |
| | | 6 | | { |
| | 0 | 7 | | var value = TempData[key]?.ToString(); |
| | 0 | 8 | | TempData.Remove(key); |
| | 0 | 9 | | return string.IsNullOrWhiteSpace(value) ? null : value; |
| | | 10 | | } |
| | | 11 | | |
| | 0 | 12 | | var transactionWarning = Take("TransactionWarning"); |
| | 0 | 13 | | var transactionResult = Take("TransactionResult"); |
| | 0 | 14 | | var errorResult = Take("ErorrResult"); |
| | | 15 | | |
| | 0 | 16 | | var isTransactionMarkup = !string.IsNullOrWhiteSpace(transactionResult) && |
| | 0 | 17 | | transactionResult.Contains("tx-result-compact", StringComparison.Ordinal); |
| | | 18 | | |
| | 0 | 19 | | if (!string.IsNullOrWhiteSpace(transactionWarning)) |
| | | 20 | | { |
| | 0 | 21 | | notifications.Add(new |
| | 0 | 22 | | { |
| | 0 | 23 | | variant = "warning", |
| | 0 | 24 | | title = "Выполнено частично", |
| | 0 | 25 | | message = transactionWarning, |
| | 0 | 26 | | detailsHtml = isTransactionMarkup ? transactionResult : null, |
| | 0 | 27 | | trustedDetails = isTransactionMarkup, |
| | 0 | 28 | | dismissLegacyAlerts = true |
| | 0 | 29 | | }); |
| | | 30 | | } |
| | 0 | 31 | | else if (!string.IsNullOrWhiteSpace(transactionResult)) |
| | | 32 | | { |
| | 0 | 33 | | notifications.Add(new |
| | 0 | 34 | | { |
| | 0 | 35 | | variant = "success", |
| | 0 | 36 | | title = "Операция выполнена", |
| | 0 | 37 | | message = isTransactionMarkup ? "" : transactionResult, |
| | 0 | 38 | | detailsHtml = isTransactionMarkup ? transactionResult : null, |
| | 0 | 39 | | trustedDetails = isTransactionMarkup, |
| | 0 | 40 | | dismissLegacyAlerts = true |
| | 0 | 41 | | }); |
| | | 42 | | } |
| | | 43 | | |
| | 0 | 44 | | if (!string.IsNullOrWhiteSpace(errorResult)) |
| | | 45 | | { |
| | 0 | 46 | | notifications.Add(new { variant = "danger", title = "Ошибка операции", message = errorResult, detailsHtml = (str |
| | | 47 | | } |
| | | 48 | | |
| | 0 | 49 | | var legacyNotifications = new[] |
| | 0 | 50 | | { |
| | 0 | 51 | | (Key: "SuccessMessage", Variant: "success", Title: "Готово"), |
| | 0 | 52 | | (Key: "Success", Variant: "success", Title: "Готово"), |
| | 0 | 53 | | (Key: "InfoMessage", Variant: "info", Title: "Информация"), |
| | 0 | 54 | | (Key: "Message", Variant: "info", Title: "Информация"), |
| | 0 | 55 | | (Key: "CreateInfo", Variant: "info", Title: "Создание"), |
| | 0 | 56 | | (Key: "EditInfo", Variant: "info", Title: "Редактирование"), |
| | 0 | 57 | | (Key: "WarningMessage", Variant: "warning", Title: "Требует внимания"), |
| | 0 | 58 | | (Key: "MappingWarning", Variant: "warning", Title: "Требует внимания"), |
| | 0 | 59 | | (Key: "ErrorMessage", Variant: "danger", Title: "Ошибка"), |
| | 0 | 60 | | (Key: "Error", Variant: "danger", Title: "Ошибка"), |
| | 0 | 61 | | (Key: "SupplierResult", Variant: "warning", Title: "Поставщик"), |
| | 0 | 62 | | (Key: "WarehouseResult", Variant: "warning", Title: "Склад"), |
| | 0 | 63 | | (Key: "StatusResult", Variant: "success", Title: "Статусы"), |
| | 0 | 64 | | (Key: "SupplierStatusMessage", Variant: "info", Title: "Статусы поставщиков"), |
| | 0 | 65 | | (Key: "ArmtekCartResult", Variant: "info", Title: "Корзина поставщика") |
| | 0 | 66 | | }; |
| | | 67 | | |
| | 0 | 68 | | foreach (var item in legacyNotifications) |
| | | 69 | | { |
| | 0 | 70 | | var message = Take(item.Key); |
| | 0 | 71 | | if (!string.IsNullOrWhiteSpace(message)) |
| | 0 | 72 | | notifications.Add(new { variant = item.Variant, title = item.Title, message, detailsHtml = (string?)null, tr |
| | | 73 | | } |
| | | 74 | | } |
| | 0 | 75 | | @if (notifications.Count > 0) |
| | | 76 | | { |
| | | 77 | | <script type="application/json" data-app-toast-seed> |
| | 0 | 78 | | @Html.Raw(JsonSerializer.Serialize(notifications)) |
| | | 79 | | </script> |
| | | 80 | | } |