-
Notifications
You must be signed in to change notification settings - Fork 378
/
Copy pathSeedDataService.cs
24 lines (22 loc) · 1.01 KB
/
SeedDataService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using SampleWebApiAspNetCore.Data;
using SampleWebApiAspNetCore.Domain.Entities;
using SampleWebApiAspNetCore.Service.Services.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SampleWebApiAspNetCore.Service.Services.Implementations
{
public class SeedDataService : ISeedDataService
{
public void Initialize(FoodDbContext context)
{
context.FoodItems.Add(new FoodEntity() { Calories = 1000, Type = "Starter", Name = "Lasagne", Created = DateTime.Now });
context.FoodItems.Add(new FoodEntity() { Calories = 1100, Type = "Main", Name = "Hamburger", Created = DateTime.Now });
context.FoodItems.Add(new FoodEntity() { Calories = 1200, Type = "Dessert", Name = "Spaghetti", Created = DateTime.Now });
context.FoodItems.Add(new FoodEntity() { Calories = 1300, Type = "Starter", Name = "Pizza", Created = DateTime.Now });
context.SaveChanges();
}
}
}