Files
WinFormDiApp/WinFormDiApp.DAL/Data/DataSeeder.cs

39 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WinFormDiApp.BL.Models;
namespace WinFormDiApp.DAL.Data
{
public class DataSeeder
{
public static void Initialize(ApplicationDbContext context)
{
if (!context.Members.Any())
{
var members = new List<Member>()
{
new Member { /*Id = 1,*/ FirstName = "John", LastName="Doe", NickName="Doey", PersonType="Normal", Email = "john@john.com" },
new Member { /*Id = 2,*/ FirstName = "Michael", LastName="Jordan", NickName="Joardie", PersonType="Normal", Email = "michael@michael.com" }
};
context.Members.AddRange(members);
context.SaveChanges();
}
if (!context.AccountRecords.Any())
{
var accountRecords = new List<AccountRecord>()
{
new AccountRecord { /* Id = 1 */ Avisering = "EInvoice", Belopp=10.0, BetalDatum=DateTime.Parse("2023-05-05"), Konto="BG 5787-1030", Mottagare="Kalles Bärplockning" },
new AccountRecord { /* Id = 1 */ Avisering = "EInvoice", Belopp = 13.0, BetalDatum = DateTime.Parse("2023-05-07"), Konto = "PG 4158502-7", Mottagare = "Nisses Strumpor" }
};
context.AccountRecords.AddRange(accountRecords);
context.SaveChanges();
}
}
}
}