Error handling system added

This commit is contained in:
retr0volkov
2025-07-05 17:31:02 +03:00 Unverified
parent 8806d28787
commit de8c487f92
21 changed files with 339 additions and 17 deletions
+69
View File
@@ -0,0 +1,69 @@
using Avalonia.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using GazpromApp.Enums;
using GazpromApp.Models;
namespace GazpromApp.ViewModels;
public partial class ErrorViewModel : ViewModelBase
{
[ObservableProperty]
private string? _title;
[ObservableProperty]
private string? _message;
[RelayCommand]
private static void Ok(Window w)
{
w.Close();
}
private ErrorSeverity severity;
// Visual and other properties
[ObservableProperty] private bool _isErrorVisible;
[ObservableProperty] private bool _isWarnVisible;
[ObservableProperty] private bool _isInfoVisible;
public ErrorViewModel()
{
IsInfoVisible = true;
Title = "Тест ошибки";
Message = "Сообщение ошибки";
}
public ErrorViewModel(Error error)
{
Title = error.Title;
Message = error.Message;
severity = error.Severity;
switch (error.Severity)
{
case ErrorSeverity.Error:
IsErrorVisible = true;
break;
case ErrorSeverity.Warning:
IsWarnVisible = true;
break;
case ErrorSeverity.Message:
IsInfoVisible = true;
break;
default:
IsInfoVisible = true;
break;
}
}
public Error GetError()
{
Error error = new Error()
{
Title = Title,
Message = Message,
Severity = severity,
};
return error;
}
}