Major rewrite
This commit is contained in:
18
SoilMoistureAPI/Models/Device.cs
Normal file
18
SoilMoistureAPI/Models/Device.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SoilMoistureAPI.Models
|
||||
{
|
||||
public class Device
|
||||
{
|
||||
[Key]
|
||||
public string DeviceId { get; set; } // Primary Key
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string Nickname { get; set; }
|
||||
|
||||
// Navigation Property
|
||||
public ICollection<SoilMoisture> SoilMoistures { get; set; }
|
||||
}
|
||||
}
|
||||
8
SoilMoistureAPI/Models/DeviceDto.cs
Normal file
8
SoilMoistureAPI/Models/DeviceDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace SoilMoistureAPI.Models
|
||||
{
|
||||
public class DeviceDto
|
||||
{
|
||||
public string DeviceId { get; set; }
|
||||
public string Nickname { get; set; }
|
||||
}
|
||||
}
|
||||
24
SoilMoistureAPI/Models/SoilMoisture.cs
Normal file
24
SoilMoistureAPI/Models/SoilMoisture.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace SoilMoistureAPI.Models
|
||||
{
|
||||
public class SoilMoisture
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[ForeignKey("Device")]
|
||||
public string DeviceId { get; set; } // Foreign Key
|
||||
|
||||
[Required]
|
||||
public float MoistureLevel { get; set; }
|
||||
|
||||
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
|
||||
|
||||
// Navigation Property
|
||||
public Device Device { get; set; }
|
||||
}
|
||||
}
|
||||
8
SoilMoistureAPI/Models/SoilMoistureDto.cs
Normal file
8
SoilMoistureAPI/Models/SoilMoistureDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace SoilMoistureAPI.Models
|
||||
{
|
||||
public class SoilMoistureDto
|
||||
{
|
||||
public string DeviceId { get; set; }
|
||||
public float MoistureLevel { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user