model changes
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"Id": 1,
|
||||
"Name": "Afghanistan"
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"Name": "Albania"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"Id": 1,
|
||||
"Name": "Comedy"
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"Name": "Thriller"
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"Name": "Horror"
|
||||
},
|
||||
{
|
||||
"Id": 4,
|
||||
"Name": "Action"
|
||||
},
|
||||
{
|
||||
"Id": 5,
|
||||
"Name": "Drama"
|
||||
}
|
||||
]
|
||||
25
WatchIt.Database/WatchIt.Database.DataSeeding/DataReader.cs
Normal file
25
WatchIt.Database/WatchIt.Database.DataSeeding/DataReader.cs
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user