Compare commits
No commits in common. "a4f205290d8e663eb5aa9c3702662491e2640133" and "ea485813feefdb8a246adb0a6fe4eab1c0177c90" have entirely different histories.
a4f205290d
...
ea485813fe
@ -315,7 +315,11 @@ namespace Api.DBAccess
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<List<TemperatureLogs>> ReadLogs(int deviceId, DateTimeRange range)
|
public async Task<List<TemperatureLogs>> ReadLogs(int deviceId, DateTimeRange range)
|
||||||
{
|
{
|
||||||
return _context.Devices.Include(d => d.Logs.Where(l => l.Date > range.DateTimeStart && l.Date < range.DateTimeEnd)).Where(d => d.Id == deviceId).FirstOrDefault().Logs;
|
return _context.TemperatureLogs
|
||||||
|
.Where(log => log.DeviceId == deviceId)
|
||||||
|
.Where(log => log.Date > range.DateTimeStart)
|
||||||
|
.Where(log => log.Date < range.DateTimeEnd)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -11,6 +11,8 @@ namespace Api
|
|||||||
|
|
||||||
public DbSet<Device> Devices { get; set; }
|
public DbSet<Device> Devices { get; set; }
|
||||||
|
|
||||||
|
public DbSet<TemperatureLogs> TemperatureLogs { get; set; }
|
||||||
|
|
||||||
public DBContext(DbContextOptions<DBContext> options) : base(options) { }
|
public DBContext(DbContextOptions<DBContext> options) : base(options) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,138 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Api;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Api.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(DBContext))]
|
|
||||||
[Migration("20250403070932_RemovedLogsFromDbset")]
|
|
||||||
partial class RemovedLogsFromDbset
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.3");
|
|
||||||
|
|
||||||
modelBuilder.Entity("Api.Models.Devices.Device", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("ReferenceId")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<double>("TempHigh")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("TempLow")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<int?>("UserId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("UserId");
|
|
||||||
|
|
||||||
b.ToTable("Devices");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Api.Models.TemperatureLogs", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<DateTime>("Date")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<int?>("DeviceId")
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<double>("TempHigh")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("TempLow")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.Property<double>("Temperature")
|
|
||||||
.HasColumnType("REAL");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("DeviceId");
|
|
||||||
|
|
||||||
b.ToTable("TemperatureLogs");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Api.Models.Users.User", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("INTEGER");
|
|
||||||
|
|
||||||
b.Property<string>("Email")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Password")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("RefreshToken")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<DateTime>("RefreshTokenExpiresAt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("Salt")
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.Property<string>("UserName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("TEXT");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Users");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Api.Models.Devices.Device", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Api.Models.Users.User", null)
|
|
||||||
.WithMany("Devices")
|
|
||||||
.HasForeignKey("UserId");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Api.Models.TemperatureLogs", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Api.Models.Devices.Device", null)
|
|
||||||
.WithMany("Logs")
|
|
||||||
.HasForeignKey("DeviceId");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Api.Models.Devices.Device", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Logs");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Api.Models.Users.User", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Devices");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace Api.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class RemovedLogsFromDbset : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_TemperatureLogs_Devices_DeviceId",
|
|
||||||
table: "TemperatureLogs");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "DeviceId",
|
|
||||||
table: "TemperatureLogs",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: true,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER");
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_TemperatureLogs_Devices_DeviceId",
|
|
||||||
table: "TemperatureLogs",
|
|
||||||
column: "DeviceId",
|
|
||||||
principalTable: "Devices",
|
|
||||||
principalColumn: "Id");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropForeignKey(
|
|
||||||
name: "FK_TemperatureLogs_Devices_DeviceId",
|
|
||||||
table: "TemperatureLogs");
|
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<int>(
|
|
||||||
name: "DeviceId",
|
|
||||||
table: "TemperatureLogs",
|
|
||||||
type: "INTEGER",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0,
|
|
||||||
oldClrType: typeof(int),
|
|
||||||
oldType: "INTEGER",
|
|
||||||
oldNullable: true);
|
|
||||||
|
|
||||||
migrationBuilder.AddForeignKey(
|
|
||||||
name: "FK_TemperatureLogs_Devices_DeviceId",
|
|
||||||
table: "TemperatureLogs",
|
|
||||||
column: "DeviceId",
|
|
||||||
principalTable: "Devices",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -55,7 +55,7 @@ namespace Api.Migrations
|
|||||||
b.Property<DateTime>("Date")
|
b.Property<DateTime>("Date")
|
||||||
.HasColumnType("TEXT");
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
b.Property<int?>("DeviceId")
|
b.Property<int>("DeviceId")
|
||||||
.HasColumnType("INTEGER");
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
b.Property<double>("TempHigh")
|
b.Property<double>("TempHigh")
|
||||||
@ -117,7 +117,9 @@ namespace Api.Migrations
|
|||||||
{
|
{
|
||||||
b.HasOne("Api.Models.Devices.Device", null)
|
b.HasOne("Api.Models.Devices.Device", null)
|
||||||
.WithMany("Logs")
|
.WithMany("Logs")
|
||||||
.HasForeignKey("DeviceId");
|
.HasForeignKey("DeviceId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Api.Models.Devices.Device", b =>
|
modelBuilder.Entity("Api.Models.Devices.Device", b =>
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int DeviceId { get; set; }
|
||||||
|
|
||||||
public double Temperature { get; set; }
|
public double Temperature { get; set; }
|
||||||
|
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 176 KiB |
Binary file not shown.
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 58 KiB |
Loading…
Reference in New Issue
Block a user