parent
2c791baa06
commit
f45ba72569
@ -0,0 +1,76 @@
|
|||||||
|
namespace TrainingSvc.Data;
|
||||||
|
using CatalogService.Entities;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Shared.Enum;
|
||||||
|
|
||||||
|
public class TrainingDbInitializer
|
||||||
|
{
|
||||||
|
public static void InitDb(WebApplication app)
|
||||||
|
{
|
||||||
|
using var scope = app.Services.CreateScope();
|
||||||
|
SeedData(scope.ServiceProvider.GetService<TrainingDbContext>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SeedData(TrainingDbContext context)
|
||||||
|
{
|
||||||
|
context.Database.Migrate();
|
||||||
|
|
||||||
|
if (context.ExerciceTemplates.Any())
|
||||||
|
{
|
||||||
|
Console.WriteLine("Already have data in the database");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var exercices = new List<ExerciceTemplate>()
|
||||||
|
{
|
||||||
|
new ExerciceTemplate
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid().ToString(),
|
||||||
|
Name = "Squat",
|
||||||
|
Description = "Squat is a compound exercise that targets the lower body, primarily the quadriceps, hamstrings, and glutes.",
|
||||||
|
Target = ETarget.Legs,
|
||||||
|
ImageUrl = "images/squat.jpg",
|
||||||
|
VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley",
|
||||||
|
},
|
||||||
|
new ExerciceTemplate
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid().ToString(),
|
||||||
|
Name = "Bench Press",
|
||||||
|
Description = "Bench Press is a compound exercise that primarily targets the chest, shoulders, and triceps.",
|
||||||
|
Target = ETarget.Chest,
|
||||||
|
ImageUrl = "images/bench_press.jpg",
|
||||||
|
VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley",
|
||||||
|
},
|
||||||
|
new ExerciceTemplate
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid().ToString(),
|
||||||
|
Name = "Deadlift",
|
||||||
|
Description = "Deadlift is a compound exercise that primarily targets the back, glutes, and hamstrings.",
|
||||||
|
Target = ETarget.Back,
|
||||||
|
ImageUrl = "images/deadlift.jpg",
|
||||||
|
VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley",
|
||||||
|
},
|
||||||
|
new ExerciceTemplate
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid().ToString(),
|
||||||
|
Name = "Shoulder Press",
|
||||||
|
Description = "Shoulder Press is a compound exercise that primarily targets the shoulders and triceps.",
|
||||||
|
Target = ETarget.Arms,
|
||||||
|
ImageUrl = "images/shoulder_press.jpg",
|
||||||
|
VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley",
|
||||||
|
},
|
||||||
|
new ExerciceTemplate
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid().ToString(),
|
||||||
|
Name = "Running on Treadmill",
|
||||||
|
Description = "Running on Treadmill is a cardiovascular exercise that primarily targets the legs and improves overall fitness.",
|
||||||
|
Target = ETarget.Cardio,
|
||||||
|
ImageUrl = "images/running_treadmill.jpg",
|
||||||
|
VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
context.AddRange(exercices);
|
||||||
|
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue