Temperature Logger Codes

This commit is contained in:
GERALD V. SORIANO
2025-02-07 16:30:55 +08:00
commit 0ecbbb949b
2046 changed files with 145004 additions and 0 deletions
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TemperatureLoggerAPI", "TemperatureLoggerAPI\TemperatureLoggerAPI.csproj", "{0B883E02-A272-4C64-8EBE-D311C8B47DD9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0B883E02-A272-4C64-8EBE-D311C8B47DD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B883E02-A272-4C64-8EBE-D311C8B47DD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B883E02-A272-4C64-8EBE-D311C8B47DD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B883E02-A272-4C64-8EBE-D311C8B47DD9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2F14467E-6A05-482B-B427-ABF44F0EFB5D}
EndGlobalSection
EndGlobal
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "9.0.0",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}
@@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TemperatureLoggerAPI.Models;
namespace TemperatureLoggerAPI.Controllers
{
[Route("[controller]")]
[ApiController]
public class TempLogController : ControllerBase
{
private readonly TemperatureLoggerAPIContext _context;
public TempLogController() {
_context = new TemperatureLoggerAPIContext();
}
[HttpPost]
public ActionResult PostTemp(TempLogs log) {
var res = 0;
if (log != null)
{
if (log.templog == null) log.templog = DateTime.Now;
_context.TempLogs.Add(log);
res = _context.SaveChanges();
}
return Ok(new { is_success = res > 0 });
}
}
}
@@ -0,0 +1,92 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241216052346_initial")]
partial class initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int>("deviceId")
.HasColumnType("int");
b.Property<DateTime>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,67 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "DeviceInfo",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DeviceInfo", x => x.Id);
});
migrationBuilder.CreateTable(
name: "TempLogs",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
templog = table.Column<DateTime>(type: "datetime2", nullable: false),
Humidity = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
TempC = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
TempF = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
deviceId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TempLogs", x => x.id);
table.ForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
column: x => x.deviceId,
principalTable: "DeviceInfo",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_TempLogs_deviceId",
table: "TempLogs",
column: "deviceId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "TempLogs");
migrationBuilder.DropTable(
name: "DeviceInfo");
}
}
}
@@ -0,0 +1,90 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241216053437_update-deviceinfo")]
partial class updatedeviceinfo
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("deviceId")
.HasColumnType("int");
b.Property<DateTime>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class updatedeviceinfo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs");
migrationBuilder.AlterColumn<int>(
name: "deviceId",
table: "TempLogs",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs",
column: "deviceId",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs");
migrationBuilder.AlterColumn<int>(
name: "deviceId",
table: "TempLogs",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs",
column: "deviceId",
principalTable: "DeviceInfo",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
@@ -0,0 +1,90 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241216053702_update-deviceinfo-add-deviceid")]
partial class updatedeviceinfoadddeviceid
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("deviceID")
.HasColumnType("int");
b.Property<DateTime>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceID");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceID");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,60 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class updatedeviceinfoadddeviceid : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs");
migrationBuilder.RenameColumn(
name: "deviceId",
table: "TempLogs",
newName: "deviceID");
migrationBuilder.RenameIndex(
name: "IX_TempLogs_deviceId",
table: "TempLogs",
newName: "IX_TempLogs_deviceID");
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceID",
table: "TempLogs",
column: "deviceID",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceID",
table: "TempLogs");
migrationBuilder.RenameColumn(
name: "deviceID",
table: "TempLogs",
newName: "deviceId");
migrationBuilder.RenameIndex(
name: "IX_TempLogs_deviceID",
table: "TempLogs",
newName: "IX_TempLogs_deviceId");
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs",
column: "deviceId",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
}
}
@@ -0,0 +1,93 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241216054111_update-deviceinfo-add-dev_id")]
partial class updatedeviceinfoadddev_id
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("dev_ID")
.HasColumnType("int");
b.Property<int?>("deviceId")
.HasColumnType("int");
b.Property<DateTime>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,70 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class updatedeviceinfoadddev_id : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceID",
table: "TempLogs");
migrationBuilder.RenameColumn(
name: "deviceID",
table: "TempLogs",
newName: "deviceId");
migrationBuilder.RenameIndex(
name: "IX_TempLogs_deviceID",
table: "TempLogs",
newName: "IX_TempLogs_deviceId");
migrationBuilder.AddColumn<int>(
name: "dev_ID",
table: "TempLogs",
type: "int",
nullable: true);
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs",
column: "deviceId",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceId",
table: "TempLogs");
migrationBuilder.DropColumn(
name: "dev_ID",
table: "TempLogs");
migrationBuilder.RenameColumn(
name: "deviceId",
table: "TempLogs",
newName: "deviceID");
migrationBuilder.RenameIndex(
name: "IX_TempLogs_deviceId",
table: "TempLogs",
newName: "IX_TempLogs_deviceID");
migrationBuilder.AddForeignKey(
name: "FK_TempLogs_DeviceInfo_deviceID",
table: "TempLogs",
column: "deviceID",
principalTable: "DeviceInfo",
principalColumn: "Id");
}
}
}
@@ -0,0 +1,129 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
[Migration("20241218071240_add_group_area")]
partial class add_group_area
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("GA_Id")
.HasColumnType("int");
b.Property<int>("GroupAreaId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("GroupAreaId");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.GroupArea", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("GAName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("GroupArea");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("dev_ID")
.HasColumnType("int");
b.Property<int?>("deviceId")
.HasColumnType("int");
b.Property<DateTime?>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.GroupArea", "GroupArea")
.WithMany()
.HasForeignKey("GroupAreaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("GroupArea");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,95 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
/// <inheritdoc />
public partial class add_group_area : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "templog",
table: "TempLogs",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.AddColumn<int>(
name: "GA_Id",
table: "DeviceInfo",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "GroupAreaId",
table: "DeviceInfo",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "GroupArea",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
GAName = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GroupArea", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_DeviceInfo_GroupAreaId",
table: "DeviceInfo",
column: "GroupAreaId");
migrationBuilder.AddForeignKey(
name: "FK_DeviceInfo_GroupArea_GroupAreaId",
table: "DeviceInfo",
column: "GroupAreaId",
principalTable: "GroupArea",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_DeviceInfo_GroupArea_GroupAreaId",
table: "DeviceInfo");
migrationBuilder.DropTable(
name: "GroupArea");
migrationBuilder.DropIndex(
name: "IX_DeviceInfo_GroupAreaId",
table: "DeviceInfo");
migrationBuilder.DropColumn(
name: "GA_Id",
table: "DeviceInfo");
migrationBuilder.DropColumn(
name: "GroupAreaId",
table: "DeviceInfo");
migrationBuilder.AlterColumn<DateTime>(
name: "templog",
table: "TempLogs",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
}
}
}
@@ -0,0 +1,126 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TemperatureLoggerAPI;
#nullable disable
namespace TemperatureLoggerAPI.Migrations
{
[DbContext(typeof(TemperatureLoggerAPIContext))]
partial class TemperatureLoggerAPIContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("GA_Id")
.HasColumnType("int");
b.Property<int>("GroupAreaId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("GroupAreaId");
b.ToTable("DeviceInfo");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.GroupArea", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("GAName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("GroupArea");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<decimal?>("Humidity")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempC")
.HasColumnType("decimal(18,2)");
b.Property<decimal?>("TempF")
.HasColumnType("decimal(18,2)");
b.Property<int?>("dev_ID")
.HasColumnType("int");
b.Property<int?>("deviceId")
.HasColumnType("int");
b.Property<DateTime?>("templog")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("deviceId");
b.ToTable("TempLogs");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.DeviceInfo", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.GroupArea", "GroupArea")
.WithMany()
.HasForeignKey("GroupAreaId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("GroupArea");
});
modelBuilder.Entity("TemperatureLoggerAPI.Models.TempLogs", b =>
{
b.HasOne("TemperatureLoggerAPI.Models.DeviceInfo", "device")
.WithMany()
.HasForeignKey("deviceId");
b.Navigation("device");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,11 @@
namespace TemperatureLoggerAPI.Models
{
public class DeviceInfo
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public int? GA_Id { get; set; }
public GroupArea GroupArea { get; set; }
}
}
@@ -0,0 +1,8 @@
namespace TemperatureLoggerAPI.Models
{
public class GroupArea
{
public int Id { get; set; }
public string GAName { get; set; }
}
}
@@ -0,0 +1,14 @@
namespace TemperatureLoggerAPI.Models
{
public class TempLogs
{
public long id { get; set; }
public DateTime? templog { get; set; }
public decimal? Humidity { get; set; }
public decimal? TempC { get; set; }
public decimal? TempF { get; set; }
public int? dev_ID { get; set; }
public DeviceInfo? device { get; set; }
}
}
@@ -0,0 +1,41 @@
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var allowedOrigins = "_allowedOrigins";
builder.Services.AddCors(opts => opts.AddPolicy(allowedOrigins, policy =>
{
//policy.WithOrigins("http://tasq.local&quot;, "http://localhost&quot;)
policy.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
}));
var app = builder.Build();
/*
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
} */
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseAuthorization();
app.UseRouting();
app.MapControllers();
app.UseCors();
app.Run();
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>false</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release\net8.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ProjectGuid>0b883e02-a272-4c64-8ebe-d311c8b47dd9</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<_PublishTargetUrl>D:\Hospital Files\PROJECTS\TemperatureLoggerAPI\TemperatureLoggerAPI\bin\Release\net8.0\publish\</_PublishTargetUrl>
<History>True|2024-12-20T07:15:18.3593028Z||;True|2024-12-18T16:34:32.3289540+08:00||;True|2024-12-18T15:16:51.2232418+08:00||;True|2024-12-16T13:49:08.6133214+08:00||;True|2024-12-16T13:45:33.4698005+08:00||;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>
@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:8312",
"sslPort": 44324
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5147",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7201;http://localhost:5147",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>https</ActiveDebugProfile>
<Controller_SelectedScaffolderID>MvcControllerWithActionsScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
<NameOfLastUsedPublishProfile>D:\Hospital Files\PROJECTS\TemperatureLoggerAPI\TemperatureLoggerAPI\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
</PropertyGroup>
</Project>
@@ -0,0 +1,6 @@
@TemperatureLoggerAPI_HostAddress = http://localhost:5147
GET {{TemperatureLoggerAPI_HostAddress}}/weatherforecast/
Accept: application/json
###
@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using TemperatureLoggerAPI.Models;
namespace TemperatureLoggerAPI
{
public class TemperatureLoggerAPIContext : DbContext
{
public TemperatureLoggerAPIContext()
: base(new DbContextOptionsBuilder().UseSqlServer("Data Source=localhost;Initial Catalog=TemperatureLog;Persist Security Info=True;User ID=sa;Password=s@password1;TrustServerCertificate=True").Options)
{
}
public DbSet<TemperatureLoggerAPI.Models.DeviceInfo> DeviceInfo { get; set; }
public DbSet<TemperatureLoggerAPI.Models.TempLogs> TempLogs { get; set; }
public DbSet<TemperatureLoggerAPI.Models.GroupArea> GroupArea { get; set; }
}
}
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
@@ -0,0 +1,20 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "8.0.0"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Reflection.NullabilityInfoContext.IsSupported": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

Some files were not shown because too many files have changed in this diff Show More