Övergått till entity framework + lagt till ny tabell

This commit is contained in:
2025-09-02 15:07:21 +02:00
parent b04fc7e06e
commit ddb6719587
22 changed files with 1175 additions and 95 deletions

View File

@ -0,0 +1,67 @@
using Common.Library;
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
using Microsoft.EntityFrameworkCore;
namespace GreadyPoang.DataLayer;
public class GamePointRepository : IRepository<GamePoint>
{
private readonly DataContext _dataContext;
public GamePointRepository(DataContext dataContext)
{
_dataContext = dataContext;
}
public async Task<IEnumerable<GamePoint>> Get()
{
return await _dataContext.GamePoints.ToListAsync();
}
public async Task<GamePoint?> Get(int id)
{
return await _dataContext.GamePoints.FindAsync(id);
}
public async Task<bool> Save(GamePoint entity)
{
var res = false;
if ((entity.GameHeatRegNr == 0)
|| (entity.GameRegPoints == 0))
{
return res; // Validation failed
}
if (entity.GamePointId == 0)
{
_dataContext.GamePoints.Add(entity);
await _dataContext.SaveChangesAsync();
res = true;
}
else
{
_dataContext.GamePoints.Update(entity);
await _dataContext.SaveChangesAsync();
res = true;
}
return res;
}
public bool Delete(GamePoint entity)
{
var res = false;
try
{
_dataContext.GamePoints.Remove(entity);
_dataContext.SaveChanges();
res = true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error deleting participant: {ex.Message}");
res = false;
}
return res;
}
}

View File

@ -1,88 +1,65 @@
using Common.Library;
using GreadyPoang.DataLayer.Database;
using GreadyPoang.EntityLayer;
using System.Collections.ObjectModel;
using Microsoft.EntityFrameworkCore;
namespace GreadyPoang.DataLayer;
public class ParticipantRepository : IRepository<Participant>
{
private readonly LocalDbService _dbService;
private ObservableCollection<Participant> lager;
private readonly DataContext _dataContext;
public ParticipantRepository(LocalDbService dbService)
public ParticipantRepository(DataContext dataContext)
{
if (lager == null || lager.Count == 0)
{
lager = new ObservableCollection<Participant>();
}
_dbService = dbService;
_dataContext = dataContext;
}
#region Get Method
public async Task<ObservableCollection<Participant>> Get()
public async Task<IEnumerable<Participant>> Get()
{
// This method should return a collection of Participant objects.
// For now, returning an empty collection.
List<Participant> result = await _dbService.GetParticipantsAsync();
if (result != null)
return await _dataContext.Participants.ToListAsync();
}
public async Task<Participant?> Get(int id)
{
// Fix: Use FindAsync with key value array, not a predicate
return await _dataContext.Participants.FindAsync(id);
}
public async Task<bool> Save(Participant entity)
{
var res = false;
if (string.IsNullOrEmpty(entity.FirstName)
|| string.IsNullOrEmpty(entity.LastName))
{
foreach (var participant in result)
{
if (!lager.Any(p => p.ParticipantId == participant.ParticipantId))
{
lager.Add(participant);
}
}
return res; // Validation failed
}
return lager;
}
public Participant? Get(int id)
{
Participant? participant = null; // Initialize the variable to avoid CS0165
_dbService.GetParticipantAsync(id).ContinueWith(task =>
if (entity.ParticipantId == 0)
{
if (task.Exception == null)
{
participant = task.Result;
if (participant != null)
{
System.Diagnostics.Debug.WriteLine($"Fetched Participant by ID: {participant.ParticipantId}, {participant.FirstName}, {participant.LastName}, {participant.Email}");
}
else
{
System.Diagnostics.Debug.WriteLine($"No Participant found with ID: {id}");
}
}
else
{
// Handle exceptions as needed
System.Diagnostics.Debug.WriteLine($"Error fetching participant by ID: {task.Exception.Message}");
}
}).Wait();
_dataContext.Participants.Add(entity);
await _dataContext.SaveChangesAsync();
res = true;
}
else
{
_dataContext.Participants.Update(entity);
await _dataContext.SaveChangesAsync();
res = true;
}
return res;
return participant;
}
#endregion
public bool Save(Participant entity)
public bool Delete(Participant entity)
{
var output = false;
var res = false;
try
{
_dbService.SaveParticipantAsync(entity).Wait();
lager.Add(entity);
output = true;
_dataContext.Participants.Remove(entity);
_dataContext.SaveChanges();
res = true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error saving participants: {ex.Message}");
System.Diagnostics.Debug.WriteLine($"Error deleting participant: {ex.Message}");
res = false;
}
return output;
return res;
}
}

View File

