Adding equipment works
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Avalonia.Media.Imaging;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using GazpromApp.Models;
|
||||
|
||||
namespace GazpromApp.ViewModels;
|
||||
|
||||
public partial class EquipmentViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? _name;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? _description;
|
||||
|
||||
[ObservableProperty]
|
||||
private ImageViewModel? _image;
|
||||
|
||||
public ObservableCollection<PropertyViewModel> Properties { get; set; }
|
||||
|
||||
public ObservableCollection<InspectionViewModel> Inspections { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
private string _nearestInspection;
|
||||
|
||||
public EquipmentViewModel()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Description = string.Empty;
|
||||
Image = null;
|
||||
Properties = [];
|
||||
Inspections = [];
|
||||
NearestInspection = DateTime.Now.ToLongDateString();
|
||||
}
|
||||
|
||||
public EquipmentViewModel(Equipment equipment)
|
||||
{
|
||||
Name = equipment.Name;
|
||||
Description = equipment.Description;
|
||||
Image = new ImageViewModel(equipment.Image ?? new Image());
|
||||
Properties = new ObservableCollection<PropertyViewModel>(equipment.Properties.Select(e => new PropertyViewModel(e)));
|
||||
Inspections = new ObservableCollection<InspectionViewModel>(equipment.Inspections.Select(e => new InspectionViewModel(e)));
|
||||
NearestInspection = DateTime.Now.ToLongDateString();
|
||||
}
|
||||
|
||||
public Equipment GetEquipment()
|
||||
{
|
||||
return new Equipment()
|
||||
{
|
||||
Name = Name,
|
||||
Description = Description,
|
||||
Image = Image?.GetImage(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using GazpromApp.Models;
|
||||
|
||||
namespace GazpromApp.ViewModels;
|
||||
|
||||
public partial class InspectionViewModel : ViewModelBase
|
||||
{
|
||||
public InspectionViewModel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public InspectionViewModel(Inspection inspection)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public partial class PointViewModel : ViewModelBase
|
||||
|
||||
[ObservableProperty]
|
||||
private double? _longitude;
|
||||
|
||||
// EF stuff
|
||||
[ObservableProperty]
|
||||
private List<Image>? _images;
|
||||
@@ -41,7 +42,9 @@ public partial class PointViewModel : ViewModelBase
|
||||
return new Models.Point()
|
||||
{
|
||||
Name = this.Name,
|
||||
Description = this.Description
|
||||
Description = this.Description,
|
||||
Equipment = this.Equipment ?? [],
|
||||
Properties = this.Properties ?? [],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using GazpromApp.Models;
|
||||
|
||||
namespace GazpromApp.ViewModels;
|
||||
|
||||
public partial class PropertyViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string _name;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _value;
|
||||
|
||||
public ObservableCollection<PropertyViewModel> Properties { get; set; } = [];
|
||||
|
||||
public PropertyViewModel()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Value = string.Empty;
|
||||
}
|
||||
|
||||
public PropertyViewModel(Property property)
|
||||
{
|
||||
Name = property.Name;
|
||||
Value = property.Value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user