diff --git a/Infrastructure/Entities/User.cs b/Infrastructure/Entities/User.cs index 9552372..8f52c97 100644 --- a/Infrastructure/Entities/User.cs +++ b/Infrastructure/Entities/User.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; using Infrastructure.Base; +using Shared; namespace Infrastructure.Entities; @@ -22,10 +23,10 @@ public class User : EntityBase public string? EGoal { get; set; } - public string? ESleepLevel { get; set; } - - public string? ESportLevel { get; set; } - + public EHealthProblem EHealthProblem { get; set; } + public ESport? ESport { get; set; } + public ESleepLevel? ESleepLevel { get; set; } + public ESportLevel? ESportLevel { get; set; } public string HashPassword { get; set; } public string? OAuthProvider { get; set; } diff --git a/Infrastructure/Migrations/20250109094527_Second.Designer.cs b/Infrastructure/Migrations/20250109094527_Second.Designer.cs new file mode 100644 index 0000000..5ec8b39 --- /dev/null +++ b/Infrastructure/Migrations/20250109094527_Second.Designer.cs @@ -0,0 +1,117 @@ +// +using Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Infrastructure.Migrations +{ + [DbContext(typeof(OptifitDbContext))] + [Migration("20250109094527_Second")] + partial class Second + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.1"); + + modelBuilder.Entity("Infrastructure.Entities.Exercice", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Duration") + .HasColumnType("REAL"); + + b.Property("Image") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbRepetitions") + .HasColumnType("INTEGER"); + + b.Property("NbSeries") + .HasColumnType("INTEGER"); + + b.Property("Video") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("Exercices"); + }); + + modelBuilder.Entity("Infrastructure.Entities.User", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("Age") + .HasColumnType("INTEGER"); + + b.Property("EGoal") + .HasColumnType("TEXT"); + + b.Property("EHealthProblem") + .HasColumnType("INTEGER"); + + b.Property("ESleepLevel") + .HasColumnType("INTEGER"); + + b.Property("ESport") + .HasColumnType("INTEGER"); + + b.Property("ESportLevel") + .HasColumnType("INTEGER"); + + b.Property("HashPassword") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Height") + .HasColumnType("REAL"); + + b.Property("Logo") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("NbSessionPerWeek") + .HasColumnType("INTEGER"); + + b.Property("OAuthId") + .HasColumnType("TEXT"); + + b.Property("OAuthProvider") + .HasColumnType("TEXT"); + + b.Property("Sexe") + .HasColumnType("INTEGER"); + + b.Property("Weight") + .HasColumnType("REAL"); + + b.HasKey("Id"); + + b.ToTable("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Infrastructure/Migrations/20250109094527_Second.cs b/Infrastructure/Migrations/20250109094527_Second.cs new file mode 100644 index 0000000..a09eabd --- /dev/null +++ b/Infrastructure/Migrations/20250109094527_Second.cs @@ -0,0 +1,75 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Infrastructure.Migrations +{ + /// + public partial class Second : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ESportLevel", + table: "Users", + type: "INTEGER", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ESleepLevel", + table: "Users", + type: "INTEGER", + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "EHealthProblem", + table: "Users", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ESport", + table: "Users", + type: "INTEGER", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "EHealthProblem", + table: "Users"); + + migrationBuilder.DropColumn( + name: "ESport", + table: "Users"); + + migrationBuilder.AlterColumn( + name: "ESportLevel", + table: "Users", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ESleepLevel", + table: "Users", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + } + } +} diff --git a/Infrastructure/Migrations/OptifitDbContextModelSnapshot.cs b/Infrastructure/Migrations/OptifitDbContextModelSnapshot.cs index 5361f59..5a17324 100644 --- a/Infrastructure/Migrations/OptifitDbContextModelSnapshot.cs +++ b/Infrastructure/Migrations/OptifitDbContextModelSnapshot.cs @@ -62,11 +62,17 @@ namespace Infrastructure.Migrations b.Property("EGoal") .HasColumnType("TEXT"); - b.Property("ESleepLevel") - .HasColumnType("TEXT"); + b.Property("EHealthProblem") + .HasColumnType("INTEGER"); - b.Property("ESportLevel") - .HasColumnType("TEXT"); + b.Property("ESleepLevel") + .HasColumnType("INTEGER"); + + b.Property("ESport") + .HasColumnType("INTEGER"); + + b.Property("ESportLevel") + .HasColumnType("INTEGER"); b.Property("HashPassword") .IsRequired() diff --git a/Infrastructure/Stub/StubbedContext.cs b/Infrastructure/Stub/StubbedContext.cs index b287d6e..0d46c2f 100644 --- a/Infrastructure/Stub/StubbedContext.cs +++ b/Infrastructure/Stub/StubbedContext.cs @@ -1,5 +1,6 @@ using Infrastructure.Entities; using Microsoft.EntityFrameworkCore; +using Shared; namespace Infrastructure.Stub; @@ -31,8 +32,8 @@ public class StubbedContext : OptifitDbContext Logo = GenerateRandomString(10), NbSessionPerWeek = GenerateRandomInt(1, 7), EGoal = GenerateRandomString(10), - ESleepLevel = GenerateRandomString(10), - ESportLevel = GenerateRandomString(10), + ESleepLevel = ESleepLevel.GOOD, + ESportLevel = ESportLevel.BEGINNER, HashPassword = GenerateRandomString(10), OAuthProvider = null, OAuthId = null @@ -48,8 +49,8 @@ public class StubbedContext : OptifitDbContext Logo = GenerateRandomString(10), NbSessionPerWeek = GenerateRandomInt(1, 7), EGoal = GenerateRandomString(10), - ESleepLevel = GenerateRandomString(10), - ESportLevel = GenerateRandomString(10), + ESleepLevel = ESleepLevel.GOOD, + ESportLevel = ESportLevel.BEGINNER, HashPassword = GenerateRandomString(10), OAuthProvider = null, OAuthId = null