DB integration added, multiple images for equipment

This commit is contained in:
retr0volkov
2025-07-15 11:14:28 +03:00 Unverified
parent 7a34fc2dbb
commit 8ddce4005f
38 changed files with 627 additions and 297 deletions
+9 -8
View File
@@ -11,23 +11,24 @@ public class Equipment
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int Id { get; set; }
[Required]
public string? Name { get; set; } = string.Empty;
[Required]
public string? Description { get; set; } = string.Empty;
[Required]
// Foreign keys
[Required]
[JsonIgnore]
public int PointId { get; set; }
[JsonIgnore]
public int ImageId { get; set; }
[JsonIgnore]
public List<int> ImageIds { get; set; } = [];
[JsonIgnore]
public List<int> InspectionIds { get; set; } = [];
// EF stuff
public Image? Image { get; set; }
[JsonIgnore]
public Point? Point { get; set; }
// Navigation Properties
public List<Image> Images { get; set; } = [];
[JsonIgnore]
public Point Point { get; set; } = null!;
public List<Property> Properties { get; set; } = [];
public List<Inspection> Inspections { get; set; } = [];
}
+3 -3
View File
@@ -4,7 +4,7 @@ namespace GazpromApp.Models;
public class Error
{
public string? Title { get; set; }
public string? Message { get; set; }
public ErrorSeverity Severity { get; set; }
public string? Title { get; init; }
public string? Message { get; init; }
public ErrorSeverity Severity { get; init; }
}
+12 -5
View File
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
@@ -11,11 +10,19 @@ public class Image
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int Id { get; set; }
[Required]
public byte[] Bytes { get; set; } = [];
// EF stuff
// Foreign keys
[JsonIgnore]
public List<Point> Points { get; set; } = [];
public int? PointId { get; set; }
[JsonIgnore]
public List<Equipment> Equipment { get; set; } = [];
public int? EquipmentId { get; set; }
// Navigation Properties
[JsonIgnore]
public Point? Point { get; set; }
[JsonIgnore]
public Equipment? Equipment { get; set; }
}
+3 -1
View File
@@ -11,6 +11,7 @@ public class Inspection
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int Id { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
[Required]
@@ -20,10 +21,11 @@ public class Inspection
[Required]
public float PeriodValue { get; set; }
// Foreign keys
[JsonIgnore]
public int EquipmentId { get; set; }
// EF stuff
// Navigation Properties
[JsonIgnore]
public Equipment? Equipment { get; } = new();
}
+2 -4
View File
@@ -11,15 +11,13 @@ public class Point
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int Id { get; set; }
[Required]
public string? Name { get; set; } = string.Empty;
[Required]
public string? Description { get; set; } = string.Empty;
[Required]
public double Latitude { get; set; }
[Required]
public double Longitude { get; set; }
// EF stuff
// Navigation Properties
public List<Image> Images { get; set; } = [];
public List<Equipment> Equipment { get; set; } = [];
public List<Property> Properties { get; set; } = [];
+19 -8
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text.Json.Serialization;
@@ -12,17 +11,29 @@ public class Property
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[JsonIgnore]
public int Id { get; set; }
[JsonIgnore]
public int ParentId { get; set; }
[Required]
public string Name { get; set; } = string.Empty;
public string Value { get; set; } = string.Empty;
// EF stuff
// For self-referencing hierarchy (Property of a Property)
[JsonIgnore]
public int? ParentPropertyId { get; set; }
[JsonIgnore]
public Property? Parent { get; set; }
public List<Property> Properties{ get; set; } = [];
// For a Property of a Point
[JsonIgnore]
public List<Point> Points { get; set; } = [];
public int? PointId { get; set; }
[JsonIgnore]
public List<Equipment> Equipment { get; } = [];
public Point? Point { get; set; }
// For a Property of an Equipment
[JsonIgnore]
public int? EquipmentId { get; set; }
[JsonIgnore]
public Equipment? Equipment { get; set; }
// Child properties in the hierarchy
public List<Property> Properties { get; set; } = [];
}