🚨 Fix mapper bug

main
Leo TUAILLON 4 months ago
parent 8029b78885
commit d8b81f7566

@ -1,111 +0,0 @@
// <auto-generated />
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("20250109081041_Initialize")]
partial class Initialize
{
/// <inheritdoc />
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<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Duration")
.HasColumnType("REAL");
b.Property<string>("Image")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbRepetitions")
.HasColumnType("INTEGER");
b.Property<int>("NbSeries")
.HasColumnType("INTEGER");
b.Property<string>("Video")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Exercices");
});
modelBuilder.Entity("Infrastructure.Entities.User", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("Age")
.HasColumnType("INTEGER");
b.Property<string>("EGoal")
.HasColumnType("TEXT");
b.Property<string>("ESleepLevel")
.HasColumnType("TEXT");
b.Property<string>("ESportLevel")
.HasColumnType("TEXT");
b.Property<string>("HashPassword")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Height")
.HasColumnType("REAL");
b.Property<string>("Logo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbSessionPerWeek")
.HasColumnType("INTEGER");
b.Property<string>("OAuthId")
.HasColumnType("TEXT");
b.Property<string>("OAuthProvider")
.HasColumnType("TEXT");
b.Property<bool>("Sexe")
.HasColumnType("INTEGER");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("Id");
b.ToTable("Users");
});
#pragma warning restore 612, 618
}
}
}

@ -1,66 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class Initialize : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Exercices",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Duration = table.Column<float>(type: "REAL", nullable: false),
Image = table.Column<string>(type: "TEXT", nullable: false),
Video = table.Column<string>(type: "TEXT", nullable: false),
NbSeries = table.Column<int>(type: "INTEGER", nullable: false),
NbRepetitions = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Exercices", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
Age = table.Column<int>(type: "INTEGER", nullable: false),
Height = table.Column<float>(type: "REAL", nullable: false),
Weight = table.Column<float>(type: "REAL", nullable: false),
Sexe = table.Column<bool>(type: "INTEGER", nullable: false),
Logo = table.Column<string>(type: "TEXT", nullable: false),
NbSessionPerWeek = table.Column<int>(type: "INTEGER", nullable: false),
EGoal = table.Column<string>(type: "TEXT", nullable: true),
ESleepLevel = table.Column<string>(type: "TEXT", nullable: true),
ESportLevel = table.Column<string>(type: "TEXT", nullable: true),
HashPassword = table.Column<string>(type: "TEXT", nullable: false),
OAuthProvider = table.Column<string>(type: "TEXT", nullable: true),
OAuthId = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Exercices");
migrationBuilder.DropTable(
name: "Users");
}
}
}

@ -1,191 +0,0 @@
// <auto-generated />
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("20250109094119_TrainingProgram")]
partial class TrainingProgram
{
/// <inheritdoc />
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<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Duration")
.HasColumnType("REAL");
b.Property<string>("Image")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbRepetitions")
.HasColumnType("INTEGER");
b.Property<int>("NbSeries")
.HasColumnType("INTEGER");
b.Property<string>("SessionId")
.HasColumnType("TEXT");
b.Property<string>("Video")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("SessionId");
b.ToTable("Exercices");
});
modelBuilder.Entity("Infrastructure.Entities.Program", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Difficulty")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("WeekDuration")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Programs");
});
modelBuilder.Entity("Infrastructure.Entities.Session", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Duration")
.HasColumnType("REAL");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ProgramId")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ProgramId");
b.ToTable("Sessions");
});
modelBuilder.Entity("Infrastructure.Entities.User", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("Age")
.HasColumnType("INTEGER");
b.Property<string>("EGoal")
.HasColumnType("TEXT");
b.Property<string>("ESleepLevel")
.HasColumnType("TEXT");
b.Property<string>("ESportLevel")
.HasColumnType("TEXT");
b.Property<string>("HashPassword")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Height")
.HasColumnType("REAL");
b.Property<string>("Logo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbSessionPerWeek")
.HasColumnType("INTEGER");
b.Property<string>("OAuthId")
.HasColumnType("TEXT");
b.Property<string>("OAuthProvider")
.HasColumnType("TEXT");
b.Property<bool>("Sexe")
.HasColumnType("INTEGER");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("Infrastructure.Entities.Exercice", b =>
{
b.HasOne("Infrastructure.Entities.Session", null)
.WithMany("Exercices")
.HasForeignKey("SessionId");
});
modelBuilder.Entity("Infrastructure.Entities.Session", b =>
{
b.HasOne("Infrastructure.Entities.Program", null)
.WithMany("Sessions")
.HasForeignKey("ProgramId");
});
modelBuilder.Entity("Infrastructure.Entities.Program", b =>
{
b.Navigation("Sessions");
});
modelBuilder.Entity("Infrastructure.Entities.Session", b =>
{
b.Navigation("Exercices");
});
#pragma warning restore 612, 618
}
}
}

