From f45ba725691925a841522629899c50796c219569 Mon Sep 17 00:00:00 2001 From: tleodev Date: Sat, 7 Jun 2025 15:51:38 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Initialize=20Db=20migra?= =?UTF-8?q?tion=20+=20DbInitializer=20(TrainingDb)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/CatalogService/CatalogService.csproj | 4 + .../Controllers/ExercicesController.cs | 2 +- src/CatalogService/Data/CatalogDbContext.cs | 2 +- src/CatalogService/Data/DbInitializer.cs | 12 +- .../RequestHelpers/MappingProfiles.cs | 8 +- .../Entities/ExerciceTemplate.cs} | 2 +- .../20250607133126_InitialCreate.Designer.cs | 204 ++++++++++++++++++ .../20250607133126_InitialCreate.cs | 126 +++++++++++ .../TrainingDbContextModelSnapshot.cs | 201 +++++++++++++++++ src/TrainingSvc/Data/TrainingDbContext.cs | 10 + src/TrainingSvc/Data/TrainingDbInitializer.cs | 76 +++++++ src/TrainingSvc/Entities/ExerciceInstance.cs | 2 +- src/TrainingSvc/Program.cs | 8 +- src/TrainingSvc/TrainingSvc.csproj | 4 + 14 files changed, 643 insertions(+), 18 deletions(-) rename src/{CatalogService/Entities/Exercice.cs => Shared/Entities/ExerciceTemplate.cs} (92%) create mode 100644 src/TrainingSvc/Data/Migrations/20250607133126_InitialCreate.Designer.cs create mode 100644 src/TrainingSvc/Data/Migrations/20250607133126_InitialCreate.cs create mode 100644 src/TrainingSvc/Data/Migrations/TrainingDbContextModelSnapshot.cs create mode 100644 src/TrainingSvc/Data/TrainingDbInitializer.cs diff --git a/src/CatalogService/CatalogService.csproj b/src/CatalogService/CatalogService.csproj index c36fcf9..3c55125 100644 --- a/src/CatalogService/CatalogService.csproj +++ b/src/CatalogService/CatalogService.csproj @@ -20,4 +20,8 @@ + + + + \ No newline at end of file diff --git a/src/CatalogService/Controllers/ExercicesController.cs b/src/CatalogService/Controllers/ExercicesController.cs index 5370499..8fb59c5 100644 --- a/src/CatalogService/Controllers/ExercicesController.cs +++ b/src/CatalogService/Controllers/ExercicesController.cs @@ -27,7 +27,7 @@ public class ExercicesController : ControllerBase [AllowAnonymous] public async Task Create([FromBody] CreateExerciceTemplateDto dto) { - var exercice = _mapper.Map(dto); + var exercice = _mapper.Map(dto); _context.Exercices.Add(exercice); await _context.SaveChangesAsync(); return CreatedAtAction(nameof(GetById), new { id = exercice.Id }, _mapper.Map(exercice)); diff --git a/src/CatalogService/Data/CatalogDbContext.cs b/src/CatalogService/Data/CatalogDbContext.cs index f870489..ba8bfc1 100644 --- a/src/CatalogService/Data/CatalogDbContext.cs +++ b/src/CatalogService/Data/CatalogDbContext.cs @@ -9,5 +9,5 @@ public class CatalogDbContext : DbContext { } - public DbSet Exercices { get; set; } + public DbSet Exercices { get; set; } } \ No newline at end of file diff --git a/src/CatalogService/Data/DbInitializer.cs b/src/CatalogService/Data/DbInitializer.cs index 65cea6b..7fd27b5 100644 --- a/src/CatalogService/Data/DbInitializer.cs +++ b/src/CatalogService/Data/DbInitializer.cs @@ -22,9 +22,9 @@ public class DbInitializer return; } - var exercices = new List() + var exercices = new List() { - new Exercice + new ExerciceTemplate { Id = Guid.NewGuid().ToString(), Name = "Squat", @@ -33,7 +33,7 @@ public class DbInitializer ImageUrl = "images/squat.jpg", VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley", }, - new Exercice + new ExerciceTemplate { Id = Guid.NewGuid().ToString(), Name = "Bench Press", @@ -42,7 +42,7 @@ public class DbInitializer ImageUrl = "images/bench_press.jpg", VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley", }, - new Exercice + new ExerciceTemplate { Id = Guid.NewGuid().ToString(), Name = "Deadlift", @@ -51,7 +51,7 @@ public class DbInitializer ImageUrl = "images/deadlift.jpg", VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley", }, - new Exercice + new ExerciceTemplate { Id = Guid.NewGuid().ToString(), Name = "Shoulder Press", @@ -60,7 +60,7 @@ public class DbInitializer ImageUrl = "images/shoulder_press.jpg", VideoUrl = "https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley", }, - new Exercice + new ExerciceTemplate { Id = Guid.NewGuid().ToString(), Name = "Running on Treadmill", diff --git a/src/CatalogService/RequestHelpers/MappingProfiles.cs b/src/CatalogService/RequestHelpers/MappingProfiles.cs index a1f98bb..c41fe6f 100644 --- a/src/CatalogService/RequestHelpers/MappingProfiles.cs +++ b/src/CatalogService/RequestHelpers/MappingProfiles.cs @@ -8,9 +8,9 @@ public class MappingProfiles : Profile { public MappingProfiles() { - CreateMap(); - CreateMap(); - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); + CreateMap(); } } \ No newline at end of file diff --git a/src/CatalogService/Entities/Exercice.cs b/src/Shared/Entities/ExerciceTemplate.cs similarity index 92% rename from src/CatalogService/Entities/Exercice.cs rename to src/Shared/Entities/ExerciceTemplate.cs index 99ed2fc..97a52db 100644 --- a/src/CatalogService/Entities/Exercice.cs +++ b/src/Shared/Entities/ExerciceTemplate.cs @@ -3,7 +3,7 @@ using Shared.Enum; namespace CatalogService.Entities; -public class Exercice : EntityBase +public class ExerciceTemplate : EntityBase { public string Name { get; set; } diff --git a/src/TrainingSvc/Data/Migrations/20250607133126_InitialCreate.Designer.cs b/src/TrainingSvc/Data/Migrations/20250607133126_InitialCreate.Designer.cs new file mode 100644 index 0000000..15d7ee4 --- /dev/null +++ b/src/TrainingSvc/Data/Migrations/20250607133126_InitialCreate.Designer.cs @@ -0,0 +1,204 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using TrainingSvc.Data; + +#nullable disable + +namespace TrainingSvc.Data.Migrations +{ + [DbContext(typeof(TrainingDbContext))] + [Migration("20250607133126_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.15") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("CatalogService.Entities.ExerciceTemplate", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("ImageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Target") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoUrl") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ExerciceTemplates"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.ExerciceInstance", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Duration") + .HasColumnType("real"); + + b.Property("ExerciceTemplateId") + .HasColumnType("text"); + + b.Property("IsDone") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NbReps") + .HasColumnType("integer"); + + b.Property("NbSets") + .HasColumnType("integer"); + + b.Property("RestingTime") + .HasColumnType("real"); + + b.Property("SessionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Weight") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("SessionId"); + + b.ToTable("ExerciceInstances"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.Session", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Day") + .HasColumnType("integer"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Target") + .HasColumnType("integer"); + + b.Property("TrainingProgramId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TrainingProgramId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.TrainingProgram", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Difficulty") + .HasColumnType("integer"); + + b.Property("Goal") + .HasColumnType("integer"); + + b.Property("Lang") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NbDays") + .HasColumnType("integer"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WeekDuration") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("TrainingPrograms"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.ExerciceInstance", b => + { + b.HasOne("TrainingSvc.Entities.Session", "Session") + .WithMany("Exercices") + .HasForeignKey("SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.Session", b => + { + b.HasOne("TrainingSvc.Entities.TrainingProgram", "TrainingProgram") + .WithMany("Sessions") + .HasForeignKey("TrainingProgramId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrainingProgram"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.Session", b => + { + b.Navigation("Exercices"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.TrainingProgram", b => + { + b.Navigation("Sessions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/TrainingSvc/Data/Migrations/20250607133126_InitialCreate.cs b/src/TrainingSvc/Data/Migrations/20250607133126_InitialCreate.cs new file mode 100644 index 0000000..b09c24c --- /dev/null +++ b/src/TrainingSvc/Data/Migrations/20250607133126_InitialCreate.cs @@ -0,0 +1,126 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace TrainingSvc.Data.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ExerciceTemplates", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + Target = table.Column(type: "integer", nullable: false), + ImageUrl = table.Column(type: "text", nullable: false), + VideoUrl = table.Column(type: "text", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ExerciceTemplates", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TrainingPrograms", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Lang = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + WeekDuration = table.Column(type: "integer", nullable: false), + NbDays = table.Column(type: "integer", nullable: false), + OwnerId = table.Column(type: "text", nullable: false), + Goal = table.Column(type: "integer", nullable: false), + Difficulty = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TrainingPrograms", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Sessions", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + Day = table.Column(type: "integer", nullable: false), + Target = table.Column(type: "integer", nullable: true), + TrainingProgramId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Sessions", x => x.Id); + table.ForeignKey( + name: "FK_Sessions_TrainingPrograms_TrainingProgramId", + column: x => x.TrainingProgramId, + principalTable: "TrainingPrograms", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ExerciceInstances", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + ExerciceTemplateId = table.Column(type: "text", nullable: true), + Duration = table.Column(type: "real", nullable: false), + NbSets = table.Column(type: "integer", nullable: false), + NbReps = table.Column(type: "integer", nullable: false), + RestingTime = table.Column(type: "real", nullable: false), + Weight = table.Column(type: "real", nullable: true), + IsDone = table.Column(type: "boolean", nullable: false), + SessionId = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ExerciceInstances", x => x.Id); + table.ForeignKey( + name: "FK_ExerciceInstances_Sessions_SessionId", + column: x => x.SessionId, + principalTable: "Sessions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ExerciceInstances_SessionId", + table: "ExerciceInstances", + column: "SessionId"); + + migrationBuilder.CreateIndex( + name: "IX_Sessions_TrainingProgramId", + table: "Sessions", + column: "TrainingProgramId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ExerciceInstances"); + + migrationBuilder.DropTable( + name: "ExerciceTemplates"); + + migrationBuilder.DropTable( + name: "Sessions"); + + migrationBuilder.DropTable( + name: "TrainingPrograms"); + } + } +} diff --git a/src/TrainingSvc/Data/Migrations/TrainingDbContextModelSnapshot.cs b/src/TrainingSvc/Data/Migrations/TrainingDbContextModelSnapshot.cs new file mode 100644 index 0000000..352c7ce --- /dev/null +++ b/src/TrainingSvc/Data/Migrations/TrainingDbContextModelSnapshot.cs @@ -0,0 +1,201 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using TrainingSvc.Data; + +#nullable disable + +namespace TrainingSvc.Data.Migrations +{ + [DbContext(typeof(TrainingDbContext))] + partial class TrainingDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.15") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("CatalogService.Entities.ExerciceTemplate", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("ImageUrl") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Target") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoUrl") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ExerciceTemplates"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.ExerciceInstance", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Duration") + .HasColumnType("real"); + + b.Property("ExerciceTemplateId") + .HasColumnType("text"); + + b.Property("IsDone") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NbReps") + .HasColumnType("integer"); + + b.Property("NbSets") + .HasColumnType("integer"); + + b.Property("RestingTime") + .HasColumnType("real"); + + b.Property("SessionId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Weight") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("SessionId"); + + b.ToTable("ExerciceInstances"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.Session", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Day") + .HasColumnType("integer"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Target") + .HasColumnType("integer"); + + b.Property("TrainingProgramId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TrainingProgramId"); + + b.ToTable("Sessions"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.TrainingProgram", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Difficulty") + .HasColumnType("integer"); + + b.Property("Goal") + .HasColumnType("integer"); + + b.Property("Lang") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("NbDays") + .HasColumnType("integer"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("text"); + + b.Property("WeekDuration") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("TrainingPrograms"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.ExerciceInstance", b => + { + b.HasOne("TrainingSvc.Entities.Session", "Session") + .WithMany("Exercices") + .HasForeignKey("SessionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Session"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.Session", b => + { + b.HasOne("TrainingSvc.Entities.TrainingProgram", "TrainingProgram") + .WithMany("Sessions") + .HasForeignKey("TrainingProgramId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TrainingProgram"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.Session", b => + { + b.Navigation("Exercices"); + }); + + modelBuilder.Entity("TrainingSvc.Entities.TrainingProgram", b => + { + b.Navigation("Sessions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/TrainingSvc/Data/TrainingDbContext.cs b/src/TrainingSvc/Data/TrainingDbContext.cs index 82d9f9f..5d047bf 100644 --- a/src/TrainingSvc/Data/TrainingDbContext.cs +++ b/src/TrainingSvc/Data/TrainingDbContext.cs @@ -1,4 +1,6 @@ +using CatalogService.Entities; using Microsoft.EntityFrameworkCore; +using TrainingSvc.Entities; namespace TrainingSvc.Data; @@ -8,4 +10,12 @@ public class TrainingDbContext : DbContext { } + public DbSet ExerciceTemplates { get; set; } + + public DbSet ExerciceInstances { get; set; } + + public DbSet Sessions { get; set; } + + public DbSet TrainingPrograms { get; set; } + } \ No newline at end of file diff --git a/src/TrainingSvc/Data/TrainingDbInitializer.cs b/src/TrainingSvc/Data/TrainingDbInitializer.cs new file mode 100644 index 0000000..1a958bc --- /dev/null +++ b/src/TrainingSvc/Data/TrainingDbInitializer.cs @@ -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()); + } + + 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() + { + 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(); + } +} \ No newline at end of file diff --git a/src/TrainingSvc/Entities/ExerciceInstance.cs b/src/TrainingSvc/Entities/ExerciceInstance.cs index e966b07..cb1760a 100644 --- a/src/TrainingSvc/Entities/ExerciceInstance.cs +++ b/src/TrainingSvc/Entities/ExerciceInstance.cs @@ -7,7 +7,7 @@ public class ExerciceInstance : EntityBase { public required string Name { get; set; } - public string? ExerciceId { get; set; } + public string? ExerciceTemplateId { get; set; } public float Duration { get; set; } diff --git a/src/TrainingSvc/Program.cs b/src/TrainingSvc/Program.cs index 4cb66c9..1a102aa 100644 --- a/src/TrainingSvc/Program.cs +++ b/src/TrainingSvc/Program.cs @@ -21,13 +21,13 @@ app.MapControllers(); try { - //NOT IMPLEMENTED - app.MapGet("/", () => "Hello World!"); - //DbInitializer.InitDb(app); + TrainingDbInitializer.InitDb(app); } catch (Exception e) { Console.WriteLine(e); } -app.Run(); \ No newline at end of file +app.Run(); + + diff --git a/src/TrainingSvc/TrainingSvc.csproj b/src/TrainingSvc/TrainingSvc.csproj index 9e84a87..094268b 100644 --- a/src/TrainingSvc/TrainingSvc.csproj +++ b/src/TrainingSvc/TrainingSvc.csproj @@ -11,6 +11,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +