You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
3.0 KiB
76 lines
3.0 KiB
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();
|
|
}
|
|
} |