@ -1,94 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class TrainingProgram : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "SessionId",
table: "Exercices",
type: "TEXT",
nullable: true);
migrationBuilder.CreateTable(
name: "Programs",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
WeekDuration = table.Column<int>(type: "INTEGER", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Difficulty = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Programs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Sessions",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", nullable: false),
Duration = table.Column<float>(type: "REAL", nullable: false),
ProgramId = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Sessions", x => x.Id);
table.ForeignKey(
name: "FK_Sessions_Programs_ProgramId",
column: x => x.ProgramId,
principalTable: "Programs",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Exercices_SessionId",
table: "Exercices",
column: "SessionId");
migrationBuilder.CreateIndex(
name: "IX_Sessions_ProgramId",
table: "Sessions",
column: "ProgramId");
migrationBuilder.AddForeignKey(
name: "FK_Exercices_Sessions_SessionId",
table: "Exercices",
column: "SessionId",
principalTable: "Sessions",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Exercices_Sessions_SessionId",
table: "Exercices");
migrationBuilder.DropTable(
name: "Sessions");
migrationBuilder.DropTable(
name: "Programs");
migrationBuilder.DropIndex(
name: "IX_Exercices_SessionId",
table: "Exercices");
migrationBuilder.DropColumn(
name: "SessionId",
table: "Exercices");
}
}
}

@ -1,117 +0,0 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Duration")
.HasColumnType("REAL");
b.Property<string>("Image")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbRepetitions")
.HasColumnType("INTEGER");
b.Property<int>("NbSeries")
.HasColumnType("INTEGER");
b.Property<string>("Video")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Exercices");
});
modelBuilder.Entity("Infrastructure.Entities.User", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("Age")
.HasColumnType("INTEGER");
b.Property<string>("EGoal")
.HasColumnType("TEXT");
b.Property<int>("EHealthProblem")
.HasColumnType("INTEGER");
b.Property<int?>("ESleepLevel")
.HasColumnType("INTEGER");
b.Property<int?>("ESport")
.HasColumnType("INTEGER");
b.Property<int?>("ESportLevel")
.HasColumnType("INTEGER");
b.Property<string>("HashPassword")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Height")
.HasColumnType("REAL");
b.Property<string>("Logo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbSessionPerWeek")
.HasColumnType("INTEGER");
b.Property<string>("OAuthId")
.HasColumnType("TEXT");
b.Property<string>("OAuthProvider")
.HasColumnType("TEXT");
b.Property<bool>("Sexe")
.HasColumnType("INTEGER");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("Id");
b.ToTable("Users");
});
#pragma warning restore 612, 618
}
}
}

@ -1,75 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Infrastructure.Migrations
{
/// <inheritdoc />
public partial class Second : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "ESportLevel",
table: "Users",
type: "INTEGER",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ESleepLevel",
table: "Users",
type: "INTEGER",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);
migrationBuilder.AddColumn<int>(
name: "EHealthProblem",
table: "Users",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "ESport",
table: "Users",
type: "INTEGER",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EHealthProblem",
table: "Users");
migrationBuilder.DropColumn(
name: "ESport",
table: "Users");
migrationBuilder.AlterColumn<string>(
name: "ESportLevel",
table: "Users",
type: "TEXT",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "ESleepLevel",
table: "Users",
type: "TEXT",
nullable: true,
oldClrType: typeof(int),
oldType: "INTEGER",
oldNullable: true);
}
}
}

