model changes

This commit is contained in:
2024-03-19 17:25:13 +01:00
Unverified
parent 6d1b30db47
commit 0d777344a9
30 changed files with 694 additions and 3283 deletions

View File

@@ -0,0 +1,10 @@
[
{
"Id": 1,
"Name": "Afghanistan"
},
{
"Id": 2,
"Name": "Albania"
}
]

View File

@@ -0,0 +1,22 @@
[
{
"Id": 1,
"Name": "Comedy"
},
{
"Id": 2,
"Name": "Thriller"
},
{
"Id": 3,
"Name": "Horror"
},
{
"Id": 4,
"Name": "Action"
},
{
"Id": 5,
"Name": "Drama"
}
]

View File

@@ -0,0 +1,25 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WatchIt.Database.DataSeeding
{
public static class DataReader
{
#region METHODS
public static IEnumerable<T> Read<T>() => Read<T>(typeof(T).Name);
public static IEnumerable<T> Read<T>(string filename)
{
string jsonFile = $"..\\WatchIt.Database\\WatchIt.Database.DataSeeding\\Data\\{filename}.json";
string dataString = File.ReadAllText(jsonFile);
IEnumerable<T> data = JsonConvert.DeserializeObject<IEnumerable<T>>(dataString);
return data;
}
#endregion
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>