diff --git a/src/DbContextLib/LibraryContext.cs b/src/DbContextLib/LibraryContext.cs index 008bbc9..33b2fea 100644 --- a/src/DbContextLib/LibraryContext.cs +++ b/src/DbContextLib/LibraryContext.cs @@ -7,6 +7,14 @@ public class LibraryContext : DbContext { public DbSet AthletesSet { get; set; } + public DbSet ActivitiesSet { get; set; } + + public DbSet DataSourcesSet { get; set; } + public DbSet HeartRatesSet { get; set; } + public DbSet NotificationsSet { get; set; } + public DbSet StatisticsSet { get; set; } + public DbSet TrainingsSet { get; set; } + public LibraryContext() :base() { } diff --git a/src/Entities/ActivityEntity.cs b/src/Entities/ActivityEntity.cs index 62b0870..7d0c1a0 100644 --- a/src/Entities/ActivityEntity.cs +++ b/src/Entities/ActivityEntity.cs @@ -10,9 +10,20 @@ public class ActivityEntity [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int IdActivity { get; set; } + [Required] + [MaxLength(100)] public required string Type { get; set; } + [Required(ErrorMessage = "Activity Date is required")] + [DataType(DataType.DateTime)] + [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)] public DateTime Date { get; set; } + [Required(ErrorMessage = "Start Activity Hour is required")] + [DataType(DataType.DateTime)] + [DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)] public DateTime StartTime { get; set; } + [Required(ErrorMessage = "End Activity Hour is required")] + [DataType(DataType.DateTime)] + [DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)] public DateTime EndTime { get; set; } public int EffortFelt { get; set; } public float Variability { get; set; } diff --git a/src/Entities/AthleteEntity.cs b/src/Entities/AthleteEntity.cs index a9fff57..c547a45 100644 --- a/src/Entities/AthleteEntity.cs +++ b/src/Entities/AthleteEntity.cs @@ -17,9 +17,11 @@ public class AthleteEntity public required string LastName { get; set; } [MaxLength(150)] public required string FirstName { get; set; } + [MaxLength(100)] public required string Email { get; set; } + [MaxLength(1)] public required string Sexe { get; set; } - public float Lenght { get; set; } + public double Lenght { get; set; } public float Weight { get; set; } public required string Password { get; set; } public DateTime DateOfBirth { get; set; } diff --git a/src/Entities/DataSourceEntity.cs b/src/Entities/DataSourceEntity.cs index 8bed224..e13a0ea 100644 --- a/src/Entities/DataSourceEntity.cs +++ b/src/Entities/DataSourceEntity.cs @@ -9,7 +9,9 @@ public class DataSourceEntity [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int IdSource { get; set; } + [MaxLength(100)] public required string Type { get; set; } + [MaxLength(100)] public required string Modele { get; set; } public float Precision { get; set; } } \ No newline at end of file diff --git a/src/Entities/HeartRateEntity.cs b/src/Entities/HeartRateEntity.cs index 0806219..028f9d1 100644 --- a/src/Entities/HeartRateEntity.cs +++ b/src/Entities/HeartRateEntity.cs @@ -10,6 +10,9 @@ public class HeartRateEntity [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int IdHeartRate { get; set; } public double Altitude { get; set; } + [Required(ErrorMessage = "HeartRate Time is required")] + [DataType(DataType.DateTime)] + [DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)] public DateTime Time { get; set; } public float Temperature { get; set; } public int Bpm { get; set; } diff --git a/src/Entities/NotificationEntity.cs b/src/Entities/NotificationEntity.cs index 53d12cc..adecd52 100644 --- a/src/Entities/NotificationEntity.cs +++ b/src/Entities/NotificationEntity.cs @@ -9,8 +9,14 @@ public class NotificationEntity [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int IdNotif { get; set; } - public required string Message { get; set; } + [MaxLength(100)] + [Required] // dire obligatoire dans la base de données + public string Message { get; set; } = null!; // pour dire pas null + [Required(ErrorMessage = "Notification Date is required")] + [DataType(DataType.DateTime)] + [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy - HH}", ApplyFormatInEditMode = true)] public DateTime Date { get; set; } - public required bool Statut { get; set; } + public bool Statut { get; set; } + [MaxLength(100)] public required string Urgence { get; set; } } \ No newline at end of file diff --git a/src/Entities/StatisticEntity.cs b/src/Entities/StatisticEntity.cs index ed01553..23cd2dc 100644 --- a/src/Entities/StatisticEntity.cs +++ b/src/Entities/StatisticEntity.cs @@ -13,5 +13,8 @@ public class StatisticEntity public double AverageHeartRate { get; set; } public double MaximumHeartRate { get; set; } public double AverageCaloriesBurned { get; set; } + [Required(ErrorMessage = "Satistic Date is required")] + [DataType(DataType.DateTime)] + [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)] public DateTime Date { get; set; } } \ No newline at end of file diff --git a/src/Entities/TrainingEntity.cs b/src/Entities/TrainingEntity.cs index 5bf7949..2f6644e 100644 --- a/src/Entities/TrainingEntity.cs +++ b/src/Entities/TrainingEntity.cs @@ -1,5 +1,6 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.CompilerServices; namespace Entities; @@ -10,6 +11,9 @@ public class TrainingEntity [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int IdTraining { get; set; } + [Required(ErrorMessage = "Training Date is required")] + [DataType(DataType.DateTime)] + [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)] public DateTime Date { get; set; } [MaxLength(300)] public string? Description { get; set; } diff --git a/src/StubbedContextLib/AthleteStubbedContext.cs b/src/StubbedContextLib/AthleteStubbedContext.cs index c4a238b..4f01ed9 100644 --- a/src/StubbedContextLib/AthleteStubbedContext.cs +++ b/src/StubbedContextLib/AthleteStubbedContext.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore; namespace StubbedContextLib; -public class AthleteStubbedContext : LibraryContext +public class AthleteStubbedContext : ActivityStubbedContext { public AthleteStubbedContext() :base() diff --git a/src/StubbedContextLib/DataSourceStubbedContext.cs b/src/StubbedContextLib/DataSourceStubbedContext.cs index f1b8b2b..a9d0472 100644 --- a/src/StubbedContextLib/DataSourceStubbedContext.cs +++ b/src/StubbedContextLib/DataSourceStubbedContext.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore; namespace StubbedContextLib; -public class DataSourceStubbedContext : LibraryContext +public class DataSourceStubbedContext : AthleteStubbedContext { public DataSourceStubbedContext() :base() diff --git a/src/StubbedContextLib/HeartRateStubbedContext.cs b/src/StubbedContextLib/HeartRateStubbedContext.cs index f22659a..0f6c3ac 100644 --- a/src/StubbedContextLib/HeartRateStubbedContext.cs +++ b/src/StubbedContextLib/HeartRateStubbedContext.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore; namespace StubbedContextLib; -public class HeartRateStubbedContext : LibraryContext +public class HeartRateStubbedContext : DataSourceStubbedContext { public HeartRateStubbedContext() :base() diff --git a/src/StubbedContextLib/Migrations/20240216134447_MyMirgations.Designer.cs b/src/StubbedContextLib/Migrations/20240216134447_MyMirgations.Designer.cs deleted file mode 100644 index 4232a95..0000000 --- a/src/StubbedContextLib/Migrations/20240216134447_MyMirgations.Designer.cs +++ /dev/null @@ -1,147 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using StubbedContextLib; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - [DbContext(typeof(AthleteStubbedContext))] - [Migration("20240216134447_MyMirgations")] - partial class MyMirgations - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.2"); - - modelBuilder.Entity("Entities.AthleteEntity", b => - { - b.Property("IdAthlete") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("DateOfBirth") - .HasColumnType("TEXT"); - - b.Property("Email") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("TEXT"); - - b.Property("IsCoach") - .HasColumnType("INTEGER"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Lenght") - .HasColumnType("REAL"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Sexe") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Weight") - .HasColumnType("REAL"); - - b.HasKey("IdAthlete"); - - b.ToTable("Athlete"); - - b.HasData( - new - { - IdAthlete = 1, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "john.doe@example.com", - FirstName = "John", - IsCoach = true, - LastName = "Doe", - Lenght = 1.8, - Password = "password123", - Sexe = "M", - Username = "Doe", - Weight = 75f - }, - new - { - IdAthlete = 2, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "jane.smith@example.com", - FirstName = "Jane", - IsCoach = false, - LastName = "Smith", - Lenght = 1.6499999999999999, - Password = "secure456", - Sexe = "F", - Username = "Smith", - Weight = 60f - }, - new - { - IdAthlete = 3, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "paul.martin@example.com", - FirstName = "Paul", - IsCoach = true, - LastName = "Martin", - Lenght = 1.75, - Password = "super789", - Sexe = "M", - Username = "Martin", - Weight = 68f - }, - new - { - IdAthlete = 4, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "anna.brown@example.com", - FirstName = "Anna", - IsCoach = false, - LastName = "Brown", - Lenght = 1.7, - Password = "test000", - Sexe = "F", - Username = "Brown", - Weight = 58f - }, - new - { - IdAthlete = 5, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "bruce.lee@example.com", - FirstName = "Bruce", - IsCoach = false, - LastName = "Lee", - Lenght = 2.0, - Password = "hello321", - Sexe = "M", - Username = "Lee", - Weight = 90f - }); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/StubbedContextLib/Migrations/20240216134447_MyMirgations.cs b/src/StubbedContextLib/Migrations/20240216134447_MyMirgations.cs deleted file mode 100644 index 3f410d6..0000000 --- a/src/StubbedContextLib/Migrations/20240216134447_MyMirgations.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace StubbedContextLib.Migrations -{ - /// - public partial class MyMirgations : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Athlete", - columns: table => new - { - IdAthlete = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Username = table.Column(type: "TEXT", maxLength: 100, nullable: false), - LastName = table.Column(type: "TEXT", maxLength: 100, nullable: false), - FirstName = table.Column(type: "TEXT", maxLength: 150, nullable: false), - Email = table.Column(type: "TEXT", nullable: false), - Sexe = table.Column(type: "TEXT", nullable: false), - Lenght = table.Column(type: "REAL", nullable: false), - Weight = table.Column(type: "REAL", nullable: false), - Password = table.Column(type: "TEXT", nullable: false), - DateOfBirth = table.Column(type: "TEXT", nullable: false), - IsCoach = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Athlete", x => x.IdAthlete); - }); - - migrationBuilder.InsertData( - table: "Athlete", - columns: new[] { "IdAthlete", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Lenght", "Password", "Sexe", "Username", "Weight" }, - values: new object[,] - { - { 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "john.doe@example.com", "John", true, "Doe", 1.8, "password123", "M", "Doe", 75f }, - { 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "jane.smith@example.com", "Jane", false, "Smith", 1.6499999999999999, "secure456", "F", "Smith", 60f }, - { 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "paul.martin@example.com", "Paul", true, "Martin", 1.75, "super789", "M", "Martin", 68f }, - { 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "anna.brown@example.com", "Anna", false, "Brown", 1.7, "test000", "F", "Brown", 58f }, - { 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "bruce.lee@example.com", "Bruce", false, "Lee", 2.0, "hello321", "M", "Lee", 90f } - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Athlete"); - } - } -} diff --git a/src/StubbedContextLib/Migrations/20240219105500_MyMigrations.Designer.cs b/src/StubbedContextLib/Migrations/20240219105500_MyMigrations.Designer.cs new file mode 100644 index 0000000..d736e69 --- /dev/null +++ b/src/StubbedContextLib/Migrations/20240219105500_MyMigrations.Designer.cs @@ -0,0 +1,678 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using StubbedContextLib; + +#nullable disable + +namespace StubbedContextLib.Migrations +{ + [DbContext(typeof(TrainingStubbedContext))] + [Migration("20240219105500_MyMigrations")] + partial class MyMigrations + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.2"); + + modelBuilder.Entity("Entities.ActivityEntity", b => + { + b.Property("IdActivity") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Average") + .HasColumnType("REAL"); + + b.Property("AverageTemperature") + .HasColumnType("REAL"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("EffortFelt") + .HasColumnType("INTEGER"); + + b.Property("EndTime") + .HasColumnType("TEXT"); + + b.Property("HasAutoPause") + .HasColumnType("INTEGER"); + + b.Property("Maximum") + .HasColumnType("INTEGER"); + + b.Property("Minimum") + .HasColumnType("INTEGER"); + + b.Property("StandardDeviation") + .HasColumnType("REAL"); + + b.Property("StartTime") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Variability") + .HasColumnType("REAL"); + + b.Property("Variance") + .HasColumnType("REAL"); + + b.HasKey("IdActivity"); + + b.ToTable("Activity"); + + b.HasData( + new + { + IdActivity = 1, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Running", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 2, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Cycling", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 3, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Swimming", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 4, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Walking", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 5, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Hiking", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 6, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Climbing", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 7, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Yoga", + Variability = 0.5f, + Variance = 0.5f + }); + }); + + modelBuilder.Entity("Entities.AthleteEntity", b => + { + b.Property("IdAthlete") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DateOfBirth") + .HasColumnType("TEXT"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("IsCoach") + .HasColumnType("INTEGER"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Lenght") + .HasColumnType("REAL"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Sexe") + .IsRequired() + .HasMaxLength(1) + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Weight") + .HasColumnType("REAL"); + + b.HasKey("IdAthlete"); + + b.ToTable("Athlete"); + + b.HasData( + new + { + IdAthlete = 1, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "john.doe@example.com", + FirstName = "John", + IsCoach = true, + LastName = "Doe", + Lenght = 1.8, + Password = "password123", + Sexe = "M", + Username = "Doe", + Weight = 75f + }, + new + { + IdAthlete = 2, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "jane.smith@example.com", + FirstName = "Jane", + IsCoach = false, + LastName = "Smith", + Lenght = 1.6499999999999999, + Password = "secure456", + Sexe = "F", + Username = "Smith", + Weight = 60f + }, + new + { + IdAthlete = 3, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "paul.martin@example.com", + FirstName = "Paul", + IsCoach = true, + LastName = "Martin", + Lenght = 1.75, + Password = "super789", + Sexe = "M", + Username = "Martin", + Weight = 68f + }, + new + { + IdAthlete = 4, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "anna.brown@example.com", + FirstName = "Anna", + IsCoach = false, + LastName = "Brown", + Lenght = 1.7, + Password = "test000", + Sexe = "F", + Username = "Brown", + Weight = 58f + }, + new + { + IdAthlete = 5, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "bruce.lee@example.com", + FirstName = "Bruce", + IsCoach = false, + LastName = "Lee", + Lenght = 2.0, + Password = "hello321", + Sexe = "M", + Username = "Lee", + Weight = 90f + }); + }); + + modelBuilder.Entity("Entities.DataSourceEntity", b => + { + b.Property("IdSource") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Modele") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Precision") + .HasColumnType("REAL"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("IdSource"); + + b.ToTable("DataSource"); + + b.HasData( + new + { + IdSource = 1, + Modele = "Garmin", + Precision = 0.5f, + Type = "Smartwatch" + }, + new + { + IdSource = 2, + Modele = "Polar", + Precision = 0.5f, + Type = "Smartwatch" + }, + new + { + IdSource = 3, + Modele = "Suunto", + Precision = 0.5f, + Type = "Smartwatch" + }, + new + { + IdSource = 4, + Modele = "Fitbit", + Precision = 0.5f, + Type = "Smartwatch" + }, + new + { + IdSource = 5, + Modele = "Apple Watch", + Precision = 0.5f, + Type = "Smartwatch" + }); + }); + + modelBuilder.Entity("Entities.HeartRateEntity", b => + { + b.Property("IdHeartRate") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Altitude") + .HasColumnType("REAL"); + + b.Property("Bpm") + .HasColumnType("INTEGER"); + + b.Property("Latitude") + .HasColumnType("REAL"); + + b.Property("Longitude") + .HasColumnType("REAL"); + + b.Property("Temperature") + .HasColumnType("REAL"); + + b.Property("Time") + .HasColumnType("TEXT"); + + b.HasKey("IdHeartRate"); + + b.ToTable("HeartRate"); + + b.HasData( + new + { + IdHeartRate = 1, + Altitude = 0.0, + Bpm = 60, + Latitude = 66f, + Longitude = 35f, + Temperature = 20f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + IdHeartRate = 2, + Altitude = 10.0, + Bpm = 65, + Latitude = 67f, + Longitude = 35f, + Temperature = 20.5f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + IdHeartRate = 3, + Altitude = 11.0, + Bpm = 71, + Latitude = 66f, + Longitude = 36f, + Temperature = 20f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + IdHeartRate = 4, + Altitude = 12.0, + Bpm = 75, + Latitude = 67f, + Longitude = 36f, + Temperature = 20.5f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + IdHeartRate = 5, + Altitude = 13.0, + Bpm = 80, + Latitude = 66f, + Longitude = 37f, + Temperature = 20f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }); + }); + + modelBuilder.Entity("Entities.NotificationEntity", b => + { + b.Property("IdNotif") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Statut") + .HasColumnType("INTEGER"); + + b.Property("Urgence") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("IdNotif"); + + b.ToTable("Notification"); + + b.HasData( + new + { + IdNotif = 1, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new activity to check", + Statut = true, + Urgence = "A" + }, + new + { + IdNotif = 2, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new athlete to check", + Statut = false, + Urgence = "3" + }, + new + { + IdNotif = 3, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new heart rate to check", + Statut = true, + Urgence = "2" + }, + new + { + IdNotif = 4, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new data source to check", + Statut = false, + Urgence = "1" + }, + new + { + IdNotif = 5, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new notification to check", + Statut = true, + Urgence = "3" + }); + }); + + modelBuilder.Entity("Entities.StatisticEntity", b => + { + b.Property("IdStatistic") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AverageCaloriesBurned") + .HasColumnType("REAL"); + + b.Property("AverageHeartRate") + .HasColumnType("REAL"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("MaximumHeartRate") + .HasColumnType("REAL"); + + b.Property("Weight") + .HasColumnType("REAL"); + + b.HasKey("IdStatistic"); + + b.ToTable("Statistic"); + + b.HasData( + new + { + IdStatistic = 1, + AverageCaloriesBurned = 500.0, + AverageHeartRate = 120.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 180.0, + Weight = 75f + }, + new + { + IdStatistic = 2, + AverageCaloriesBurned = 600.0, + AverageHeartRate = 130.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 190.0, + Weight = 60f + }, + new + { + IdStatistic = 3, + AverageCaloriesBurned = 550.0, + AverageHeartRate = 125.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 185.0, + Weight = 68f + }, + new + { + IdStatistic = 4, + AverageCaloriesBurned = 650.0, + AverageHeartRate = 135.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 195.0, + Weight = 58f + }, + new + { + IdStatistic = 5, + AverageCaloriesBurned = 450.0, + AverageHeartRate = 110.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 170.0, + Weight = 90f + }); + }); + + modelBuilder.Entity("Entities.TrainingEntity", b => + { + b.Property("IdTraining") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FeedBack") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Latitude") + .HasColumnType("REAL"); + + b.Property("Longitude") + .HasColumnType("REAL"); + + b.HasKey("IdTraining"); + + b.ToTable("Training"); + + b.HasData( + new + { + IdTraining = 1, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Running", + FeedBack = "Good", + Latitude = 48.8566f, + Longitude = 2.3522f + }, + new + { + IdTraining = 2, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Cycling", + Latitude = 48.8566f, + Longitude = 2.3522f + }, + new + { + IdTraining = 3, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + FeedBack = "Good", + Latitude = 48.8566f, + Longitude = 2.3522f + }, + new + { + IdTraining = 4, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Running", + FeedBack = "Good", + Latitude = 48.8566f, + Longitude = 2.3522f + }, + new + { + IdTraining = 5, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Cycling", + Latitude = 48.8566f, + Longitude = 2.3522f + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/StubbedContextLib/Migrations/20240219105500_MyMigrations.cs b/src/StubbedContextLib/Migrations/20240219105500_MyMigrations.cs new file mode 100644 index 0000000..1326864 --- /dev/null +++ b/src/StubbedContextLib/Migrations/20240219105500_MyMigrations.cs @@ -0,0 +1,258 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace StubbedContextLib.Migrations +{ + /// + public partial class MyMigrations : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Activity", + columns: table => new + { + IdActivity = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Type = table.Column(type: "TEXT", maxLength: 100, nullable: false), + Date = table.Column(type: "TEXT", nullable: false), + StartTime = table.Column(type: "TEXT", nullable: false), + EndTime = table.Column(type: "TEXT", nullable: false), + EffortFelt = table.Column(type: "INTEGER", nullable: false), + Variability = table.Column(type: "REAL", nullable: false), + Variance = table.Column(type: "REAL", nullable: false), + StandardDeviation = table.Column(type: "REAL", nullable: false), + Average = table.Column(type: "REAL", nullable: false), + Maximum = table.Column(type: "INTEGER", nullable: false), + Minimum = table.Column(type: "INTEGER", nullable: false), + AverageTemperature = table.Column(type: "REAL", nullable: false), + HasAutoPause = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Activity", x => x.IdActivity); + }); + + migrationBuilder.CreateTable( + name: "Athlete", + columns: table => new + { + IdAthlete = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Username = table.Column(type: "TEXT", maxLength: 100, nullable: false), + LastName = table.Column(type: "TEXT", maxLength: 100, nullable: false), + FirstName = table.Column(type: "TEXT", maxLength: 150, nullable: false), + Email = table.Column(type: "TEXT", maxLength: 100, nullable: false), + Sexe = table.Column(type: "TEXT", maxLength: 1, nullable: false), + Lenght = table.Column(type: "REAL", nullable: false), + Weight = table.Column(type: "REAL", nullable: false), + Password = table.Column(type: "TEXT", nullable: false), + DateOfBirth = table.Column(type: "TEXT", nullable: false), + IsCoach = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Athlete", x => x.IdAthlete); + }); + + migrationBuilder.CreateTable( + name: "DataSource", + columns: table => new + { + IdSource = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Type = table.Column(type: "TEXT", maxLength: 100, nullable: false), + Modele = table.Column(type: "TEXT", maxLength: 100, nullable: false), + Precision = table.Column(type: "REAL", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DataSource", x => x.IdSource); + }); + + migrationBuilder.CreateTable( + name: "HeartRate", + columns: table => new + { + IdHeartRate = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Altitude = table.Column(type: "REAL", nullable: false), + Time = table.Column(type: "TEXT", nullable: false), + Temperature = table.Column(type: "REAL", nullable: false), + Bpm = table.Column(type: "INTEGER", nullable: false), + Longitude = table.Column(type: "REAL", nullable: false), + Latitude = table.Column(type: "REAL", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_HeartRate", x => x.IdHeartRate); + }); + + migrationBuilder.CreateTable( + name: "Notification", + columns: table => new + { + IdNotif = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Message = table.Column(type: "TEXT", maxLength: 100, nullable: false), + Date = table.Column(type: "TEXT", nullable: false), + Statut = table.Column(type: "INTEGER", nullable: false), + Urgence = table.Column(type: "TEXT", maxLength: 100, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Notification", x => x.IdNotif); + }); + + migrationBuilder.CreateTable( + name: "Statistic", + columns: table => new + { + IdStatistic = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Weight = table.Column(type: "REAL", nullable: false), + AverageHeartRate = table.Column(type: "REAL", nullable: false), + MaximumHeartRate = table.Column(type: "REAL", nullable: false), + AverageCaloriesBurned = table.Column(type: "REAL", nullable: false), + Date = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Statistic", x => x.IdStatistic); + }); + + migrationBuilder.CreateTable( + name: "Training", + columns: table => new + { + IdTraining = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Date = table.Column(type: "TEXT", nullable: false), + Description = table.Column(type: "TEXT", maxLength: 300, nullable: true), + Latitude = table.Column(type: "REAL", nullable: false), + Longitude = table.Column(type: "REAL", nullable: false), + FeedBack = table.Column(type: "TEXT", maxLength: 300, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Training", x => x.IdTraining); + }); + + migrationBuilder.InsertData( + table: "Activity", + columns: new[] { "IdActivity", "Average", "AverageTemperature", "Date", "EffortFelt", "EndTime", "HasAutoPause", "Maximum", "Minimum", "StandardDeviation", "StartTime", "Type", "Variability", "Variance" }, + values: new object[,] + { + { 1, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Running", 0.5f, 0.5f }, + { 2, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Cycling", 0.5f, 0.5f }, + { 3, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Swimming", 0.5f, 0.5f }, + { 4, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Walking", 0.5f, 0.5f }, + { 5, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Hiking", 0.5f, 0.5f }, + { 6, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Climbing", 0.5f, 0.5f }, + { 7, 0.5f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), false, 0, 0, 0.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Yoga", 0.5f, 0.5f } + }); + + migrationBuilder.InsertData( + table: "Athlete", + columns: new[] { "IdAthlete", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Lenght", "Password", "Sexe", "Username", "Weight" }, + values: new object[,] + { + { 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "john.doe@example.com", "John", true, "Doe", 1.8, "password123", "M", "Doe", 75f }, + { 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "jane.smith@example.com", "Jane", false, "Smith", 1.6499999999999999, "secure456", "F", "Smith", 60f }, + { 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "paul.martin@example.com", "Paul", true, "Martin", 1.75, "super789", "M", "Martin", 68f }, + { 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "anna.brown@example.com", "Anna", false, "Brown", 1.7, "test000", "F", "Brown", 58f }, + { 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "bruce.lee@example.com", "Bruce", false, "Lee", 2.0, "hello321", "M", "Lee", 90f } + }); + + migrationBuilder.InsertData( + table: "DataSource", + columns: new[] { "IdSource", "Modele", "Precision", "Type" }, + values: new object[,] + { + { 1, "Garmin", 0.5f, "Smartwatch" }, + { 2, "Polar", 0.5f, "Smartwatch" }, + { 3, "Suunto", 0.5f, "Smartwatch" }, + { 4, "Fitbit", 0.5f, "Smartwatch" }, + { 5, "Apple Watch", 0.5f, "Smartwatch" } + }); + + migrationBuilder.InsertData( + table: "HeartRate", + columns: new[] { "IdHeartRate", "Altitude", "Bpm", "Latitude", "Longitude", "Temperature", "Time" }, + values: new object[,] + { + { 1, 0.0, 60, 66f, 35f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, + { 2, 10.0, 65, 67f, 35f, 20.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, + { 3, 11.0, 71, 66f, 36f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, + { 4, 12.0, 75, 67f, 36f, 20.5f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, + { 5, 13.0, 80, 66f, 37f, 20f, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) } + }); + + migrationBuilder.InsertData( + table: "Notification", + columns: new[] { "IdNotif", "Date", "Message", "Statut", "Urgence" }, + values: new object[,] + { + { 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new activity to check", true, "A" }, + { 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new athlete to check", false, "3" }, + { 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new heart rate to check", true, "2" }, + { 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new data source to check", false, "1" }, + { 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "You have a new notification to check", true, "3" } + }); + + migrationBuilder.InsertData( + table: "Statistic", + columns: new[] { "IdStatistic", "AverageCaloriesBurned", "AverageHeartRate", "Date", "MaximumHeartRate", "Weight" }, + values: new object[,] + { + { 1, 500.0, 120.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 180.0, 75f }, + { 2, 600.0, 130.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 190.0, 60f }, + { 3, 550.0, 125.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 185.0, 68f }, + { 4, 650.0, 135.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 195.0, 58f }, + { 5, 450.0, 110.0, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 170.0, 90f } + }); + + migrationBuilder.InsertData( + table: "Training", + columns: new[] { "IdTraining", "Date", "Description", "FeedBack", "Latitude", "Longitude" }, + values: new object[,] + { + { 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Running", "Good", 48.8566f, 2.3522f }, + { 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Cycling", null, 48.8566f, 2.3522f }, + { 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), null, "Good", 48.8566f, 2.3522f }, + { 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Running", "Good", 48.8566f, 2.3522f }, + { 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Cycling", null, 48.8566f, 2.3522f } + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Activity"); + + migrationBuilder.DropTable( + name: "Athlete"); + + migrationBuilder.DropTable( + name: "DataSource"); + + migrationBuilder.DropTable( + name: "HeartRate"); + + migrationBuilder.DropTable( + name: "Notification"); + + migrationBuilder.DropTable( + name: "Statistic"); + + migrationBuilder.DropTable( + name: "Training"); + } + } +} diff --git a/src/StubbedContextLib/Migrations/AthleteStubbedContextModelSnapshot.cs b/src/StubbedContextLib/Migrations/AthleteStubbedContextModelSnapshot.cs deleted file mode 100644 index 1556ab4..0000000 --- a/src/StubbedContextLib/Migrations/AthleteStubbedContextModelSnapshot.cs +++ /dev/null @@ -1,144 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using StubbedContextLib; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - [DbContext(typeof(AthleteStubbedContext))] - partial class AthleteStubbedContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.2"); - - modelBuilder.Entity("Entities.AthleteEntity", b => - { - b.Property("IdAthlete") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("DateOfBirth") - .HasColumnType("TEXT"); - - b.Property("Email") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("TEXT"); - - b.Property("IsCoach") - .HasColumnType("INTEGER"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Lenght") - .HasColumnType("REAL"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Sexe") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Weight") - .HasColumnType("REAL"); - - b.HasKey("IdAthlete"); - - b.ToTable("Athlete"); - - b.HasData( - new - { - IdAthlete = 1, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "john.doe@example.com", - FirstName = "John", - IsCoach = true, - LastName = "Doe", - Lenght = 1.8, - Password = "password123", - Sexe = "M", - Username = "Doe", - Weight = 75f - }, - new - { - IdAthlete = 2, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "jane.smith@example.com", - FirstName = "Jane", - IsCoach = false, - LastName = "Smith", - Lenght = 1.6499999999999999, - Password = "secure456", - Sexe = "F", - Username = "Smith", - Weight = 60f - }, - new - { - IdAthlete = 3, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "paul.martin@example.com", - FirstName = "Paul", - IsCoach = true, - LastName = "Martin", - Lenght = 1.75, - Password = "super789", - Sexe = "M", - Username = "Martin", - Weight = 68f - }, - new - { - IdAthlete = 4, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "anna.brown@example.com", - FirstName = "Anna", - IsCoach = false, - LastName = "Brown", - Lenght = 1.7, - Password = "test000", - Sexe = "F", - Username = "Brown", - Weight = 58f - }, - new - { - IdAthlete = 5, - DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Email = "bruce.lee@example.com", - FirstName = "Bruce", - IsCoach = false, - LastName = "Lee", - Lenght = 2.0, - Password = "hello321", - Sexe = "M", - Username = "Lee", - Weight = 90f - }); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs b/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs new file mode 100644 index 0000000..69783d1 --- /dev/null +++ b/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs @@ -0,0 +1,675 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using StubbedContextLib; + +#nullable disable + +namespace StubbedContextLib.Migrations +{ + [DbContext(typeof(TrainingStubbedContext))] + partial class TrainingStubbedContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.2"); + + modelBuilder.Entity("Entities.ActivityEntity", b => + { + b.Property("IdActivity") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Average") + .HasColumnType("REAL"); + + b.Property("AverageTemperature") + .HasColumnType("REAL"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("EffortFelt") + .HasColumnType("INTEGER"); + + b.Property("EndTime") + .HasColumnType("TEXT"); + + b.Property("HasAutoPause") + .HasColumnType("INTEGER"); + + b.Property("Maximum") + .HasColumnType("INTEGER"); + + b.Property("Minimum") + .HasColumnType("INTEGER"); + + b.Property("StandardDeviation") + .HasColumnType("REAL"); + + b.Property("StartTime") + .HasColumnType("TEXT"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Variability") + .HasColumnType("REAL"); + + b.Property("Variance") + .HasColumnType("REAL"); + + b.HasKey("IdActivity"); + + b.ToTable("Activity"); + + b.HasData( + new + { + IdActivity = 1, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Running", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 2, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Cycling", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 3, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Swimming", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 4, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Walking", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 5, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Hiking", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 6, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Climbing", + Variability = 0.5f, + Variance = 0.5f + }, + new + { + IdActivity = 7, + Average = 0.5f, + AverageTemperature = 20f, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + EffortFelt = 5, + EndTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + HasAutoPause = false, + Maximum = 0, + Minimum = 0, + StandardDeviation = 0.5f, + StartTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Type = "Yoga", + Variability = 0.5f, + Variance = 0.5f + }); + }); + + modelBuilder.Entity("Entities.AthleteEntity", b => + { + b.Property("IdAthlete") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DateOfBirth") + .HasColumnType("TEXT"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("IsCoach") + .HasColumnType("INTEGER"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Lenght") + .HasColumnType("REAL"); + + b.Property("Password") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Sexe") + .IsRequired() + .HasMaxLength(1) + .HasColumnType("TEXT"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Weight") + .HasColumnType("REAL"); + + b.HasKey("IdAthlete"); + + b.ToTable("Athlete"); + + b.HasData( + new + { + IdAthlete = 1, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "john.doe@example.com", + FirstName = "John", + IsCoach = true, + LastName = "Doe", + Lenght = 1.8, + Password = "password123", + Sexe = "M", + Username = "Doe", + Weight = 75f + }, + new + { + IdAthlete = 2, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "jane.smith@example.com", + FirstName = "Jane", + IsCoach = false, + LastName = "Smith", + Lenght = 1.6499999999999999, + Password = "secure456", + Sexe = "F", + Username = "Smith", + Weight = 60f + }, + new + { + IdAthlete = 3, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "paul.martin@example.com", + FirstName = "Paul", + IsCoach = true, + LastName = "Martin", + Lenght = 1.75, + Password = "super789", + Sexe = "M", + Username = "Martin", + Weight = 68f + }, + new + { + IdAthlete = 4, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "anna.brown@example.com", + FirstName = "Anna", + IsCoach = false, + LastName = "Brown", + Lenght = 1.7, + Password = "test000", + Sexe = "F", + Username = "Brown", + Weight = 58f + }, + new + { + IdAthlete = 5, + DateOfBirth = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Email = "bruce.lee@example.com", + FirstName = "Bruce", + IsCoach = false, + LastName = "Lee", + Lenght = 2.0, + Password = "hello321", + Sexe = "M", + Username = "Lee", + Weight = 90f + }); + }); + + modelBuilder.Entity("Entities.DataSourceEntity", b => + { + b.Property("IdSource") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Modele") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Precision") + .HasColumnType("REAL"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("IdSource"); + + b.ToTable("DataSource"); + + b.HasData( + new + { + IdSource = 1, + Modele = "Garmin", + Precision = 0.5f, + Type = "Smartwatch" + }, + new + { + IdSource = 2, + Modele = "Polar", + Precision = 0.5f, + Type = "Smartwatch" + }, + new + { + IdSource = 3, + Modele = "Suunto", + Precision = 0.5f, + Type = "Smartwatch" + }, + new + { + IdSource = 4, + Modele = "Fitbit", + Precision = 0.5f, + Type = "Smartwatch" + }, + new + { + IdSource = 5, + Modele = "Apple Watch", + Precision = 0.5f, + Type = "Smartwatch" + }); + }); + + modelBuilder.Entity("Entities.HeartRateEntity", b => + { + b.Property("IdHeartRate") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Altitude") + .HasColumnType("REAL"); + + b.Property("Bpm") + .HasColumnType("INTEGER"); + + b.Property("Latitude") + .HasColumnType("REAL"); + + b.Property("Longitude") + .HasColumnType("REAL"); + + b.Property("Temperature") + .HasColumnType("REAL"); + + b.Property("Time") + .HasColumnType("TEXT"); + + b.HasKey("IdHeartRate"); + + b.ToTable("HeartRate"); + + b.HasData( + new + { + IdHeartRate = 1, + Altitude = 0.0, + Bpm = 60, + Latitude = 66f, + Longitude = 35f, + Temperature = 20f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + IdHeartRate = 2, + Altitude = 10.0, + Bpm = 65, + Latitude = 67f, + Longitude = 35f, + Temperature = 20.5f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + IdHeartRate = 3, + Altitude = 11.0, + Bpm = 71, + Latitude = 66f, + Longitude = 36f, + Temperature = 20f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + IdHeartRate = 4, + Altitude = 12.0, + Bpm = 75, + Latitude = 67f, + Longitude = 36f, + Temperature = 20.5f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }, + new + { + IdHeartRate = 5, + Altitude = 13.0, + Bpm = 80, + Latitude = 66f, + Longitude = 37f, + Temperature = 20f, + Time = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) + }); + }); + + modelBuilder.Entity("Entities.NotificationEntity", b => + { + b.Property("IdNotif") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Statut") + .HasColumnType("INTEGER"); + + b.Property("Urgence") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("IdNotif"); + + b.ToTable("Notification"); + + b.HasData( + new + { + IdNotif = 1, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new activity to check", + Statut = true, + Urgence = "A" + }, + new + { + IdNotif = 2, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new athlete to check", + Statut = false, + Urgence = "3" + }, + new + { + IdNotif = 3, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new heart rate to check", + Statut = true, + Urgence = "2" + }, + new + { + IdNotif = 4, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new data source to check", + Statut = false, + Urgence = "1" + }, + new + { + IdNotif = 5, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Message = "You have a new notification to check", + Statut = true, + Urgence = "3" + }); + }); + + modelBuilder.Entity("Entities.StatisticEntity", b => + { + b.Property("IdStatistic") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AverageCaloriesBurned") + .HasColumnType("REAL"); + + b.Property("AverageHeartRate") + .HasColumnType("REAL"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("MaximumHeartRate") + .HasColumnType("REAL"); + + b.Property("Weight") + .HasColumnType("REAL"); + + b.HasKey("IdStatistic"); + + b.ToTable("Statistic"); + + b.HasData( + new + { + IdStatistic = 1, + AverageCaloriesBurned = 500.0, + AverageHeartRate = 120.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 180.0, + Weight = 75f + }, + new + { + IdStatistic = 2, + AverageCaloriesBurned = 600.0, + AverageHeartRate = 130.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 190.0, + Weight = 60f + }, + new + { + IdStatistic = 3, + AverageCaloriesBurned = 550.0, + AverageHeartRate = 125.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 185.0, + Weight = 68f + }, + new + { + IdStatistic = 4, + AverageCaloriesBurned = 650.0, + AverageHeartRate = 135.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 195.0, + Weight = 58f + }, + new + { + IdStatistic = 5, + AverageCaloriesBurned = 450.0, + AverageHeartRate = 110.0, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + MaximumHeartRate = 170.0, + Weight = 90f + }); + }); + + modelBuilder.Entity("Entities.TrainingEntity", b => + { + b.Property("IdTraining") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Date") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FeedBack") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Latitude") + .HasColumnType("REAL"); + + b.Property("Longitude") + .HasColumnType("REAL"); + + b.HasKey("IdTraining"); + + b.ToTable("Training"); + + b.HasData( + new + { + IdTraining = 1, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Running", + FeedBack = "Good", + Latitude = 48.8566f, + Longitude = 2.3522f + }, + new + { + IdTraining = 2, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Cycling", + Latitude = 48.8566f, + Longitude = 2.3522f + }, + new + { + IdTraining = 3, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + FeedBack = "Good", + Latitude = 48.8566f, + Longitude = 2.3522f + }, + new + { + IdTraining = 4, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Running", + FeedBack = "Good", + Latitude = 48.8566f, + Longitude = 2.3522f + }, + new + { + IdTraining = 5, + Date = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Description = "Cycling", + Latitude = 48.8566f, + Longitude = 2.3522f + }); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/StubbedContextLib/NotificationStubbedContext.cs b/src/StubbedContextLib/NotificationStubbedContext.cs index e2b287a..84e5275 100644 --- a/src/StubbedContextLib/NotificationStubbedContext.cs +++ b/src/StubbedContextLib/NotificationStubbedContext.cs @@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore; namespace StubbedContextLib; -public class NotificationStubbedContext : LibraryContext +public class NotificationStubbedContext : HeartRateStubbedContext { public NotificationStubbedContext() :base() diff --git a/src/StubbedContextLib/StatisticStubbedContext.cs b/src/StubbedContextLib/StatisticStubbedContext.cs index e69de29..cc5cf1e 100644 --- a/src/StubbedContextLib/StatisticStubbedContext.cs +++ b/src/StubbedContextLib/StatisticStubbedContext.cs @@ -0,0 +1,29 @@ +using DbContextLib; +using Entities; +using Microsoft.EntityFrameworkCore; + +namespace StubbedContextLib; + +public class StatisticStubbedContext : NotificationStubbedContext +{ + public StatisticStubbedContext() + :base() + { } + + public StatisticStubbedContext(DbContextOptions options) + :base(options) + { } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity().HasData( + new StatisticEntity { IdStatistic = 1, Weight = 75, AverageHeartRate = 120, MaximumHeartRate = 180, AverageCaloriesBurned = 500, Date = new DateTime(12/12/2021) }, + new StatisticEntity { IdStatistic = 2, Weight = 60, AverageHeartRate = 130, MaximumHeartRate = 190, AverageCaloriesBurned = 600, Date = new DateTime(11/01/2021) }, + new StatisticEntity { IdStatistic = 3, Weight = 68, AverageHeartRate = 125, MaximumHeartRate = 185, AverageCaloriesBurned = 550, Date = new DateTime(30/12/2022) }, + new StatisticEntity { IdStatistic = 4, Weight = 58, AverageHeartRate = 135, MaximumHeartRate = 195, AverageCaloriesBurned = 650, Date = new DateTime(20/02/2023) }, + new StatisticEntity { IdStatistic = 5, Weight = 90, AverageHeartRate = 110, MaximumHeartRate = 170, AverageCaloriesBurned = 450, Date = new DateTime(10/01/2024) } + ); + } +} \ No newline at end of file diff --git a/src/StubbedContextLib/TrainingStubbedContext.cs b/src/StubbedContextLib/TrainingStubbedContext.cs index e69de29..4f8d404 100644 --- a/src/StubbedContextLib/TrainingStubbedContext.cs +++ b/src/StubbedContextLib/TrainingStubbedContext.cs @@ -0,0 +1,29 @@ +using DbContextLib; +using Entities; +using Microsoft.EntityFrameworkCore; + +namespace StubbedContextLib; + +public class TrainingStubbedContext : StatisticStubbedContext +{ + public TrainingStubbedContext() + :base() + { } + + public TrainingStubbedContext(DbContextOptions options) + :base(options) + { } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity().HasData( + new TrainingEntity { IdTraining = 1, Date = new DateTime(19/02/2024), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" }, + new TrainingEntity { IdTraining = 2, Date = new DateTime(20/02/2024), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f }, + new TrainingEntity { IdTraining = 3, Date = new DateTime(21/02/2024), Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" }, + new TrainingEntity { IdTraining = 4, Date = new DateTime(22/02/2024), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" }, + new TrainingEntity { IdTraining = 5, Date = new DateTime(23/02/2024), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f } + ); + } +} \ No newline at end of file diff --git a/src/Tests/ConsoleTestEntities/Program.cs b/src/Tests/ConsoleTestEntities/Program.cs index 80154f8..8b1e196 100644 --- a/src/Tests/ConsoleTestEntities/Program.cs +++ b/src/Tests/ConsoleTestEntities/Program.cs @@ -9,10 +9,22 @@ class Program { try { - using (LibraryContext db = new AthleteStubbedContext()) + using (LibraryContext db = new TrainingStubbedContext()) { AthletesTests(db); + ActivityTests(db); + + DataSourceTests(db); + + HeartRateTests(db); + + NotificationTests(db); + + StatisticTests(db); + + TrainingTests(db); + // // Test d'ajout, de modification et de suppression // AddUpdateDeleteOperations(db); @@ -31,7 +43,7 @@ class Program { Console.WriteLine("Accès à tous les athletes :"); - // Affichage des livres + // Affichage des athletes Console.WriteLine("Athletes :"); Console.WriteLine("---------------------------------"); @@ -143,6 +155,206 @@ class Program Console.WriteLine("---------------------------------\n"); } + static void ActivityTests(LibraryContext db) + { + Console.WriteLine("Accès à toutes les activités :"); + + Console.WriteLine("Activités :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'activité d'id '2' :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet.Where(a => a.IdActivity == 2)) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'activité de type 'Running' :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet.Where(a => a.Type == "Running")) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'activité de date '01/01/2022' :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateTime(01/01/2022))) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'activité de date '01/01/2022' et de type 'Running' :"); + Console.WriteLine("---------------------------------"); + + foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateTime(01/01/2022) && a.Type == "Running")) + { + Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + } + + Console.WriteLine("---------------------------------\n"); + + // Console.WriteLine("Accès à l'activité de date '01/01/2022' et de type 'Running' et de StartTime '12:00:00' :"); + // Console.WriteLine("---------------------------------"); + + // foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateTime(01/01/2022) && a.Type == "Running" && a.StartTime == new DateTime(12,00,00))) + // { + // Console.WriteLine($"\t{activity.IdActivity} - {activity.Type}, {activity.Date}, {activity.StartTime}, {activity.EndTime}, {activity.EffortFelt}, {activity.Variability}, {activity.Variance}, {activity.StandardDeviation}, {activity.Average}, {activity.Maximum}, {activity.Minimum}, {activity.AverageTemperature}, {activity.HasAutoPause}"); + // } + + // Console.WriteLine("---------------------------------\n"); + } + + static void DataSourceTests(LibraryContext db) + { + Console.WriteLine("Accès à toutes les sources de données :"); + + Console.WriteLine("Sources de données :"); + Console.WriteLine("---------------------------------"); + + foreach (var dataSource in db.DataSourcesSet) + { + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la source de données d'id '2' :"); + Console.WriteLine("---------------------------------"); + + foreach (var dataSource in db.DataSourcesSet.Where(d => d.IdSource == 2)) + { + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la source de données de type 'Polar' :"); + Console.WriteLine("---------------------------------"); + + foreach (var dataSource in db.DataSourcesSet.Where(d => d.Type == "Polar")) + { + Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}"); + } + + Console.WriteLine("---------------------------------\n"); + + } + + static void HeartRateTests(LibraryContext db) + { + Console.WriteLine("Accès à toutes les fréquences cardiaques :"); + + Console.WriteLine("Fréquences cardiaques :"); + Console.WriteLine("---------------------------------"); + + foreach (var heartRate in db.HeartRatesSet) + { + Console.WriteLine($"\t{heartRate.IdHeartRate} - {heartRate.Altitude}, {heartRate.Time}, {heartRate.Temperature}, {heartRate.Bpm}, {heartRate.Longitude}, {heartRate.Latitude}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la fréquence cardiaque d'id '2' :"); + Console.WriteLine("---------------------------------"); + + foreach (var heartRate in db.HeartRatesSet.Where(h => h.IdHeartRate == 2)) + { + Console.WriteLine($"\t{heartRate.IdHeartRate} - {heartRate.Altitude}, {heartRate.Time}, {heartRate.Temperature}, {heartRate.Bpm}, {heartRate.Longitude}, {heartRate.Latitude}"); + } + + Console.WriteLine("---------------------------------\n"); + } + + static void NotificationTests(LibraryContext db) + { + Console.WriteLine("Accès à toutes les notifications :"); + + Console.WriteLine("Notifications :"); + Console.WriteLine("---------------------------------"); + + foreach (var notification in db.NotificationsSet) + { + Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la notification d'id '2' :"); + Console.WriteLine("---------------------------------"); + + foreach (var notification in db.NotificationsSet.Where(n => n.IdNotif == 2)) + { + Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}"); + } + + Console.WriteLine("---------------------------------\n"); + } + + static void StatisticTests(LibraryContext db) + { + Console.WriteLine("Accès à toutes les statistiques :"); + + Console.WriteLine("Statistiques :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à la statistique d'id '2' :"); + Console.WriteLine("---------------------------------"); + + foreach (var statistic in db.StatisticsSet.Where(s => s.IdStatistic == 2)) + { + Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}"); + } + + Console.WriteLine("---------------------------------\n"); + } + static void TrainingTests(LibraryContext db) + { + Console.WriteLine("Accès à tout les entrainements :"); + + Console.WriteLine("Entrainements :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + + Console.WriteLine("Accès à l'entrainement d'id '2' :"); + Console.WriteLine("---------------------------------"); + + foreach (var training in db.TrainingsSet.Where(t => t.IdTraining == 2)) + { + Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}"); + } + + Console.WriteLine("---------------------------------\n"); + } + // /// // /// Test d'ajout, de modification et de suppression de livres. // /// diff --git a/src/Tests/ConsoleTestEntities/uca.HeartTrack.db b/src/Tests/ConsoleTestEntities/uca.HeartTrack.db index 1895d72..b4e7a29 100644 Binary files a/src/Tests/ConsoleTestEntities/uca.HeartTrack.db and b/src/Tests/ConsoleTestEntities/uca.HeartTrack.db differ