@ -1,25 +1,32 @@
using GreadyPoang.EntityLayer;
using Microsoft.EntityFrameworkCore;
namespace GreadyPoang.DataLayer.Database
namespace GreadyPoang.DataLayer.Database;
public class DataContext : DbContext
{
public class DataContext : DbContext
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
public DataContext(DbContextOptions<DataContext> options) : base(options)
{
}
//public DbSet<User> Users => Set<User>();
public DbSet<Participant> Participants { get; set; }
}
//public DbSet<User> Users => Set<User>();
public DbSet<Participant> Participants { get; set; }
public DbSet<GamePoint> GamePoints { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Participant>().HasData(
new Participant { ParticipantId = 1, FirstName = "John", LastName = "Doe", Email = "John.Doe@gmail.com" },
new Participant { ParticipantId = 2, FirstName = "Jane", LastName = "Black", Email = "jb@gmail.com" },
new Participant { ParticipantId = 3, FirstName = "Mary", LastName = "White", Email = "mw@gmail.com" }
);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Participant>().HasData(
new Participant { ParticipantId = 1, FirstName = "John", LastName = "Doe", Email = "John.Doe@gmail.com" },
new Participant { ParticipantId = 2, FirstName = "Jane", LastName = "Black", Email = "jb@gmail.com" },
new Participant { ParticipantId = 3, FirstName = "Mary", LastName = "White", Email = "mw@gmail.com" }
);
modelBuilder.Entity<GamePoint>().HasData(
new GamePoint { GamePointId = 1, ParticipantId = 1, GameHeatId = 0, GameDate = new DateTime(2025, 10, 15, 20, 10, 15), GameHeatRegNr = 1, GameRegPoints = 1050 },
new GamePoint { GamePointId = 2, ParticipantId = 1, GameHeatId = 0, GameDate = new DateTime(2025, 10, 15, 20, 15, 15), GameHeatRegNr = 3, GameRegPoints = 350 },
new GamePoint { GamePointId = 3, ParticipantId = 3, GameHeatId = 0, GameDate = new DateTime(2025, 10, 15, 20, 12, 15), GameHeatRegNr = 2, GameRegPoints = 1000 },
new GamePoint { GamePointId = 4, ParticipantId = 3, GameHeatId = 0, GameDate = new DateTime(2025, 10, 15, 20, 20, 15), GameHeatRegNr = 4, GameRegPoints = 400 }
);
}
}

View File

@ -7,6 +7,14 @@
</PropertyGroup>
<ItemGroup>
<Compile Remove="DataClasses\LocalDbService.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.100" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" />

View File

@ -0,0 +1,70 @@
// <auto-generated />
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250901152226_initialCreate")]
partial class initialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class initialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Participants",
columns: table => new
{
ParticipantId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
FirstName = table.Column<string>(type: "TEXT", nullable: false),
LastName = table.Column<string>(type: "TEXT", nullable: false),
Email = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Participants", x => x.ParticipantId);
});
migrationBuilder.InsertData(
table: "Participants",
columns: new[] { "ParticipantId", "Email", "FirstName", "LastName" },
values: new object[,]
{
{ 1, "John.Doe@gmail.com", "John", "Doe" },
{ 2, "jb@gmail.com", "Jane", "Black" },
{ 3, "mw@gmail.com", "Mary", "White" }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Participants");
}
}
}

View File

@ -0,0 +1,135 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250902115700_GamePointsTable")]
partial class GamePointsTable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameHeatId")
.HasColumnType("INTEGER");
b.Property<int>("GameHeatRegNr")
.HasColumnType("INTEGER");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8341),
GameHeatId = 0,
GameHeatRegNr = 1,
GameRegPoints = 1050,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8923),
GameHeatId = 0,
GameHeatRegNr = 3,
GameRegPoints = 350,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8927),
GameHeatId = 0,
GameHeatRegNr = 2,
GameRegPoints = 1000,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8929),
GameHeatId = 0,
GameHeatRegNr = 4,
GameRegPoints = 400,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,52 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class GamePointsTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "GamePoints",
columns: table => new
{
GamePointId = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ParticipantId = table.Column<int>(type: "INTEGER", nullable: false),
GameHeatId = table.Column<int>(type: "INTEGER", nullable: false),
GameDate = table.Column<DateTime>(type: "TEXT", nullable: false),
GameHeatRegNr = table.Column<int>(type: "INTEGER", nullable: false),
GameRegPoints = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_GamePoints", x => x.GamePointId);
});
migrationBuilder.InsertData(
table: "GamePoints",
columns: new[] { "GamePointId", "GameDate", "GameHeatId", "GameHeatRegNr", "GameRegPoints", "ParticipantId" },
values: new object[,]
{
{ 1, new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8341), 0, 1, 1050, 1 },
{ 2, new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8923), 0, 3, 350, 1 },
{ 3, new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8927), 0, 2, 1000, 3 },
{ 4, new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8929), 0, 4, 400, 3 }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "GamePoints");
}
}
}

