Code clean up
This commit is contained in:
@@ -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()
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 ?? []
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
|
||||
@@ -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,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,
|
||||
|
||||
Reference in New Issue
Block a user