DB integration added, multiple images for equipment
This commit is contained in:
@@ -9,18 +9,19 @@ namespace GazpromApp.ViewModels;
|
||||
|
||||
public partial class EquipmentViewModel : ViewModelBase
|
||||
{
|
||||
private Equipment Equipment { get; }
|
||||
|
||||
[ObservableProperty]
|
||||
private string? _name;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? _description;
|
||||
|
||||
[ObservableProperty]
|
||||
private ImageViewModel? _image;
|
||||
|
||||
public ObservableCollection<PropertyViewModel> Properties { get; set; }
|
||||
|
||||
public ObservableCollection<InspectionViewModel> Inspections { get; set; }
|
||||
public ObservableCollection<ImageViewModel> Images { get; init; } = [];
|
||||
|
||||
public ObservableCollection<PropertyViewModel> Properties { get; }
|
||||
|
||||
public ObservableCollection<InspectionViewModel> Inspections { get; }
|
||||
|
||||
[ObservableProperty]
|
||||
private string _nearestInspection;
|
||||
@@ -29,17 +30,17 @@ public partial class EquipmentViewModel : ViewModelBase
|
||||
{
|
||||
Name = string.Empty;
|
||||
Description = string.Empty;
|
||||
Image = null;
|
||||
Properties = [];
|
||||
Inspections = [];
|
||||
NearestInspection = "Нету инспекций";
|
||||
Equipment = new Equipment();
|
||||
}
|
||||
|
||||
public EquipmentViewModel(Equipment equipment)
|
||||
{
|
||||
Name = equipment.Name;
|
||||
Description = equipment.Description;
|
||||
Image = new ImageViewModel(equipment.Image ?? new Image());
|
||||
Images = new ObservableCollection<ImageViewModel>(equipment.Images.Select(i => new ImageViewModel(i)));
|
||||
Properties = new ObservableCollection<PropertyViewModel>(equipment.Properties.Select(e => new PropertyViewModel(e)));
|
||||
|
||||
var times = equipment.Inspections.Select(e => new InspectionViewModel(e))
|
||||
@@ -57,16 +58,15 @@ public partial class EquipmentViewModel : ViewModelBase
|
||||
.ToLongDateString();
|
||||
|
||||
if (Inspections.Count == 0) NearestInspection = "Нету инспекций";
|
||||
Equipment = equipment;
|
||||
}
|
||||
|
||||
public Equipment GetEquipment()
|
||||
{
|
||||
return new Equipment
|
||||
{
|
||||
Name = Name,
|
||||
Description = Description,
|
||||
Image = Image?.GetImage(),
|
||||
Inspections = Inspections.Select(e => e.GetInspection()).ToList()
|
||||
};
|
||||
Equipment.Name = Name;
|
||||
Equipment.Description = Description;
|
||||
Equipment.Images = Images.Select(e => e.GetImage()).ToList();
|
||||
Equipment.Inspections = Inspections.Select(e => e.GetInspection()).ToList();
|
||||
return Equipment;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user