View File

@ -0,0 +1,135 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250902120934_GamePointsTableStaticSeed")]
partial class GamePointsTableStaticSeed
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameHeatId")
.HasColumnType("INTEGER");
b.Property<int>("GameHeatRegNr")
.HasColumnType("INTEGER");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(5394),
GameHeatId = 0,
GameHeatRegNr = 1,
GameRegPoints = 1050,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6081),
GameHeatId = 0,
GameHeatRegNr = 3,
GameRegPoints = 350,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6085),
GameHeatId = 0,
GameHeatRegNr = 2,
GameRegPoints = 1000,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6088),
GameHeatId = 0,
GameHeatRegNr = 4,
GameRegPoints = 400,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,75 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class GamePointsTableStaticSeed : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(5394));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6081));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6085));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6088));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "GameDate",
value: new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8341));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "GameDate",
value: new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8923));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "GameDate",
value: new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8927));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "GameDate",
value: new DateTime(2025, 9, 2, 13, 56, 59, 539, DateTimeKind.Local).AddTicks(8929));
}
}
}

View File

@ -0,0 +1,135 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
[Migration("20250902122130_FixDateTimeSeed")]
partial class FixDateTimeSeed
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameHeatId")
.HasColumnType("INTEGER");
b.Property<int>("GameHeatRegNr")
.HasColumnType("INTEGER");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 1,
GameRegPoints = 1050,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 3,
GameRegPoints = 350,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 2,
GameRegPoints = 1000,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 4,
GameRegPoints = 400,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,75 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
/// <inheritdoc />
public partial class FixDateTimeSeed : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "GameDate",
value: new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "GameDate",
value: new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "GameDate",
value: new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "GameDate",
value: new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 1,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(5394));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 2,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6081));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 3,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6085));
migrationBuilder.UpdateData(
table: "GamePoints",
keyColumn: "GamePointId",
keyValue: 4,
column: "GameDate",
value: new DateTime(2025, 9, 2, 14, 9, 34, 269, DateTimeKind.Local).AddTicks(6088));
}
}
}

View File

@ -0,0 +1,132 @@
// <auto-generated />
using System;
using GreadyPoang.DataLayer.Database;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreadyPoang.DataLayer.Migrations
{
[DbContext(typeof(DataContext))]
partial class DataContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "9.0.8");
modelBuilder.Entity("GreadyPoang.EntityLayer.GamePoint", b =>
{
b.Property<int>("GamePointId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("GameDate")
.HasColumnType("TEXT");
b.Property<int>("GameHeatId")
.HasColumnType("INTEGER");
b.Property<int>("GameHeatRegNr")
.HasColumnType("INTEGER");
b.Property<int>("GameRegPoints")
.HasColumnType("INTEGER");
b.Property<int>("ParticipantId")
.HasColumnType("INTEGER");
b.HasKey("GamePointId");
b.ToTable("GamePoints");
b.HasData(
new
{
GamePointId = 1,
GameDate = new DateTime(2025, 10, 15, 20, 10, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 1,
GameRegPoints = 1050,
ParticipantId = 1
},
new
{
GamePointId = 2,
GameDate = new DateTime(2025, 10, 15, 20, 15, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 3,
GameRegPoints = 350,
ParticipantId = 1
},
new
{
GamePointId = 3,
GameDate = new DateTime(2025, 10, 15, 20, 12, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 2,
GameRegPoints = 1000,
ParticipantId = 3
},
new
{
GamePointId = 4,
GameDate = new DateTime(2025, 10, 15, 20, 20, 15, 0, DateTimeKind.Unspecified),
GameHeatId = 0,
GameHeatRegNr = 4,
GameRegPoints = 400,
ParticipantId = 3
});
});
modelBuilder.Entity("GreadyPoang.EntityLayer.Participant", b =>
{
b.Property<int>("ParticipantId")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("ParticipantId");
b.ToTable("Participants");
b.HasData(
new
{
ParticipantId = 1,
Email = "John.Doe@gmail.com",
FirstName = "John",
LastName = "Doe"
},
new
{
ParticipantId = 2,
Email = "jb@gmail.com",
FirstName = "Jane",
LastName = "Black"
},
new
{
ParticipantId = 3,
Email = "mw@gmail.com",
FirstName = "Mary",
LastName = "White"
});
});
#pragma warning restore 612, 618
}
}
}