Code clean up

This commit is contained in:
retr0volkov
2025-07-10 09:19:06 +03:00 Unverified
parent 2a8f8d2714
commit 915c7a7c5e
36 changed files with 116 additions and 133 deletions
+3 -4
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
@@ -43,7 +42,7 @@ public partial class EquipmentViewModel : ViewModelBase
Image = new ImageViewModel(equipment.Image ?? new Image());
Properties = new ObservableCollection<PropertyViewModel>(equipment.Properties.Select(e => new PropertyViewModel(e)));
List<DateTime[]> times = (equipment.Inspections.Select(e => new InspectionViewModel(e)))
var times = equipment.Inspections.Select(e => new InspectionViewModel(e))
.Select(e => e.GetNearestDates())
.ToList();
@@ -62,12 +61,12 @@ public partial class EquipmentViewModel : ViewModelBase
public Equipment GetEquipment()
{
return new Equipment()
return new Equipment
{
Name = Name,
Description = Description,
Image = Image?.GetImage(),
Inspections = Inspections.Select(e => e.GetInspection()).ToList(),
Inspections = Inspections.Select(e => e.GetInspection()).ToList()
};
}
}
+5 -6
View File
@@ -20,7 +20,7 @@ public partial class ErrorViewModel : ViewModelBase
w.Close();
}
private ErrorSeverity severity;
private readonly ErrorSeverity _severity;
// Visual and other properties
[ObservableProperty] private bool _isErrorVisible;
@@ -38,7 +38,7 @@ public partial class ErrorViewModel : ViewModelBase
{
Title = error.Title;
Message = error.Message;
severity = error.Severity;
_severity = error.Severity;
switch (error.Severity)
{
case ErrorSeverity.Error:
@@ -48,21 +48,20 @@ public partial class ErrorViewModel : ViewModelBase
IsWarnVisible = true;
break;
case ErrorSeverity.Message:
IsInfoVisible = true;
break;
default:
IsInfoVisible = true;
break;
}
}
// ReSharper disable once UnusedMember.Global
public Error GetError()
{
Error error = new Error()
var error = new Error
{
Title = Title,
Message = Message,
Severity = severity,
Severity = _severity
};
return error;
}
+3 -3
View File
@@ -35,13 +35,13 @@ public partial class ImageViewModel : ViewModelBase
public Image GetImage()
{
MemoryStream ms = new MemoryStream();
var ms = new MemoryStream();
FileName?.Save(ms);
return new Image()
return new Image
{
Bytes = ms.ToArray(),
Equipment = Equipment ?? [],
Points = Points ?? [],
Points = Points ?? []
};
}
}
+2 -2
View File
@@ -19,7 +19,7 @@ public partial class InspectionViewModel : ViewModelBase
// Visual properties
[ObservableProperty]
private bool _isEditing = false;
private bool _isEditing;
public InspectionViewModel()
{
@@ -39,7 +39,7 @@ public partial class InspectionViewModel : ViewModelBase
public Inspection GetInspection()
{
return new Inspection()
return new Inspection
{
Name = Name,
InspectionDate = InspectionDate,
+8 -7
View File
@@ -26,7 +26,7 @@ public partial class PointViewModel : ViewModelBase
[ObservableProperty]
private List<Property>? _properties;
public PointViewModel(Models.Point point)
public PointViewModel(Point point)
{
Name = point.Name;
Description = point.Description;
@@ -37,14 +37,15 @@ public partial class PointViewModel : ViewModelBase
Properties = point.Properties;
}
public Models.Point GetPoint()
// ReSharper disable once UnusedMember.Global
public Point GetPoint()
{
return new Models.Point()
return new Point
{
Name = this.Name,
Description = this.Description,
Equipment = this.Equipment ?? [],
Properties = this.Properties ?? [],
Name = Name,
Description = Description,
Equipment = Equipment ?? [],
Properties = Properties ?? []
};
}
}
+1 -2
View File
@@ -1,7 +1,6 @@
using System.Collections.ObjectModel;
using System.Linq;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using GazpromApp.Models;
namespace GazpromApp.ViewModels;
@@ -26,7 +25,7 @@ public partial class PropertyViewModel : ViewModelBase
public Property GetProperty(Property? parent = null)
{
Property p = new Property
var p = new Property
{
Name = Name,
Value = Value,