@ -1,194 +0,0 @@
// <auto-generated />
using Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Infrastructure.Migrations
{
[DbContext(typeof(OptifitDbContext))]
partial class OptifitDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.1");
modelBuilder.Entity("Infrastructure.Entities.Exercice", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Duration")
.HasColumnType("REAL");
b.Property<string>("Image")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbRepetitions")
.HasColumnType("INTEGER");
b.Property<int>("NbSeries")
.HasColumnType("INTEGER");
b.Property<string>("SessionId")
.HasColumnType("TEXT");
b.Property<string>("Video")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("SessionId");
b.ToTable("Exercices");
});
modelBuilder.Entity("Infrastructure.Entities.Program", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Difficulty")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("WeekDuration")
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Programs");
});
modelBuilder.Entity("Infrastructure.Entities.Session", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Duration")
.HasColumnType("REAL");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("ProgramId")
.HasColumnType("TEXT");
b.HasKey("Id");
b.HasIndex("ProgramId");
b.ToTable("Sessions");
});
modelBuilder.Entity("Infrastructure.Entities.User", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<int>("Age")
.HasColumnType("INTEGER");
b.Property<string>("EGoal")
.HasColumnType("TEXT");
b.Property<int>("EHealthProblem")
.HasColumnType("INTEGER");
b.Property<int?>("ESleepLevel")
.HasColumnType("INTEGER");
b.Property<int?>("ESport")
.HasColumnType("INTEGER");
b.Property<int?>("ESportLevel")
.HasColumnType("INTEGER");
b.Property<string>("HashPassword")
.IsRequired()
.HasColumnType("TEXT");
b.Property<float>("Height")
.HasColumnType("REAL");
b.Property<string>("Logo")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("NbSessionPerWeek")
.HasColumnType("INTEGER");
b.Property<string>("OAuthId")
.HasColumnType("TEXT");
b.Property<string>("OAuthProvider")
.HasColumnType("TEXT");
b.Property<bool>("Sexe")
.HasColumnType("INTEGER");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("Infrastructure.Entities.Exercice", b =>
{
b.HasOne("Infrastructure.Entities.Session", null)
.WithMany("Exercices")
.HasForeignKey("SessionId");
});
modelBuilder.Entity("Infrastructure.Entities.Session", b =>
{
b.HasOne("Infrastructure.Entities.Program", null)
.WithMany("Sessions")
.HasForeignKey("ProgramId");
});
modelBuilder.Entity("Infrastructure.Entities.Program", b =>
{
b.Navigation("Sessions");
});
modelBuilder.Entity("Infrastructure.Entities.Session", b =>
{
b.Navigation("Exercices");
});
#pragma warning restore 612, 618
}
}
}

Binary file not shown.

@ -3,17 +3,23 @@ using Infrastructure.Entities;
using Server.Dto.Request; using Server.Dto.Request;
using Server.Dto.Response; using Server.Dto.Response;
namespace Server.Mappers namespace Server.Mappers;
{
public class TrainingProgramProfile : Profile public class TrainingProgramProfile : Profile
{ {
public TrainingProgramProfile() public TrainingProgramProfile()
{ {
CreateMap<TrainingProgram, ResponseTrainingProgramDto>() CreateMap<TrainingProgram, ResponseTrainingProgramDto>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
.ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description))
.ForMember(dest => dest.WeekDuration, opt => opt.MapFrom(src => src.WeekDuration))
.ForMember(dest => dest.Sessions, opt => opt.MapFrom(src => src.Sessions)); .ForMember(dest => dest.Sessions, opt => opt.MapFrom(src => src.Sessions));
CreateMap<RequestTrainingProgramDto, TrainingProgram>() CreateMap<RequestTrainingProgramDto, TrainingProgram>()
.ForMember(dest => dest, opt => opt.Ignore()); .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
} .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description))
.ForMember(dest => dest.WeekDuration, opt => opt.MapFrom(src => src.WeekDuration))
.ForMember(dest => dest.Sessions, opt => opt.MapFrom(src => src.Sessions));
} }
} }
Loading…
Cancel
Save