Skip to content

Commit

Permalink
Merge branch 'release/v0.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilLord666 committed Oct 3, 2022
2 parents c555b04 + 5e4e9ac commit 4bcdff3
Show file tree
Hide file tree
Showing 44 changed files with 1,985 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Text;
using Wissance.WebApiToolkit.Data.Entity;

namespace Wissance.MossbauerLab.Watcher.Data.Entities
{
public enum EventType
{
NetworkLoss = 1,
PowerLoss = 2,
Maintenance = 3
}

public class EventEntity : IModelIdentifiable<int>
{
public EventEntity()
{
}

public EventEntity(EventType eventType, DateTime start, DateTime? finish)
{
Type = eventType;
Start = start;
Finish = finish;
}

public int Id { get; }
public EventType Type { get; set; }
public DateTime Start { get; set; }
public DateTime? Finish { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using Wissance.WebApiToolkit.Data.Entity;

namespace Wissance.MossbauerLab.Watcher.Data.Entities
{
public class SpectrumEntity : IModelIdentifiable<int>
{
public SpectrumEntity()
{
}

public SpectrumEntity(string name, string description, string location, DateTime measureStartDate, DateTime? first, DateTime? last)
{
Name = name;
Description = description;
Location = location;
measureStartDate = MeasureStartDate;
First = first;
Last = last;
}

public int Id { get; }
public string Name { get; set; }
public string Description { get; set; }
public string Location { get; set; }
public DateTime MeasureStartDate { get; set; }
public DateTime? First { get; set; }
public DateTime? Last { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Wissance.MossbauerLab.Watcher.Data.Entities;

namespace Wissance.MossbauerLab.Watcher.Data
{
public interface IModelContext
{
int SaveChanges();
Task<int> SaveChangesAsync();
DbSet<SpectrumEntity> Spectra { get; }
DbSet<EventEntity> Events { get; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Wissance.MossbauerLab.Watcher.Data.Entities;

namespace Wissance.MossbauerLab.Watcher.Data.Mapping
{
internal static class EventMapping
{
public static void Map(this EntityTypeBuilder<EventEntity> builder)
{
builder.ToTable("Wissance.MossbauerLab.Event");
builder.HasKey(p => p.Id);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Wissance.MossbauerLab.Watcher.Data.Entities;

namespace Wissance.MossbauerLab.Watcher.Data.Mapping
{
internal static class SpectrumMapping
{
public static void Map(this EntityTypeBuilder<SpectrumEntity> builder)
{
builder.ToTable("Wissance.MossbauerLab.Spectrum");
builder.HasKey(p => p.Id);
builder.Property(p => p.Name).IsRequired();
builder.HasIndex(p => p.Name);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Wissance.MossbauerLab.Watcher.Data.Migrations
{
public partial class Migration_1_Initial : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Wissance.MossbauerLab.Spectrum",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: true),
Location = table.Column<string>(type: "TEXT", nullable: true),
First = table.Column<DateTime>(type: "TEXT", nullable: true),
Last = table.Column<DateTime>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Wissance.MossbauerLab.Spectrum", x => x.Id);
});

migrationBuilder.CreateIndex(
name: "IX_Wissance.MossbauerLab.Spectrum_Name",
table: "Wissance.MossbauerLab.Spectrum",
column: "Name");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Wissance.MossbauerLab.Spectrum");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Wissance.MossbauerLab.Watcher.Data.Migrations
{
public partial class Migration_2_Events_Added : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Wissance.MossbauerLab.Event",
columns: table => new
{
Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<int>(type: "INTEGER", nullable: false),
Start = table.Column<DateTime>(type: "TEXT", nullable: false),
Finish = table.Column<DateTime>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Wissance.MossbauerLab.Event", x => x.Id);
});
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Wissance.MossbauerLab.Event");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4bcdff3

Please sign in to comment.