add DataManager

WORK-EF_WebAPI
David D'ALMEIDA 1 year ago
parent 39de7eb0ae
commit 1e751fe540

4
.gitignore vendored

@ -498,7 +498,8 @@ fabric.properties
.LSOverride
# Icon must end with two \r
Icon
Icon
# Thumbnails
._*
@ -548,3 +549,4 @@ xcuserdata/
*.xcscmblueprint
*.xccheckout
Migration/

@ -1,221 +1,221 @@
//-----------------------------------------------------------------------
// FILENAME: LibraryContext.cs
// PROJECT: DbContextLib
// SOLUTION: FitnessApp
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
namespace DbContextLib
{
/// <summary>
/// Represents the database context for the FitnessApp.
/// </summary>
public class LibraryContext : DbContext
{
/// <summary>
/// Gets or sets the set of athletes.
/// </summary>
public DbSet<AthleteEntity> AthletesSet { get; set; }
/// <summary>
/// Gets or sets the set of activities.
/// </summary>
public DbSet<ActivityEntity> ActivitiesSet { get; set; }
/// <summary>
/// Gets or sets the set of data sources.
/// </summary>
public DbSet<DataSourceEntity> DataSourcesSet { get; set; }
/// <summary>
/// Gets or sets the set of heart rates.
/// </summary>
public DbSet<HeartRateEntity> HeartRatesSet { get; set; }
/// <summary>
/// Gets or sets the set of notifications.
/// </summary>
public DbSet<NotificationEntity> NotificationsSet { get; set; }
/// <summary>
/// Gets or sets the set of statistics.
/// </summary>
public DbSet<StatisticEntity> StatisticsSet { get; set; }
/// <summary>
/// Gets or sets the set of trainings.
/// </summary>
public DbSet<TrainingEntity> TrainingsSet { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="LibraryContext"/> class.
/// </summary>
public LibraryContext() : base() { }
/// <summary>
/// Initializes a new instance of the <see cref="LibraryContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public LibraryContext(DbContextOptions<LibraryContext> options) : base(options) { }
/// <summary>
/// Configures the database options if they are not already configured.
/// </summary>
/// <param name="optionsBuilder">The options builder instance.</param>
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite($"Data Source=uca.HeartTrack.db");
}
}
/// <summary>
/// Configures the model for the library context.
/// </summary>
/// <param name="modelBuilder">The model builder instance.</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ActivityEntity>()
.HasKey(a => a.IdActivity);
//generation mode (at insertion)
modelBuilder.Entity<ActivityEntity>()
.Property(a => a.IdActivity)
.ValueGeneratedOnAdd();
//primary key of HeartRateEntity
modelBuilder.Entity<HeartRateEntity>()
.HasKey(h => h.IdHeartRate);
//generation mode (at insertion)
modelBuilder.Entity<HeartRateEntity>()
.Property(h => h.IdHeartRate)
.ValueGeneratedOnAdd();
//primary key of DataSourceEntity
modelBuilder.Entity<DataSourceEntity>()
.HasKey(d => d.IdSource);
//generation mode (at insertion)
modelBuilder.Entity<DataSourceEntity>()
.Property(d => d.IdSource)
.ValueGeneratedOnAdd();
//primary key of AthleteEntity
modelBuilder.Entity<AthleteEntity>()
.HasKey(at => at.IdAthlete);
//generation mode (at insertion)
modelBuilder.Entity<AthleteEntity>()
.Property(at => at.IdAthlete)
.ValueGeneratedOnAdd();
// add image column type
// modelBuilder.Entity<AthleteEntity>()
// .Property(at => at.ProfilPicture)
// .HasColumnType("image");
//primary key of StatisticEntity
modelBuilder.Entity<StatisticEntity>()
.HasKey(s => s.IdStatistic);
//generation mode (at insertion)
modelBuilder.Entity<StatisticEntity>()
.Property(s => s.IdStatistic)
.ValueGeneratedOnAdd();
//primary key of TrainingEntity
modelBuilder.Entity<TrainingEntity>()
.HasKey(t => t.IdTraining);
//generation mode (at insertion)
modelBuilder.Entity<TrainingEntity>()
.Property(t => t.IdTraining)
.ValueGeneratedOnAdd();
//primary key of NotificationEntity
modelBuilder.Entity<NotificationEntity>()
.HasKey(n => n.IdNotif);
//generation mode (at insertion)
modelBuilder.Entity<NotificationEntity>()
.Property(n => n.IdNotif)
.ValueGeneratedOnAdd();
modelBuilder.Entity<FriendshipEntity>()
.HasKey(f => new { f.FollowingId, f.FollowerId });
modelBuilder.Entity<FriendshipEntity>()
.HasOne(fing => fing.Following)
.WithMany(fings => fings.Followings)
.HasForeignKey(fing => fing.FollowingId);
modelBuilder.Entity<FriendshipEntity>()
.HasOne(fer => fer.Follower)
.WithMany(fers => fers.Followers)
.HasForeignKey(fing => fing.FollowerId);
// !
// ? Plusieurs questions sur les required ou non, différence difficile à comprendre
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.TrainingsCoach)
.WithOne(tc => tc.Coach)
.HasForeignKey(tc => tc.CoachId);
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.TrainingsAthlete)
.WithMany(ta => ta.Athletes);
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.NotificationsReceived)
.WithMany(nr => nr.Receivers);
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.NotificationsSent)
.WithOne(ns => ns.Sender)
.HasForeignKey(ns => ns.SenderId);
// required car on veut toujours savoir le receveur et l'envoyeur de la notification meme admin ou systeme
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.Statistics)
.WithOne(s => s.Athlete)
.HasForeignKey(s => s.AthleteId)
.IsRequired(false);
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.Activities)
.WithOne(a => a.Athlete)
.HasForeignKey(a => a.AthleteId)
.IsRequired(false);
modelBuilder.Entity<ActivityEntity>()
.HasMany(a => a.HeartRates)
.WithOne(h => h.Activity)
.HasForeignKey(h => h.ActivityId)
.IsRequired();
modelBuilder.Entity<DataSourceEntity>()
.HasMany(d => d.Activities)
.WithOne(a => a.DataSource)
.HasForeignKey(a => a.DataSourceId)
.IsRequired();
modelBuilder.Entity<DataSourceEntity>()
.HasMany(ds => ds.Activities)
.WithOne(at => at.DataSource)
.HasForeignKey(at => at.DataSourceId)
.IsRequired(false);
// modelBuilder.Entity<AthleteEntity>()
// .HasMany(fer => fer.Followers)
// .WithMany(fing => fing.Followings)
// .UsingEntity<FriendshipEntity>(
// l => l.HasOne<AthleteEntity>().WithMany().HasForeignKey(fer => fer.FollowerId),
// r => r.HasOne<AthleteEntity>().WithMany().HasForeignKey(fing => fing.FollowingId),
// j => j.Property(f => f.StartDate).HasDefaultValueSql("CURRENT_TIMESTAMP")
// );
}
}
//-----------------------------------------------------------------------
// FILENAME: HeartTrackContextLibraryContext.cs
// PROJECT: DbContextLib
// SOLUTION: FitnessApp
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
namespace DbContextLib
{
/// <summary>
/// Represents the database context for the FitnessApp.
/// </summary>
public class HeartTrackContext : DbContext
{
/// <summary>
/// Gets or sets the set of athletes.
/// </summary>
public DbSet<AthleteEntity> AthletesSet { get; set; }
/// <summary>
/// Gets or sets the set of activities.
/// </summary>
public DbSet<ActivityEntity> ActivitiesSet { get; set; }
/// <summary>
/// Gets or sets the set of data sources.
/// </summary>
public DbSet<DataSourceEntity> DataSourcesSet { get; set; }
/// <summary>
/// Gets or sets the set of heart rates.
/// </summary>
public DbSet<HeartRateEntity> HeartRatesSet { get; set; }
/// <summary>
/// Gets or sets the set of notifications.
/// </summary>
public DbSet<NotificationEntity> NotificationsSet { get; set; }
/// <summary>
/// Gets or sets the set of statistics.
/// </summary>
public DbSet<StatisticEntity> StatisticsSet { get; set; }
/// <summary>
/// Gets or sets the set of trainings.
/// </summary>
public DbSet<TrainingEntity> TrainingsSet { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="HeartTrackContext"/> class.
/// </summary>
public HeartTrackContext() : base() { }
/// <summary>
/// Initializes a new instance of the <see cref="HeartTrackContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public HeartTrackContext(DbContextOptions<HeartTrackContext> options) : base(options) { }
/// <summary>
/// Configures the database options if they are not already configured.
/// </summary>
/// <param name="optionsBuilder">The options builder instance.</param>
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite($"Data Source=uca.HeartTrack.db");
}
}
/// <summary>
/// Configures the model for the library context.
/// </summary>
/// <param name="modelBuilder">The model builder instance.</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ActivityEntity>()
.HasKey(a => a.IdActivity);
//generation mode (at insertion)
modelBuilder.Entity<ActivityEntity>()
.Property(a => a.IdActivity)
.ValueGeneratedOnAdd();
//primary key of HeartRateEntity
modelBuilder.Entity<HeartRateEntity>()
.HasKey(h => h.IdHeartRate);
//generation mode (at insertion)
modelBuilder.Entity<HeartRateEntity>()
.Property(h => h.IdHeartRate)
.ValueGeneratedOnAdd();
//primary key of DataSourceEntity
modelBuilder.Entity<DataSourceEntity>()
.HasKey(d => d.IdSource);
//generation mode (at insertion)
modelBuilder.Entity<DataSourceEntity>()
.Property(d => d.IdSource)
.ValueGeneratedOnAdd();
//primary key of AthleteEntity
modelBuilder.Entity<AthleteEntity>()
.HasKey(at => at.IdAthlete);
//generation mode (at insertion)
modelBuilder.Entity<AthleteEntity>()
.Property(at => at.IdAthlete)
.ValueGeneratedOnAdd();
// add image column type
// modelBuilder.Entity<AthleteEntity>()
// .Property(at => at.ProfilPicture)
// .HasColumnType("image");
//primary key of StatisticEntity
modelBuilder.Entity<StatisticEntity>()
.HasKey(s => s.IdStatistic);
//generation mode (at insertion)
modelBuilder.Entity<StatisticEntity>()
.Property(s => s.IdStatistic)
.ValueGeneratedOnAdd();
//primary key of TrainingEntity
modelBuilder.Entity<TrainingEntity>()
.HasKey(t => t.IdTraining);
//generation mode (at insertion)
modelBuilder.Entity<TrainingEntity>()
.Property(t => t.IdTraining)
.ValueGeneratedOnAdd();
//primary key of NotificationEntity
modelBuilder.Entity<NotificationEntity>()
.HasKey(n => n.IdNotif);
//generation mode (at insertion)
modelBuilder.Entity<NotificationEntity>()
.Property(n => n.IdNotif)
.ValueGeneratedOnAdd();
modelBuilder.Entity<FriendshipEntity>()
.HasKey(f => new { f.FollowingId, f.FollowerId });
modelBuilder.Entity<FriendshipEntity>()
.HasOne(fing => fing.Following)
.WithMany(fings => fings.Followings)
.HasForeignKey(fing => fing.FollowingId);
modelBuilder.Entity<FriendshipEntity>()
.HasOne(fer => fer.Follower)
.WithMany(fers => fers.Followers)
.HasForeignKey(fing => fing.FollowerId);
// !
// ? Plusieurs questions sur les required ou non, différence difficile à comprendre
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.TrainingsCoach)
.WithOne(tc => tc.Coach)
.HasForeignKey(tc => tc.CoachId);
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.TrainingsAthlete)
.WithMany(ta => ta.Athletes);
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.NotificationsReceived)
.WithMany(nr => nr.Receivers);
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.NotificationsSent)
.WithOne(ns => ns.Sender)
.HasForeignKey(ns => ns.SenderId);
// required car on veut toujours savoir le receveur et l'envoyeur de la notification meme admin ou systeme
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.Statistics)
.WithOne(s => s.Athlete)
.HasForeignKey(s => s.AthleteId)
.IsRequired(false);
modelBuilder.Entity<AthleteEntity>()
.HasMany(at => at.Activities)
.WithOne(a => a.Athlete)
.HasForeignKey(a => a.AthleteId)
.IsRequired(false);
modelBuilder.Entity<ActivityEntity>()
.HasMany(a => a.HeartRates)
.WithOne(h => h.Activity)
.HasForeignKey(h => h.ActivityId)
.IsRequired();
modelBuilder.Entity<DataSourceEntity>()
.HasMany(d => d.Activities)
.WithOne(a => a.DataSource)
.HasForeignKey(a => a.DataSourceId)
.IsRequired();
modelBuilder.Entity<DataSourceEntity>()
.HasMany(ds => ds.Activities)
.WithOne(at => at.DataSource)
.HasForeignKey(at => at.DataSourceId)
.IsRequired(false);
// modelBuilder.Entity<AthleteEntity>()
// .HasMany(fer => fer.Followers)
// .WithMany(fing => fing.Followings)
// .UsingEntity<FriendshipEntity>(
// l => l.HasOne<AthleteEntity>().WithMany().HasForeignKey(fer => fer.FollowerId),
// r => r.HasOne<AthleteEntity>().WithMany().HasForeignKey(fing => fing.FollowingId),
// j => j.Property(f => f.StartDate).HasDefaultValueSql("CURRENT_TIMESTAMP")
// );
}
}
}

@ -17,6 +17,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTestRelationships",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestsEntities", "Tests\UnitTestsEntities\UnitTestsEntities.csproj", "{31FA8E5E-D642-4C43-A2B2-02B9832B2CEC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedEF", "SharedEF\SharedEF.csproj", "{55478079-0AA0-47C1-97FF-A048091FD930}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model2Entities", "Model2Entities\Model2Entities.csproj", "{FA329DEF-4756-4A8B-84E9-5A625FF94CBF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -50,6 +54,14 @@ Global
{31FA8E5E-D642-4C43-A2B2-02B9832B2CEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31FA8E5E-D642-4C43-A2B2-02B9832B2CEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31FA8E5E-D642-4C43-A2B2-02B9832B2CEC}.Release|Any CPU.Build.0 = Release|Any CPU
{55478079-0AA0-47C1-97FF-A048091FD930}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55478079-0AA0-47C1-97FF-A048091FD930}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55478079-0AA0-47C1-97FF-A048091FD930}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55478079-0AA0-47C1-97FF-A048091FD930}.Release|Any CPU.Build.0 = Release|Any CPU
{FA329DEF-4756-4A8B-84E9-5A625FF94CBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA329DEF-4756-4A8B-84E9-5A625FF94CBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA329DEF-4756-4A8B-84E9-5A625FF94CBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA329DEF-4756-4A8B-84E9-5A625FF94CBF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{477D2129-A6C9-4FF8-8BE9-5E9E8E5282F8} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18}

@ -0,0 +1,46 @@
using SharedEF;
namespace Model2Entities;
public partial class DbDataManager
{
public class ActivityRepository : IActivityRepository
{
private readonly DbDataManager _dataManager;
public ActivityRepository(DbDataManager dataManager)
{
_dataManager = dataManager;
}
public async Task<IEnumerable<Activity>> GetItems(int index, int count, Enum? orderingProperty = null, bool descending = false)
{
throw new NotImplementedException();
}
public async Task<Activity> GetItemById(int id)
{
throw new NotImplementedException();
}
public async Task<Activity> UpdateItem(int oldItem, Activity newItem)
{
throw new NotImplementedException();
}
public async Task<Activity> AddItem(Activity item)
{
throw new NotImplementedException();
}
public async Task<bool> DeleteItem(Activity item)
{
throw new NotImplementedException();
}
public async Task<int> GetNbItems()
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,28 @@
using DbContextLib;
using SharedEF;
namespace Model2Entities;
public partial class DbDataManager: IDataManager
{
public IActivityRepository ActivityRepo { get; }
public IUserRepository UserRepo { get; }
protected HeartTrackContext DbContext { get; }
public DbDataManager(HeartTrackContext dbContext)
{
DbContext = dbContext;
ActivityRepo = new ActivityRepository(this);
UserRepo = new UserRepository(this);
}
public DbDataManager()
{
DbContext = new HeartTrackContext();
ActivityRepo = new ActivityRepository(this);
UserRepo= new UserRepository(this);
}
}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DbContextLib\DbContextLib.csproj" />
<ProjectReference Include="..\SharedEF\SharedEF.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,46 @@
using SharedEF;
namespace Model2Entities;
public partial class DbDataManager
{
public class UserRepository : IUserRepository
{
private readonly DbDataManager _dataManager;
public UserRepository(DbDataManager dataManager)
{
_dataManager = dataManager;
}
public async Task<IEnumerable<User>> GetItems(int index, int count, Enum? orderingProperty = null, bool descending = false)
{
throw new NotImplementedException();
}
public async Task<User> GetItemById(int id)
{
throw new NotImplementedException();
}
public async Task<User> UpdateItem(int oldItem, User newItem)
{
throw new NotImplementedException();
}
public async Task<User> AddItem(User item)
{
throw new NotImplementedException();
}
public async Task<bool> DeleteItem(User item)
{
throw new NotImplementedException();
}
public async Task<int> GetNbItems()
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,6 @@
namespace SharedEF;
public class Activity
{
}

@ -0,0 +1,6 @@
namespace SharedEF;
public interface IActivityRepository : IGenericRepository<Activity>
{
}

@ -0,0 +1,7 @@
namespace SharedEF;
public interface IDataManager
{
IUserRepository UserRepo { get; }
IActivityRepository ActivityRepo { get; }
}

@ -0,0 +1,12 @@
namespace SharedEF;
public interface IGenericRepository<T>
{
Task<IEnumerable<T>> GetItems(int index, int count, Enum? orderingProperty = null, bool descending = false);
Task<T> GetItemById(int id);
Task<T> UpdateItem(int oldItem, T newItem);
Task<T> AddItem(T item);
Task<bool> DeleteItem(T item);
Task<int> GetNbItems();
}

@ -0,0 +1,6 @@
namespace SharedEF;
public interface IUserRepository: IGenericRepository<User>
{
}

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

@ -0,0 +1,6 @@
namespace SharedEF;
public class User
{
}

@ -15,7 +15,7 @@ namespace StubbedContextLib
/// <summary>
/// Represents a stubbed context for activities.
/// </summary>
public class ActivityStubbedContext : LibraryContext
public class ActivityStubbedContext : HeartTrackContext
{
/// <summary>
/// Initializes a new instance of the <see cref="ActivityStubbedContext"/> class.
@ -26,7 +26,7 @@ namespace StubbedContextLib
/// Initializes a new instance of the <see cref="ActivityStubbedContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public ActivityStubbedContext(DbContextOptions<LibraryContext> options) : base(options) { }
public ActivityStubbedContext(DbContextOptions<HeartTrackContext> options) : base(options) { }
/// <summary>
/// Configures the model for the activity context.

@ -26,7 +26,7 @@ namespace StubbedContextLib
/// Initializes a new instance of the <see cref="AthleteStubbedContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public AthleteStubbedContext(DbContextOptions<LibraryContext> options) : base(options) { }
public AthleteStubbedContext(DbContextOptions<HeartTrackContext> options) : base(options) { }
/// <summary>
/// Configures the model for the athlete stubbed context.
@ -35,13 +35,14 @@ namespace StubbedContextLib
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
var picture = System.Text.Encoding.UTF8.GetBytes(
"\"UklGRtwDAABXRUJQVlA4INADAAAwEACdASoqACoAAMASJZgCdMoSCz655ndU4XXAP2yXIge5neM/Qd6WCfO8evoj2S0A/p7+f0An85cBxlLDgPC8jO/0nsl/13/O8vvzj7Af8s/p3/H4FU6td4MCwq23z1H2uzoKIXaqJniPI/bRMf8qzv0Zp+HE1RCBw5WQ1j/JovdM1FS52+QcaAAA/v/+NxU4DpPk3+xQPW7tcmURSo9vC4qc+XMxNVBzEM5E8actDz98gmwTXgD62e9EmG/ervdd2ovFFSuxYppWl/wtaX3rkn0xrt8qOql/5I2jfLOnCU0kALLcW4F/wTjU10qsxZXW9fxauC6OPVRF28sc94V9ocmoSWy+sf6jW3vYkVOh+gE/RE0L6b2d3oFyHmkRJnfYwG8o3p6fv9pivNF5aopIBzFnjzwb/VqSq3/b+MWKFmjr8T1qe4/fITo2vBWEqDyogV3ZVGnDVi2DbiEFVSUr2eXTNZQ9V/D9QC/+vCR5TGyX9QOVBgtAYtm/ZTIwzPEYB9NrV1NeO1/sAz78u0tW59r0I+SO5Jgm3B9i1toRurzHv9EZJ9yZL8nafb/T1FaoPDkuJfM+iPs0j8xnS7TaU/gEK0wCxeDYRYtJx9j4hUQq7pAu/T2yWy0vjcUHki952ZNbXnXxB8m8pV5x9E1sfLj5MZEgpU2XV8RHrVvWniCjsf6vgxmR7+KtwIbMjahitUGtHet1WdL+8MmdL29iQJC37pDXirir1NibxKKhFYRuJ3xW9O0r9+Vnh8diqbBuXqDbYR/MSoHvscOCm2t95dN5WBdRUoD7YCG/ZHWc7Ypv/x/al4fkB2lZlYhVWHxjaoeF9jEPI0gAN5XsvUI6hbzEzWMsNW/1orkNOnlskalgmpI4B2rm4Gc7LNui+MuMBrpnBvLkbYX9exe9g8tu7wLt7ScOjDcL99oOyR89Mh9L8rd4+43+JQyR6tsIfcPJo6T6FxHf11d/MGayJi+SWct/uhvvua0oOh+zXNIaUzgoBmu1XULjkpuA0Ghzctf30jbY1AOM49qbMZRYS9A+0S1HrHPnwRvpQY/Sj4xKPn0gdpv/+iTbKJb8zkPC4/9af0Jvesa+GDG0/iw3TswenMhqlh7BM9MW5txpeblsByx4WnJ/oHv6cc0dmM7tsV36lYkCTUXEf/0eKlnfivnN0g1g+j/Lk9et/uoa6TFCW0HgwFOIVFumEYdT675PfuTrYO5o8ZrWEIHtv2Ctlrv9J3TrslD/iKEwtipGHtn0Vak8B9wLL+kz+CIQ/VG4KJpXjx88CeCC4XaGitEdjAAA\"");
modelBuilder.Entity<AthleteEntity>().HasData(
new AthleteEntity { IdAthlete = 1, Username = "Doe", LastName = "Doe", FirstName = "John", Email = "john.doe@example.com", Password = "password123", Sexe = "M", Length = 1.80, Weight = 75, DateOfBirth = new DateOnly(1990, 01, 01), IsCoach = true },
new AthleteEntity { IdAthlete = 2, Username = "Smith", LastName = "Smith", FirstName = "Jane", Email = "jane.smith@exemple.com", Password = "secure456", Sexe = "F", Length = 1.65, Weight = 60, DateOfBirth = new DateOnly(1995, 01, 01), IsCoach = false, DataSourceId = 1 },
new AthleteEntity { IdAthlete = 3, Username = "Martin", LastName = "Martin", FirstName = "Paul", Email = "paul.martin@example.com", Password = "super789", Sexe = "M", Length = 1.75, Weight = 68, DateOfBirth = new DateOnly(1992, 01, 01), IsCoach = true },
new AthleteEntity { IdAthlete = 4, Username = "Brown", LastName = "Brown", FirstName = "Anna", Email = "anna.brown@example.com", Password = "test000", Sexe = "F", Length = 1.70, Weight = 58, DateOfBirth = new DateOnly(1993, 01, 01), IsCoach = false },
new AthleteEntity { IdAthlete = 5, Username = "Lee", LastName = "Lee", FirstName = "Bruce", Email = "bruce.lee@example.com", Password = "hello321", Sexe = "M", Length = 2.0, Weight = 90, DateOfBirth = new DateOnly(1991, 01, 01), IsCoach = false, DataSourceId = 3 }
new AthleteEntity { IdAthlete = 1, Username = "Doe",ProfilPicture = picture, LastName = "Doe", FirstName = "John", Email = "john.doe@example.com", Password = "password123", Sexe = "M", Length = 1.80, Weight = 75, DateOfBirth = new DateOnly(1990, 01, 01), IsCoach = true },
new AthleteEntity { IdAthlete = 2, Username = "Smith",ProfilPicture = picture, LastName = "Smith", FirstName = "Jane", Email = "jane.smith@exemple.com", Password = "secure456", Sexe = "F", Length = 1.65, Weight = 60, DateOfBirth = new DateOnly(1995, 01, 01), IsCoach = false, DataSourceId = 1 },
new AthleteEntity { IdAthlete = 3, Username = "Martin",ProfilPicture = picture, LastName = "Martin", FirstName = "Paul", Email = "paul.martin@example.com", Password = "super789", Sexe = "M", Length = 1.75, Weight = 68, DateOfBirth = new DateOnly(1992, 01, 01), IsCoach = true },
new AthleteEntity { IdAthlete = 4, Username = "Brown",ProfilPicture = picture, LastName = "Brown", FirstName = "Anna", Email = "anna.brown@example.com", Password = "test000", Sexe = "F", Length = 1.70, Weight = 58, DateOfBirth = new DateOnly(1993, 01, 01), IsCoach = false },
new AthleteEntity { IdAthlete = 5, Username = "Lee", ProfilPicture = picture,LastName = "Lee", FirstName = "Bruce", Email = "bruce.lee@example.com", Password = "hello321", Sexe = "M", Length = 2.0, Weight = 90, DateOfBirth = new DateOnly(1991, 01, 01), IsCoach = false, DataSourceId = 3 }
);
}
}

@ -26,7 +26,7 @@ namespace StubbedContextLib
/// Initializes a new instance of the <see cref="DataSourceStubbedContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public DataSourceStubbedContext(DbContextOptions<LibraryContext> options) : base(options) { }
public DataSourceStubbedContext(DbContextOptions<HeartTrackContext> options) : base(options) { }
/// <summary>
/// Configures the model for the data source stubbed context.

@ -26,7 +26,7 @@ namespace StubbedContextLib
/// Initializes a new instance of the <see cref="FriendshipStubbedContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public FriendshipStubbedContext(DbContextOptions<LibraryContext> options) : base(options) { }
public FriendshipStubbedContext(DbContextOptions<HeartTrackContext> options) : base(options) { }
/// <summary>
/// Configures the model for the heart rate stubbed context.

@ -26,7 +26,7 @@ namespace StubbedContextLib
/// Initializes a new instance of the <see cref="HeartRateStubbedContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public HeartRateStubbedContext(DbContextOptions<LibraryContext> options) : base(options) { }
public HeartRateStubbedContext(DbContextOptions<HeartTrackContext> options) : base(options) { }
/// <summary>
/// Configures the model for the heart rate stubbed context.

@ -1,977 +0,0 @@
// <auto-generated />
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("20240307081406_MyMigrations")]
partial class MyMigrations
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder.Entity("AthleteEntityNotificationEntity", b =>
{
b.Property<int>("NotificationsReceivedIdNotif")
.HasColumnType("INTEGER");
b.Property<int>("ReceiversIdAthlete")
.HasColumnType("INTEGER");
b.HasKey("NotificationsReceivedIdNotif", "ReceiversIdAthlete");
b.HasIndex("ReceiversIdAthlete");
b.ToTable("AthleteEntityNotificationEntity");
});
modelBuilder.Entity("AthleteEntityTrainingEntity", b =>
{
b.Property<int>("AthletesIdAthlete")
.HasColumnType("INTEGER");
b.Property<int>("TrainingsAthleteIdTraining")
.HasColumnType("INTEGER");
b.HasKey("AthletesIdAthlete", "TrainingsAthleteIdTraining");
b.HasIndex("TrainingsAthleteIdTraining");
b.ToTable("AthleteEntityTrainingEntity");
});
modelBuilder.Entity("Entities.ActivityEntity", b =>
{
b.Property<int>("IdActivity")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AthleteId")
.HasColumnType("INTEGER");
b.Property<float>("Average")
.HasColumnType("REAL");
b.Property<float>("AverageTemperature")
.HasColumnType("REAL");
b.Property<int>("DataSourceId")
.HasColumnType("INTEGER");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<int>("EffortFelt")
.HasColumnType("INTEGER");
b.Property<TimeOnly>("EndTime")
.HasColumnType("TEXT");
b.Property<bool>("HasAutoPause")
.HasColumnType("INTEGER");
b.Property<int>("Maximum")
.HasColumnType("INTEGER");
b.Property<int>("Minimum")
.HasColumnType("INTEGER");
b.Property<float>("StandardDeviation")
.HasColumnType("REAL");
b.Property<TimeOnly>("StartTime")
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Variability")
.HasColumnType("REAL");
b.Property<float>("Variance")
.HasColumnType("REAL");
b.HasKey("IdActivity");
b.HasIndex("AthleteId");
b.HasIndex("DataSourceId");
b.ToTable("Activity");
b.HasData(
new
{
IdActivity = 1,
AthleteId = 1,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 1,
Date = new DateOnly(2023, 1, 10),
EffortFelt = 5,
EndTime = new TimeOnly(14, 0, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(13, 0, 34),
Type = "Running",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 2,
AthleteId = 2,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 2,
Date = new DateOnly(2023, 1, 25),
EffortFelt = 5,
EndTime = new TimeOnly(14, 0, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(13, 4, 34),
Type = "Cycling",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 3,
AthleteId = 1,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 1,
Date = new DateOnly(2023, 12, 10),
EffortFelt = 5,
EndTime = new TimeOnly(15, 2, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(13, 30, 34),
Type = "Swimming",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 4,
AthleteId = 5,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 3,
Date = new DateOnly(2024, 1, 2),
EffortFelt = 5,
EndTime = new TimeOnly(16, 1, 55),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(15, 0, 0),
Type = "Walking",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 5,
AthleteId = 4,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 4,
Date = new DateOnly(2024, 1, 12),
EffortFelt = 5,
EndTime = new TimeOnly(9, 0, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(7, 45, 34),
Type = "Hiking",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 6,
AthleteId = 4,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 4,
Date = new DateOnly(2024, 1, 27),
EffortFelt = 5,
EndTime = new TimeOnly(14, 0, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(13, 30, 1),
Type = "Climbing",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 7,
AthleteId = 3,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 5,
Date = new DateOnly(2024, 2, 22),
EffortFelt = 5,
EndTime = new TimeOnly(23, 50, 58),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(22, 0, 34),
Type = "Yoga",
Variability = 0.5f,
Variance = 0.5f
});
});
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.Property<int>("IdAthlete")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("DataSourceId")
.HasColumnType("INTEGER");
b.Property<DateOnly>("DateOfBirth")
.HasColumnType("TEXT");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("TEXT");
b.Property<bool>("IsCoach")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double>("Length")
.HasColumnType("REAL");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Sexe")
.IsRequired()
.HasMaxLength(1)
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdAthlete");
b.HasIndex("DataSourceId");
b.ToTable("Athlete");
b.HasData(
new
{
IdAthlete = 1,
DateOfBirth = new DateOnly(1990, 1, 1),
Email = "john.doe@example.com",
FirstName = "John",
IsCoach = true,
LastName = "Doe",
Length = 1.8,
Password = "password123",
Sexe = "M",
Username = "Doe",
Weight = 75f
},
new
{
IdAthlete = 2,
DataSourceId = 1,
DateOfBirth = new DateOnly(1995, 1, 1),
Email = "jane.smith@exemple.com",
FirstName = "Jane",
IsCoach = false,
LastName = "Smith",
Length = 1.6499999999999999,
Password = "secure456",
Sexe = "F",
Username = "Smith",
Weight = 60f
},
new
{
IdAthlete = 3,
DateOfBirth = new DateOnly(1992, 1, 1),
Email = "paul.martin@example.com",
FirstName = "Paul",
IsCoach = true,
LastName = "Martin",
Length = 1.75,
Password = "super789",
Sexe = "M",
Username = "Martin",
Weight = 68f
},
new
{
IdAthlete = 4,
DateOfBirth = new DateOnly(1993, 1, 1),
Email = "anna.brown@example.com",
FirstName = "Anna",
IsCoach = false,
LastName = "Brown",
Length = 1.7,
Password = "test000",
Sexe = "F",
Username = "Brown",
Weight = 58f
},
new
{
IdAthlete = 5,
DataSourceId = 3,
DateOfBirth = new DateOnly(1991, 1, 1),
Email = "bruce.lee@example.com",
FirstName = "Bruce",
IsCoach = false,
LastName = "Lee",
Length = 2.0,
Password = "hello321",
Sexe = "M",
Username = "Lee",
Weight = 90f
});
});
modelBuilder.Entity("Entities.DataSourceEntity", b =>
{
b.Property<int>("IdSource")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Model")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Precision")
.HasColumnType("REAL");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("IdSource");
b.ToTable("DataSource");
b.HasData(
new
{
IdSource = 1,
Model = "Garmin",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 2,
Model = "Polar",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 3,
Model = "Suunto",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 4,
Model = "Fitbit",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 5,
Model = "Apple Watch",
Precision = 0.5f,
Type = "Smartwatch"
});
});
modelBuilder.Entity("Entities.FriendshipEntity", b =>
{
b.Property<int>("FollowingId")
.HasColumnType("INTEGER");
b.Property<int>("FollowerId")
.HasColumnType("INTEGER");
b.Property<DateTime>("StartDate")
.HasColumnType("TEXT");
b.HasKey("FollowingId", "FollowerId");
b.HasIndex("FollowerId");
b.ToTable("FriendshipEntity");
b.HasData(
new
{
FollowingId = 2,
FollowerId = 1,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 3,
FollowerId = 1,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 4,
FollowerId = 1,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 5,
FollowerId = 1,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 1,
FollowerId = 2,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 3,
FollowerId = 2,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
});
});
modelBuilder.Entity("Entities.HeartRateEntity", b =>
{
b.Property<int>("IdHeartRate")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ActivityId")
.HasColumnType("INTEGER");
b.Property<double>("Altitude")
.HasColumnType("REAL");
b.Property<int>("Bpm")
.HasColumnType("INTEGER");
b.Property<float>("Latitude")
.HasColumnType("REAL");
b.Property<float>("Longitude")
.HasColumnType("REAL");
b.Property<float>("Temperature")
.HasColumnType("REAL");
b.Property<TimeOnly>("Time")
.HasColumnType("TEXT");
b.HasKey("IdHeartRate");
b.HasIndex("ActivityId");
b.ToTable("HeartRate");
b.HasData(
new
{
IdHeartRate = 1,
ActivityId = 1,
Altitude = 0.0,
Bpm = 60,
Latitude = 66f,
Longitude = 35f,
Temperature = 20f,
Time = new TimeOnly(13, 0, 30)
},
new
{
IdHeartRate = 2,
ActivityId = 2,
Altitude = 10.0,
Bpm = 65,
Latitude = 67f,
Longitude = 35f,
Temperature = 20.5f,
Time = new TimeOnly(13, 0, 31)
},
new
{
IdHeartRate = 3,
ActivityId = 1,
Altitude = 11.0,
Bpm = 71,
Latitude = 66f,
Longitude = 36f,
Temperature = 20f,
Time = new TimeOnly(13, 0, 32)
},
new
{
IdHeartRate = 4,
ActivityId = 2,
Altitude = 12.0,
Bpm = 75,
Latitude = 67f,
Longitude = 36f,
Temperature = 20.5f,
Time = new TimeOnly(13, 0, 33)
},
new
{
IdHeartRate = 5,
ActivityId = 4,
Altitude = 13.0,
Bpm = 80,
Latitude = 66f,
Longitude = 37f,
Temperature = 20f,
Time = new TimeOnly(13, 0, 34)
});
});
modelBuilder.Entity("Entities.NotificationEntity", b =>
{
b.Property<int>("IdNotif")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<string>("Message")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<int>("SenderId")
.HasColumnType("INTEGER");
b.Property<bool>("Statut")
.HasColumnType("INTEGER");
b.Property<string>("Urgence")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("IdNotif");
b.HasIndex("SenderId");
b.ToTable("Notification");
b.HasData(
new
{
IdNotif = 1,
Date = new DateTime(2023, 12, 25, 13, 0, 40, 0, DateTimeKind.Unspecified),
Message = "You have a new activity to check",
SenderId = 1,
Statut = true,
Urgence = "A"
},
new
{
IdNotif = 2,
Date = new DateTime(2023, 12, 26, 13, 10, 40, 0, DateTimeKind.Unspecified),
Message = "You have a new athlete to check",
SenderId = 2,
Statut = false,
Urgence = "3"
},
new
{
IdNotif = 3,
Date = new DateTime(2023, 12, 26, 16, 10, 4, 0, DateTimeKind.Unspecified),
Message = "You have a new heart rate to check",
SenderId = 3,
Statut = true,
Urgence = "2"
},
new
{
IdNotif = 4,
Date = new DateTime(2024, 1, 12, 9, 30, 50, 0, DateTimeKind.Unspecified),
Message = "You have a new data source to check",
SenderId = 4,
Statut = false,
Urgence = "1"
},
new
{
IdNotif = 5,
Date = new DateTime(2024, 2, 22, 12, 10, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new notification to check",
SenderId = 5,
Statut = true,
Urgence = "3"
});
});
modelBuilder.Entity("Entities.StatisticEntity", b =>
{
b.Property<int>("IdStatistic")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AthleteId")
.HasColumnType("INTEGER");
b.Property<double>("AverageCaloriesBurned")
.HasColumnType("REAL");
b.Property<double>("AverageHeartRate")
.HasColumnType("REAL");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<double>("MaximumHeartRate")
.HasColumnType("REAL");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdStatistic");
b.HasIndex("AthleteId");
b.ToTable("Statistic");
b.HasData(
new
{
IdStatistic = 1,
AthleteId = 1,
AverageCaloriesBurned = 500.0,
AverageHeartRate = 120.0,
Date = new DateOnly(2021, 12, 12),
MaximumHeartRate = 180.0,
Weight = 75f
},
new
{
IdStatistic = 2,
AthleteId = 2,
AverageCaloriesBurned = 600.0,
AverageHeartRate = 130.0,
Date = new DateOnly(2021, 1, 11),
MaximumHeartRate = 190.0,
Weight = 60f
},
new
{
IdStatistic = 3,
AthleteId = 1,
AverageCaloriesBurned = 550.0,
AverageHeartRate = 125.0,
Date = new DateOnly(2022, 12, 30),
MaximumHeartRate = 185.0,
Weight = 68f
},
new
{
IdStatistic = 4,
AthleteId = 3,
AverageCaloriesBurned = 650.0,
AverageHeartRate = 135.0,
Date = new DateOnly(2023, 2, 20),
MaximumHeartRate = 195.0,
Weight = 58f
},
new
{
IdStatistic = 5,
AthleteId = 4,
AverageCaloriesBurned = 450.0,
AverageHeartRate = 110.0,
Date = new DateOnly(2024, 1, 10),
MaximumHeartRate = 170.0,
Weight = 90f
});
});
modelBuilder.Entity("Entities.TrainingEntity", b =>
{
b.Property<int>("IdTraining")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("CoachId")
.HasColumnType("INTEGER");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("FeedBack")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<float>("Latitude")
.HasColumnType("REAL");
b.Property<float>("Longitude")
.HasColumnType("REAL");
b.HasKey("IdTraining");
b.HasIndex("CoachId");
b.ToTable("Training");
b.HasData(
new
{
IdTraining = 1,
CoachId = 1,
Date = new DateOnly(2024, 1, 19),
Description = "Running",
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 2,
CoachId = 5,
Date = new DateOnly(2024, 2, 20),
Description = "Cycling",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 3,
CoachId = 4,
Date = new DateOnly(2024, 2, 21),
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 4,
CoachId = 3,
Date = new DateOnly(2024, 2, 22),
Description = "Running",
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 5,
CoachId = 1,
Date = new DateOnly(2024, 2, 23),
Description = "Cycling",
Latitude = 48.8566f,
Longitude = 2.3522f
});
});
modelBuilder.Entity("AthleteEntityNotificationEntity", b =>
{
b.HasOne("Entities.NotificationEntity", null)
.WithMany()
.HasForeignKey("NotificationsReceivedIdNotif")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.AthleteEntity", null)
.WithMany()
.HasForeignKey("ReceiversIdAthlete")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("AthleteEntityTrainingEntity", b =>
{
b.HasOne("Entities.AthleteEntity", null)
.WithMany()
.HasForeignKey("AthletesIdAthlete")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.TrainingEntity", null)
.WithMany()
.HasForeignKey("TrainingsAthleteIdTraining")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Entities.ActivityEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Athlete")
.WithMany("Activities")
.HasForeignKey("AthleteId");
b.HasOne("Entities.DataSourceEntity", "DataSource")
.WithMany("Activities")
.HasForeignKey("DataSourceId");
b.Navigation("Athlete");
b.Navigation("DataSource");
});
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.HasOne("Entities.DataSourceEntity", "DataSource")
.WithMany("Athletes")
.HasForeignKey("DataSourceId");
b.Navigation("DataSource");
});
modelBuilder.Entity("Entities.FriendshipEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Follower")
.WithMany("Followers")
.HasForeignKey("FollowerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.AthleteEntity", "Following")
.WithMany("Followings")
.HasForeignKey("FollowingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Follower");
b.Navigation("Following");
});
modelBuilder.Entity("Entities.HeartRateEntity", b =>
{
b.HasOne("Entities.ActivityEntity", "Activity")
.WithMany("HeartRates")
.HasForeignKey("ActivityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Activity");
});
modelBuilder.Entity("Entities.NotificationEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Sender")
.WithMany("NotificationsSent")
.HasForeignKey("SenderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Sender");
});
modelBuilder.Entity("Entities.StatisticEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Athlete")
.WithMany("Statistics")
.HasForeignKey("AthleteId");
b.Navigation("Athlete");
});
modelBuilder.Entity("Entities.TrainingEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Coach")
.WithMany("TrainingsCoach")
.HasForeignKey("CoachId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Coach");
});
modelBuilder.Entity("Entities.ActivityEntity", b =>
{
b.Navigation("HeartRates");
});
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.Navigation("Activities");
b.Navigation("Followers");
b.Navigation("Followings");
b.Navigation("NotificationsSent");
b.Navigation("Statistics");
b.Navigation("TrainingsCoach");
});
modelBuilder.Entity("Entities.DataSourceEntity", b =>
{
b.Navigation("Activities");
b.Navigation("Athletes");
});
#pragma warning restore 612, 618
}
}
}

@ -1,491 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace StubbedContextLib.Migrations
{
/// <inheritdoc />
public partial class MyMigrations : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "DataSource",
columns: table => new
{
IdSource = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Model = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Precision = table.Column<float>(type: "REAL", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DataSource", x => x.IdSource);
});
migrationBuilder.CreateTable(
name: "Athlete",
columns: table => new
{
IdAthlete = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Username = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
LastName = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
FirstName = table.Column<string>(type: "TEXT", maxLength: 150, nullable: false),
Email = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Sexe = table.Column<string>(type: "TEXT", maxLength: 1, nullable: false),
Length = table.Column<double>(type: "REAL", nullable: false),
Weight = table.Column<float>(type: "REAL", nullable: false),
Password = table.Column<string>(type: "TEXT", nullable: false),
DateOfBirth = table.Column<DateOnly>(type: "TEXT", nullable: false),
IsCoach = table.Column<bool>(type: "INTEGER", nullable: false),
DataSourceId = table.Column<int>(type: "INTEGER", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Athlete", x => x.IdAthlete);
table.ForeignKey(
name: "FK_Athlete_DataSource_DataSourceId",
column: x => x.DataSourceId,
principalTable: "DataSource",
principalColumn: "IdSource");
});
migrationBuilder.CreateTable(
name: "Activity",
columns: table => new
{
IdActivity = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Date = table.Column<DateOnly>(type: "TEXT", nullable: false),
StartTime = table.Column<TimeOnly>(type: "TEXT", nullable: false),
EndTime = table.Column<TimeOnly>(type: "TEXT", nullable: false),
EffortFelt = table.Column<int>(type: "INTEGER", nullable: false),
Variability = table.Column<float>(type: "REAL", nullable: false),
Variance = table.Column<float>(type: "REAL", nullable: false),
StandardDeviation = table.Column<float>(type: "REAL", nullable: false),
Average = table.Column<float>(type: "REAL", nullable: false),
Maximum = table.Column<int>(type: "INTEGER", nullable: false),
Minimum = table.Column<int>(type: "INTEGER", nullable: false),
AverageTemperature = table.Column<float>(type: "REAL", nullable: false),
HasAutoPause = table.Column<bool>(type: "INTEGER", nullable: false),
DataSourceId = table.Column<int>(type: "INTEGER", nullable: false),
AthleteId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Activity", x => x.IdActivity);
table.ForeignKey(
name: "FK_Activity_Athlete_AthleteId",
column: x => x.AthleteId,
principalTable: "Athlete",
principalColumn: "IdAthlete");
table.ForeignKey(
name: "FK_Activity_DataSource_DataSourceId",
column: x => x.DataSourceId,
principalTable: "DataSource",
principalColumn: "IdSource");
});
migrationBuilder.CreateTable(
name: "FriendshipEntity",
columns: table => new
{
FollowingId = table.Column<int>(type: "INTEGER", nullable: false),
FollowerId = table.Column<int>(type: "INTEGER", nullable: false),
StartDate = table.Column<DateTime>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_FriendshipEntity", x => new { x.FollowingId, x.FollowerId });
table.ForeignKey(
name: "FK_FriendshipEntity_Athlete_FollowerId",
column: x => x.FollowerId,
principalTable: "Athlete",
principalColumn: "IdAthlete",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_FriendshipEntity_Athlete_FollowingId",
column: x => x.FollowingId,
principalTable: "Athlete",
principalColumn: "IdAthlete",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Notification",
columns: table => new
{
IdNotif = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Message = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Date = table.Column<DateTime>(type: "TEXT", nullable: false),
Statut = table.Column<bool>(type: "INTEGER", nullable: false),
Urgence = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
SenderId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Notification", x => x.IdNotif);
table.ForeignKey(
name: "FK_Notification_Athlete_SenderId",
column: x => x.SenderId,
principalTable: "Athlete",
principalColumn: "IdAthlete",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Statistic",
columns: table => new
{
IdStatistic = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Weight = table.Column<float>(type: "REAL", nullable: false),
AverageHeartRate = table.Column<double>(type: "REAL", nullable: false),
MaximumHeartRate = table.Column<double>(type: "REAL", nullable: false),
AverageCaloriesBurned = table.Column<double>(type: "REAL", nullable: false),
Date = table.Column<DateOnly>(type: "TEXT", nullable: false),
AthleteId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Statistic", x => x.IdStatistic);
table.ForeignKey(
name: "FK_Statistic_Athlete_AthleteId",
column: x => x.AthleteId,
principalTable: "Athlete",
principalColumn: "IdAthlete");
});
migrationBuilder.CreateTable(
name: "Training",
columns: table => new
{
IdTraining = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Date = table.Column<DateOnly>(type: "TEXT", nullable: false),
Description = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
Latitude = table.Column<float>(type: "REAL", nullable: false),
Longitude = table.Column<float>(type: "REAL", nullable: false),
FeedBack = table.Column<string>(type: "TEXT", maxLength: 300, nullable: true),
CoachId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Training", x => x.IdTraining);
table.ForeignKey(
name: "FK_Training_Athlete_CoachId",
column: x => x.CoachId,
principalTable: "Athlete",
principalColumn: "IdAthlete",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "HeartRate",
columns: table => new
{
IdHeartRate = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Altitude = table.Column<double>(type: "REAL", nullable: false),
Time = table.Column<TimeOnly>(type: "TEXT", nullable: false),
Temperature = table.Column<float>(type: "REAL", nullable: false),
Bpm = table.Column<int>(type: "INTEGER", nullable: false),
Longitude = table.Column<float>(type: "REAL", nullable: false),
Latitude = table.Column<float>(type: "REAL", nullable: false),
ActivityId = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_HeartRate", x => x.IdHeartRate);
table.ForeignKey(
name: "FK_HeartRate_Activity_ActivityId",
column: x => x.ActivityId,
principalTable: "Activity",
principalColumn: "IdActivity",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AthleteEntityNotificationEntity",
columns: table => new
{
NotificationsReceivedIdNotif = table.Column<int>(type: "INTEGER", nullable: false),
ReceiversIdAthlete = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AthleteEntityNotificationEntity", x => new { x.NotificationsReceivedIdNotif, x.ReceiversIdAthlete });
table.ForeignKey(
name: "FK_AthleteEntityNotificationEntity_Athlete_ReceiversIdAthlete",
column: x => x.ReceiversIdAthlete,
principalTable: "Athlete",
principalColumn: "IdAthlete",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AthleteEntityNotificationEntity_Notification_NotificationsReceivedIdNotif",
column: x => x.NotificationsReceivedIdNotif,
principalTable: "Notification",
principalColumn: "IdNotif",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AthleteEntityTrainingEntity",
columns: table => new
{
AthletesIdAthlete = table.Column<int>(type: "INTEGER", nullable: false),
TrainingsAthleteIdTraining = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AthleteEntityTrainingEntity", x => new { x.AthletesIdAthlete, x.TrainingsAthleteIdTraining });
table.ForeignKey(
name: "FK_AthleteEntityTrainingEntity_Athlete_AthletesIdAthlete",
column: x => x.AthletesIdAthlete,
principalTable: "Athlete",
principalColumn: "IdAthlete",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AthleteEntityTrainingEntity_Training_TrainingsAthleteIdTraining",
column: x => x.TrainingsAthleteIdTraining,
principalTable: "Training",
principalColumn: "IdTraining",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Athlete",
columns: new[] { "IdAthlete", "DataSourceId", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Length", "Password", "Sexe", "Username", "Weight" },
values: new object[,]
{
{ 1, null, new DateOnly(1990, 1, 1), "john.doe@example.com", "John", true, "Doe", 1.8, "password123", "M", "Doe", 75f },
{ 3, null, new DateOnly(1992, 1, 1), "paul.martin@example.com", "Paul", true, "Martin", 1.75, "super789", "M", "Martin", 68f },
{ 4, null, new DateOnly(1993, 1, 1), "anna.brown@example.com", "Anna", false, "Brown", 1.7, "test000", "F", "Brown", 58f }
});
migrationBuilder.InsertData(
table: "DataSource",
columns: new[] { "IdSource", "Model", "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: "Activity",
columns: new[] { "IdActivity", "AthleteId", "Average", "AverageTemperature", "DataSourceId", "Date", "EffortFelt", "EndTime", "HasAutoPause", "Maximum", "Minimum", "StandardDeviation", "StartTime", "Type", "Variability", "Variance" },
values: new object[,]
{
{ 1, 1, 0.5f, 20f, 1, new DateOnly(2023, 1, 10), 5, new TimeOnly(14, 0, 22), false, 0, 0, 0.5f, new TimeOnly(13, 0, 34), "Running", 0.5f, 0.5f },
{ 3, 1, 0.5f, 20f, 1, new DateOnly(2023, 12, 10), 5, new TimeOnly(15, 2, 22), false, 0, 0, 0.5f, new TimeOnly(13, 30, 34), "Swimming", 0.5f, 0.5f },
{ 5, 4, 0.5f, 20f, 4, new DateOnly(2024, 1, 12), 5, new TimeOnly(9, 0, 22), false, 0, 0, 0.5f, new TimeOnly(7, 45, 34), "Hiking", 0.5f, 0.5f },
{ 6, 4, 0.5f, 20f, 4, new DateOnly(2024, 1, 27), 5, new TimeOnly(14, 0, 22), false, 0, 0, 0.5f, new TimeOnly(13, 30, 1), "Climbing", 0.5f, 0.5f },
{ 7, 3, 0.5f, 20f, 5, new DateOnly(2024, 2, 22), 5, new TimeOnly(23, 50, 58), false, 0, 0, 0.5f, new TimeOnly(22, 0, 34), "Yoga", 0.5f, 0.5f }
});
migrationBuilder.InsertData(
table: "Athlete",
columns: new[] { "IdAthlete", "DataSourceId", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Length", "Password", "Sexe", "Username", "Weight" },
values: new object[,]
{
{ 2, 1, new DateOnly(1995, 1, 1), "jane.smith@exemple.com", "Jane", false, "Smith", 1.6499999999999999, "secure456", "F", "Smith", 60f },
{ 5, 3, new DateOnly(1991, 1, 1), "bruce.lee@example.com", "Bruce", false, "Lee", 2.0, "hello321", "M", "Lee", 90f }
});
migrationBuilder.InsertData(
table: "FriendshipEntity",
columns: new[] { "FollowerId", "FollowingId", "StartDate" },
values: new object[,]
{
{ 1, 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) },
{ 1, 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }
});
migrationBuilder.InsertData(
table: "Notification",
columns: new[] { "IdNotif", "Date", "Message", "SenderId", "Statut", "Urgence" },
values: new object[,]
{
{ 1, new DateTime(2023, 12, 25, 13, 0, 40, 0, DateTimeKind.Unspecified), "You have a new activity to check", 1, true, "A" },
{ 3, new DateTime(2023, 12, 26, 16, 10, 4, 0, DateTimeKind.Unspecified), "You have a new heart rate to check", 3, true, "2" },
{ 4, new DateTime(2024, 1, 12, 9, 30, 50, 0, DateTimeKind.Unspecified), "You have a new data source to check", 4, false, "1" }
});
migrationBuilder.InsertData(
table: "Statistic",
columns: new[] { "IdStatistic", "AthleteId", "AverageCaloriesBurned", "AverageHeartRate", "Date", "MaximumHeartRate", "Weight" },
values: new object[,]
{
{ 1, 1, 500.0, 120.0, new DateOnly(2021, 12, 12), 180.0, 75f },
{ 3, 1, 550.0, 125.0, new DateOnly(2022, 12, 30), 185.0, 68f },
{ 4, 3, 650.0, 135.0, new DateOnly(2023, 2, 20), 195.0, 58f },
{ 5, 4, 450.0, 110.0, new DateOnly(2024, 1, 10), 170.0, 90f }
});
migrationBuilder.InsertData(
table: "Training",
columns: new[] { "IdTraining", "CoachId", "Date", "Description", "FeedBack", "Latitude", "Longitude" },
values: new object[,]
{
{ 1, 1, new DateOnly(2024, 1, 19), "Running", "Good", 48.8566f, 2.3522f },
{ 3, 4, new DateOnly(2024, 2, 21), null, "Good", 48.8566f, 2.3522f },
{ 4, 3, new DateOnly(2024, 2, 22), "Running", "Good", 48.8566f, 2.3522f },
{ 5, 1, new DateOnly(2024, 2, 23), "Cycling", null, 48.8566f, 2.3522f }
});
migrationBuilder.InsertData(
table: "Activity",
columns: new[] { "IdActivity", "AthleteId", "Average", "AverageTemperature", "DataSourceId", "Date", "EffortFelt", "EndTime", "HasAutoPause", "Maximum", "Minimum", "StandardDeviation", "StartTime", "Type", "Variability", "Variance" },
values: new object[,]
{
{ 2, 2, 0.5f, 20f, 2, new DateOnly(2023, 1, 25), 5, new TimeOnly(14, 0, 22), false, 0, 0, 0.5f, new TimeOnly(13, 4, 34), "Cycling", 0.5f, 0.5f },
{ 4, 5, 0.5f, 20f, 3, new DateOnly(2024, 1, 2), 5, new TimeOnly(16, 1, 55), false, 0, 0, 0.5f, new TimeOnly(15, 0, 0), "Walking", 0.5f, 0.5f }
});
migrationBuilder.InsertData(
table: "FriendshipEntity",
columns: new[] { "FollowerId", "FollowingId", "StartDate" },
values: new object[,]
{
{ 2, 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) },
{ 1, 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) },
{ 2, 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) },
{ 1, 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }
});
migrationBuilder.InsertData(
table: "HeartRate",
columns: new[] { "IdHeartRate", "ActivityId", "Altitude", "Bpm", "Latitude", "Longitude", "Temperature", "Time" },
values: new object[,]
{
{ 1, 1, 0.0, 60, 66f, 35f, 20f, new TimeOnly(13, 0, 30) },
{ 3, 1, 11.0, 71, 66f, 36f, 20f, new TimeOnly(13, 0, 32) }
});
migrationBuilder.InsertData(
table: "Notification",
columns: new[] { "IdNotif", "Date", "Message", "SenderId", "Statut", "Urgence" },
values: new object[,]
{
{ 2, new DateTime(2023, 12, 26, 13, 10, 40, 0, DateTimeKind.Unspecified), "You have a new athlete to check", 2, false, "3" },
{ 5, new DateTime(2024, 2, 22, 12, 10, 0, 0, DateTimeKind.Unspecified), "You have a new notification to check", 5, true, "3" }
});
migrationBuilder.InsertData(
table: "Statistic",
columns: new[] { "IdStatistic", "AthleteId", "AverageCaloriesBurned", "AverageHeartRate", "Date", "MaximumHeartRate", "Weight" },
values: new object[] { 2, 2, 600.0, 130.0, new DateOnly(2021, 1, 11), 190.0, 60f });
migrationBuilder.InsertData(
table: "Training",
columns: new[] { "IdTraining", "CoachId", "Date", "Description", "FeedBack", "Latitude", "Longitude" },
values: new object[] { 2, 5, new DateOnly(2024, 2, 20), "Cycling", null, 48.8566f, 2.3522f });
migrationBuilder.InsertData(
table: "HeartRate",
columns: new[] { "IdHeartRate", "ActivityId", "Altitude", "Bpm", "Latitude", "Longitude", "Temperature", "Time" },
values: new object[,]
{
{ 2, 2, 10.0, 65, 67f, 35f, 20.5f, new TimeOnly(13, 0, 31) },
{ 4, 2, 12.0, 75, 67f, 36f, 20.5f, new TimeOnly(13, 0, 33) },
{ 5, 4, 13.0, 80, 66f, 37f, 20f, new TimeOnly(13, 0, 34) }
});
migrationBuilder.CreateIndex(
name: "IX_Activity_AthleteId",
table: "Activity",
column: "AthleteId");
migrationBuilder.CreateIndex(
name: "IX_Activity_DataSourceId",
table: "Activity",
column: "DataSourceId");
migrationBuilder.CreateIndex(
name: "IX_Athlete_DataSourceId",
table: "Athlete",
column: "DataSourceId");
migrationBuilder.CreateIndex(
name: "IX_AthleteEntityNotificationEntity_ReceiversIdAthlete",
table: "AthleteEntityNotificationEntity",
column: "ReceiversIdAthlete");
migrationBuilder.CreateIndex(
name: "IX_AthleteEntityTrainingEntity_TrainingsAthleteIdTraining",
table: "AthleteEntityTrainingEntity",
column: "TrainingsAthleteIdTraining");
migrationBuilder.CreateIndex(
name: "IX_FriendshipEntity_FollowerId",
table: "FriendshipEntity",
column: "FollowerId");
migrationBuilder.CreateIndex(
name: "IX_HeartRate_ActivityId",
table: "HeartRate",
column: "ActivityId");
migrationBuilder.CreateIndex(
name: "IX_Notification_SenderId",
table: "Notification",
column: "SenderId");
migrationBuilder.CreateIndex(
name: "IX_Statistic_AthleteId",
table: "Statistic",
column: "AthleteId");
migrationBuilder.CreateIndex(
name: "IX_Training_CoachId",
table: "Training",
column: "CoachId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AthleteEntityNotificationEntity");
migrationBuilder.DropTable(
name: "AthleteEntityTrainingEntity");
migrationBuilder.DropTable(
name: "FriendshipEntity");
migrationBuilder.DropTable(
name: "HeartRate");
migrationBuilder.DropTable(
name: "Statistic");
migrationBuilder.DropTable(
name: "Notification");
migrationBuilder.DropTable(
name: "Training");
migrationBuilder.DropTable(
name: "Activity");
migrationBuilder.DropTable(
name: "Athlete");
migrationBuilder.DropTable(
name: "DataSource");
}
}
}

@ -1,974 +0,0 @@
// <auto-generated />
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("AthleteEntityNotificationEntity", b =>
{
b.Property<int>("NotificationsReceivedIdNotif")
.HasColumnType("INTEGER");
b.Property<int>("ReceiversIdAthlete")
.HasColumnType("INTEGER");
b.HasKey("NotificationsReceivedIdNotif", "ReceiversIdAthlete");
b.HasIndex("ReceiversIdAthlete");
b.ToTable("AthleteEntityNotificationEntity");
});
modelBuilder.Entity("AthleteEntityTrainingEntity", b =>
{
b.Property<int>("AthletesIdAthlete")
.HasColumnType("INTEGER");
b.Property<int>("TrainingsAthleteIdTraining")
.HasColumnType("INTEGER");
b.HasKey("AthletesIdAthlete", "TrainingsAthleteIdTraining");
b.HasIndex("TrainingsAthleteIdTraining");
b.ToTable("AthleteEntityTrainingEntity");
});
modelBuilder.Entity("Entities.ActivityEntity", b =>
{
b.Property<int>("IdActivity")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AthleteId")
.HasColumnType("INTEGER");
b.Property<float>("Average")
.HasColumnType("REAL");
b.Property<float>("AverageTemperature")
.HasColumnType("REAL");
b.Property<int>("DataSourceId")
.HasColumnType("INTEGER");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<int>("EffortFelt")
.HasColumnType("INTEGER");
b.Property<TimeOnly>("EndTime")
.HasColumnType("TEXT");
b.Property<bool>("HasAutoPause")
.HasColumnType("INTEGER");
b.Property<int>("Maximum")
.HasColumnType("INTEGER");
b.Property<int>("Minimum")
.HasColumnType("INTEGER");
b.Property<float>("StandardDeviation")
.HasColumnType("REAL");
b.Property<TimeOnly>("StartTime")
.HasColumnType("TEXT");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Variability")
.HasColumnType("REAL");
b.Property<float>("Variance")
.HasColumnType("REAL");
b.HasKey("IdActivity");
b.HasIndex("AthleteId");
b.HasIndex("DataSourceId");
b.ToTable("Activity");
b.HasData(
new
{
IdActivity = 1,
AthleteId = 1,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 1,
Date = new DateOnly(2023, 1, 10),
EffortFelt = 5,
EndTime = new TimeOnly(14, 0, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(13, 0, 34),
Type = "Running",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 2,
AthleteId = 2,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 2,
Date = new DateOnly(2023, 1, 25),
EffortFelt = 5,
EndTime = new TimeOnly(14, 0, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(13, 4, 34),
Type = "Cycling",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 3,
AthleteId = 1,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 1,
Date = new DateOnly(2023, 12, 10),
EffortFelt = 5,
EndTime = new TimeOnly(15, 2, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(13, 30, 34),
Type = "Swimming",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 4,
AthleteId = 5,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 3,
Date = new DateOnly(2024, 1, 2),
EffortFelt = 5,
EndTime = new TimeOnly(16, 1, 55),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(15, 0, 0),
Type = "Walking",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 5,
AthleteId = 4,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 4,
Date = new DateOnly(2024, 1, 12),
EffortFelt = 5,
EndTime = new TimeOnly(9, 0, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(7, 45, 34),
Type = "Hiking",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 6,
AthleteId = 4,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 4,
Date = new DateOnly(2024, 1, 27),
EffortFelt = 5,
EndTime = new TimeOnly(14, 0, 22),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(13, 30, 1),
Type = "Climbing",
Variability = 0.5f,
Variance = 0.5f
},
new
{
IdActivity = 7,
AthleteId = 3,
Average = 0.5f,
AverageTemperature = 20f,
DataSourceId = 5,
Date = new DateOnly(2024, 2, 22),
EffortFelt = 5,
EndTime = new TimeOnly(23, 50, 58),
HasAutoPause = false,
Maximum = 0,
Minimum = 0,
StandardDeviation = 0.5f,
StartTime = new TimeOnly(22, 0, 34),
Type = "Yoga",
Variability = 0.5f,
Variance = 0.5f
});
});
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.Property<int>("IdAthlete")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int?>("DataSourceId")
.HasColumnType("INTEGER");
b.Property<DateOnly>("DateOfBirth")
.HasColumnType("TEXT");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("TEXT");
b.Property<bool>("IsCoach")
.HasColumnType("INTEGER");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double>("Length")
.HasColumnType("REAL");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Sexe")
.IsRequired()
.HasMaxLength(1)
.HasColumnType("TEXT");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdAthlete");
b.HasIndex("DataSourceId");
b.ToTable("Athlete");
b.HasData(
new
{
IdAthlete = 1,
DateOfBirth = new DateOnly(1990, 1, 1),
Email = "john.doe@example.com",
FirstName = "John",
IsCoach = true,
LastName = "Doe",
Length = 1.8,
Password = "password123",
Sexe = "M",
Username = "Doe",
Weight = 75f
},
new
{
IdAthlete = 2,
DataSourceId = 1,
DateOfBirth = new DateOnly(1995, 1, 1),
Email = "jane.smith@exemple.com",
FirstName = "Jane",
IsCoach = false,
LastName = "Smith",
Length = 1.6499999999999999,
Password = "secure456",
Sexe = "F",
Username = "Smith",
Weight = 60f
},
new
{
IdAthlete = 3,
DateOfBirth = new DateOnly(1992, 1, 1),
Email = "paul.martin@example.com",
FirstName = "Paul",
IsCoach = true,
LastName = "Martin",
Length = 1.75,
Password = "super789",
Sexe = "M",
Username = "Martin",
Weight = 68f
},
new
{
IdAthlete = 4,
DateOfBirth = new DateOnly(1993, 1, 1),
Email = "anna.brown@example.com",
FirstName = "Anna",
IsCoach = false,
LastName = "Brown",
Length = 1.7,
Password = "test000",
Sexe = "F",
Username = "Brown",
Weight = 58f
},
new
{
IdAthlete = 5,
DataSourceId = 3,
DateOfBirth = new DateOnly(1991, 1, 1),
Email = "bruce.lee@example.com",
FirstName = "Bruce",
IsCoach = false,
LastName = "Lee",
Length = 2.0,
Password = "hello321",
Sexe = "M",
Username = "Lee",
Weight = 90f
});
});
modelBuilder.Entity("Entities.DataSourceEntity", b =>
{
b.Property<int>("IdSource")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Model")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<float>("Precision")
.HasColumnType("REAL");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("IdSource");
b.ToTable("DataSource");
b.HasData(
new
{
IdSource = 1,
Model = "Garmin",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 2,
Model = "Polar",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 3,
Model = "Suunto",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 4,
Model = "Fitbit",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 5,
Model = "Apple Watch",
Precision = 0.5f,
Type = "Smartwatch"
});
});
modelBuilder.Entity("Entities.FriendshipEntity", b =>
{
b.Property<int>("FollowingId")
.HasColumnType("INTEGER");
b.Property<int>("FollowerId")
.HasColumnType("INTEGER");
b.Property<DateTime>("StartDate")
.HasColumnType("TEXT");
b.HasKey("FollowingId", "FollowerId");
b.HasIndex("FollowerId");
b.ToTable("FriendshipEntity");
b.HasData(
new
{
FollowingId = 2,
FollowerId = 1,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 3,
FollowerId = 1,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 4,
FollowerId = 1,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 5,
FollowerId = 1,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 1,
FollowerId = 2,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
},
new
{
FollowingId = 3,
FollowerId = 2,
StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
});
});
modelBuilder.Entity("Entities.HeartRateEntity", b =>
{
b.Property<int>("IdHeartRate")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("ActivityId")
.HasColumnType("INTEGER");
b.Property<double>("Altitude")
.HasColumnType("REAL");
b.Property<int>("Bpm")
.HasColumnType("INTEGER");
b.Property<float>("Latitude")
.HasColumnType("REAL");
b.Property<float>("Longitude")
.HasColumnType("REAL");
b.Property<float>("Temperature")
.HasColumnType("REAL");
b.Property<TimeOnly>("Time")
.HasColumnType("TEXT");
b.HasKey("IdHeartRate");
b.HasIndex("ActivityId");
b.ToTable("HeartRate");
b.HasData(
new
{
IdHeartRate = 1,
ActivityId = 1,
Altitude = 0.0,
Bpm = 60,
Latitude = 66f,
Longitude = 35f,
Temperature = 20f,
Time = new TimeOnly(13, 0, 30)
},
new
{
IdHeartRate = 2,
ActivityId = 2,
Altitude = 10.0,
Bpm = 65,
Latitude = 67f,
Longitude = 35f,
Temperature = 20.5f,
Time = new TimeOnly(13, 0, 31)
},
new
{
IdHeartRate = 3,
ActivityId = 1,
Altitude = 11.0,
Bpm = 71,
Latitude = 66f,
Longitude = 36f,
Temperature = 20f,
Time = new TimeOnly(13, 0, 32)
},
new
{
IdHeartRate = 4,
ActivityId = 2,
Altitude = 12.0,
Bpm = 75,
Latitude = 67f,
Longitude = 36f,
Temperature = 20.5f,
Time = new TimeOnly(13, 0, 33)
},
new
{
IdHeartRate = 5,
ActivityId = 4,
Altitude = 13.0,
Bpm = 80,
Latitude = 66f,
Longitude = 37f,
Temperature = 20f,
Time = new TimeOnly(13, 0, 34)
});
});
modelBuilder.Entity("Entities.NotificationEntity", b =>
{
b.Property<int>("IdNotif")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<DateTime>("Date")
.HasColumnType("TEXT");
b.Property<string>("Message")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<int>("SenderId")
.HasColumnType("INTEGER");
b.Property<bool>("Statut")
.HasColumnType("INTEGER");
b.Property<string>("Urgence")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
b.HasKey("IdNotif");
b.HasIndex("SenderId");
b.ToTable("Notification");
b.HasData(
new
{
IdNotif = 1,
Date = new DateTime(2023, 12, 25, 13, 0, 40, 0, DateTimeKind.Unspecified),
Message = "You have a new activity to check",
SenderId = 1,
Statut = true,
Urgence = "A"
},
new
{
IdNotif = 2,
Date = new DateTime(2023, 12, 26, 13, 10, 40, 0, DateTimeKind.Unspecified),
Message = "You have a new athlete to check",
SenderId = 2,
Statut = false,
Urgence = "3"
},
new
{
IdNotif = 3,
Date = new DateTime(2023, 12, 26, 16, 10, 4, 0, DateTimeKind.Unspecified),
Message = "You have a new heart rate to check",
SenderId = 3,
Statut = true,
Urgence = "2"
},
new
{
IdNotif = 4,
Date = new DateTime(2024, 1, 12, 9, 30, 50, 0, DateTimeKind.Unspecified),
Message = "You have a new data source to check",
SenderId = 4,
Statut = false,
Urgence = "1"
},
new
{
IdNotif = 5,
Date = new DateTime(2024, 2, 22, 12, 10, 0, 0, DateTimeKind.Unspecified),
Message = "You have a new notification to check",
SenderId = 5,
Statut = true,
Urgence = "3"
});
});
modelBuilder.Entity("Entities.StatisticEntity", b =>
{
b.Property<int>("IdStatistic")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("AthleteId")
.HasColumnType("INTEGER");
b.Property<double>("AverageCaloriesBurned")
.HasColumnType("REAL");
b.Property<double>("AverageHeartRate")
.HasColumnType("REAL");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<double>("MaximumHeartRate")
.HasColumnType("REAL");
b.Property<float>("Weight")
.HasColumnType("REAL");
b.HasKey("IdStatistic");
b.HasIndex("AthleteId");
b.ToTable("Statistic");
b.HasData(
new
{
IdStatistic = 1,
AthleteId = 1,
AverageCaloriesBurned = 500.0,
AverageHeartRate = 120.0,
Date = new DateOnly(2021, 12, 12),
MaximumHeartRate = 180.0,
Weight = 75f
},
new
{
IdStatistic = 2,
AthleteId = 2,
AverageCaloriesBurned = 600.0,
AverageHeartRate = 130.0,
Date = new DateOnly(2021, 1, 11),
MaximumHeartRate = 190.0,
Weight = 60f
},
new
{
IdStatistic = 3,
AthleteId = 1,
AverageCaloriesBurned = 550.0,
AverageHeartRate = 125.0,
Date = new DateOnly(2022, 12, 30),
MaximumHeartRate = 185.0,
Weight = 68f
},
new
{
IdStatistic = 4,
AthleteId = 3,
AverageCaloriesBurned = 650.0,
AverageHeartRate = 135.0,
Date = new DateOnly(2023, 2, 20),
MaximumHeartRate = 195.0,
Weight = 58f
},
new
{
IdStatistic = 5,
AthleteId = 4,
AverageCaloriesBurned = 450.0,
AverageHeartRate = 110.0,
Date = new DateOnly(2024, 1, 10),
MaximumHeartRate = 170.0,
Weight = 90f
});
});
modelBuilder.Entity("Entities.TrainingEntity", b =>
{
b.Property<int>("IdTraining")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("CoachId")
.HasColumnType("INTEGER");
b.Property<DateOnly>("Date")
.HasColumnType("TEXT");
b.Property<string>("Description")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<string>("FeedBack")
.HasMaxLength(300)
.HasColumnType("TEXT");
b.Property<float>("Latitude")
.HasColumnType("REAL");
b.Property<float>("Longitude")
.HasColumnType("REAL");
b.HasKey("IdTraining");
b.HasIndex("CoachId");
b.ToTable("Training");
b.HasData(
new
{
IdTraining = 1,
CoachId = 1,
Date = new DateOnly(2024, 1, 19),
Description = "Running",
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 2,
CoachId = 5,
Date = new DateOnly(2024, 2, 20),
Description = "Cycling",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 3,
CoachId = 4,
Date = new DateOnly(2024, 2, 21),
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 4,
CoachId = 3,
Date = new DateOnly(2024, 2, 22),
Description = "Running",
FeedBack = "Good",
Latitude = 48.8566f,
Longitude = 2.3522f
},
new
{
IdTraining = 5,
CoachId = 1,
Date = new DateOnly(2024, 2, 23),
Description = "Cycling",
Latitude = 48.8566f,
Longitude = 2.3522f
});
});
modelBuilder.Entity("AthleteEntityNotificationEntity", b =>
{
b.HasOne("Entities.NotificationEntity", null)
.WithMany()
.HasForeignKey("NotificationsReceivedIdNotif")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.AthleteEntity", null)
.WithMany()
.HasForeignKey("ReceiversIdAthlete")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("AthleteEntityTrainingEntity", b =>
{
b.HasOne("Entities.AthleteEntity", null)
.WithMany()
.HasForeignKey("AthletesIdAthlete")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.TrainingEntity", null)
.WithMany()
.HasForeignKey("TrainingsAthleteIdTraining")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Entities.ActivityEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Athlete")
.WithMany("Activities")
.HasForeignKey("AthleteId");
b.HasOne("Entities.DataSourceEntity", "DataSource")
.WithMany("Activities")
.HasForeignKey("DataSourceId");
b.Navigation("Athlete");
b.Navigation("DataSource");
});
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.HasOne("Entities.DataSourceEntity", "DataSource")
.WithMany("Athletes")
.HasForeignKey("DataSourceId");
b.Navigation("DataSource");
});
modelBuilder.Entity("Entities.FriendshipEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Follower")
.WithMany("Followers")
.HasForeignKey("FollowerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Entities.AthleteEntity", "Following")
.WithMany("Followings")
.HasForeignKey("FollowingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Follower");
b.Navigation("Following");
});
modelBuilder.Entity("Entities.HeartRateEntity", b =>
{
b.HasOne("Entities.ActivityEntity", "Activity")
.WithMany("HeartRates")
.HasForeignKey("ActivityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Activity");
});
modelBuilder.Entity("Entities.NotificationEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Sender")
.WithMany("NotificationsSent")
.HasForeignKey("SenderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Sender");
});
modelBuilder.Entity("Entities.StatisticEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Athlete")
.WithMany("Statistics")
.HasForeignKey("AthleteId");
b.Navigation("Athlete");
});
modelBuilder.Entity("Entities.TrainingEntity", b =>
{
b.HasOne("Entities.AthleteEntity", "Coach")
.WithMany("TrainingsCoach")
.HasForeignKey("CoachId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Coach");
});
modelBuilder.Entity("Entities.ActivityEntity", b =>
{
b.Navigation("HeartRates");
});
modelBuilder.Entity("Entities.AthleteEntity", b =>
{
b.Navigation("Activities");
b.Navigation("Followers");
b.Navigation("Followings");
b.Navigation("NotificationsSent");
b.Navigation("Statistics");
b.Navigation("TrainingsCoach");
});
modelBuilder.Entity("Entities.DataSourceEntity", b =>
{
b.Navigation("Activities");
b.Navigation("Athletes");
});
#pragma warning restore 612, 618
}
}
}

@ -26,7 +26,7 @@ namespace StubbedContextLib
/// Initializes a new instance of the <see cref="NotificationStubbedContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public NotificationStubbedContext(DbContextOptions<LibraryContext> options) : base(options) { }
public NotificationStubbedContext(DbContextOptions<HeartTrackContext> options) : base(options) { }
/// <summary>
/// Configures the model for the notification stubbed context.

@ -26,7 +26,7 @@ namespace StubbedContextLib
/// Initializes a new instance of the <see cref="StatisticStubbedContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public StatisticStubbedContext(DbContextOptions<LibraryContext> options) : base(options) { }
public StatisticStubbedContext(DbContextOptions<HeartTrackContext> options) : base(options) { }
/// <summary>
/// Configures the model for the statistic stubbed context.

@ -26,7 +26,7 @@ namespace StubbedContextLib
/// Initializes a new instance of the <see cref="TrainingStubbedContext"/> class with the specified options.
/// </summary>
/// <param name="options">The options for the context.</param>
public TrainingStubbedContext(DbContextOptions<LibraryContext> options) : base(options) { }
public TrainingStubbedContext(DbContextOptions<HeartTrackContext> options) : base(options) { }
/// <summary>
/// Configures the model for the training stubbed context.

@ -9,7 +9,7 @@ class Program
{
try {
using (LibraryContext db = new TrainingStubbedContext())
using (HeartTrackContext db = new TrainingStubbedContext())
{
AthletesTests(db);
@ -46,7 +46,7 @@ class Program
}
}
static void AthletesTests(LibraryContext db)
static void AthletesTests(HeartTrackContext db)
{
Console.WriteLine("Accès à tous les athletes :");
@ -161,7 +161,7 @@ class Program
Console.WriteLine("---------------------------------\n");
}
static void ActivityTests(LibraryContext db)
static void ActivityTests(HeartTrackContext db)
{
Console.WriteLine("Accès à toutes les activités :");
@ -276,7 +276,7 @@ class Program
Console.WriteLine("---------------------------------\n");
}
static void DataSourceTests(LibraryContext db)
static void DataSourceTests(HeartTrackContext db)
{
Console.WriteLine("Accès à toutes les sources de données :");
@ -341,7 +341,7 @@ class Program
Console.WriteLine("---------------------------------\n");
}
static void HeartRateTests(LibraryContext db)
static void HeartRateTests(HeartTrackContext db)
{
Console.WriteLine("Accès à toutes les fréquences cardiaques :");
@ -426,7 +426,7 @@ class Program
Console.WriteLine("---------------------------------\n");
}
static void NotificationTests(LibraryContext db)
static void NotificationTests(HeartTrackContext db)
{
Console.WriteLine("Accès à toutes les notifications :");
@ -501,7 +501,7 @@ class Program
Console.WriteLine("---------------------------------\n");
}
static void StatisticTests(LibraryContext db)
static void StatisticTests(HeartTrackContext db)
{
Console.WriteLine("Accès à toutes les statistiques :");
@ -635,7 +635,7 @@ class Program
Console.WriteLine("---------------------------------\n");
}
static void TrainingTests(LibraryContext db)
static void TrainingTests(HeartTrackContext db)
{
Console.WriteLine("Accès à tout les entrainements :");
@ -750,12 +750,14 @@ class Program
Console.WriteLine("---------------------------------\n");
}
static void AddUpdateDeleteAthlete(LibraryContext db)
static void AddUpdateDeleteAthlete(HeartTrackContext db)
{
Console.WriteLine("Test d'ajout, de modification et de suppression des athletes :");
var picture = System.Text.Encoding.UTF8.GetBytes(
"\"UklGRtwDAABXRUJQVlA4INADAAAwEACdASoqACoAAMASJZgCdMoSCz655ndU4XXAP2yXIge5neM/Qd6WCfO8evoj2S0A/p7+f0An85cBxlLDgPC8jO/0nsl/13/O8vvzj7Af8s/p3/H4FU6td4MCwq23z1H2uzoKIXaqJniPI/bRMf8qzv0Zp+HE1RCBw5WQ1j/JovdM1FS52+QcaAAA/v/+NxU4DpPk3+xQPW7tcmURSo9vC4qc+XMxNVBzEM5E8actDz98gmwTXgD62e9EmG/ervdd2ovFFSuxYppWl/wtaX3rkn0xrt8qOql/5I2jfLOnCU0kALLcW4F/wTjU10qsxZXW9fxauC6OPVRF28sc94V9ocmoSWy+sf6jW3vYkVOh+gE/RE0L6b2d3oFyHmkRJnfYwG8o3p6fv9pivNF5aopIBzFnjzwb/VqSq3/b+MWKFmjr8T1qe4/fITo2vBWEqDyogV3ZVGnDVi2DbiEFVSUr2eXTNZQ9V/D9QC/+vCR5TGyX9QOVBgtAYtm/ZTIwzPEYB9NrV1NeO1/sAz78u0tW59r0I+SO5Jgm3B9i1toRurzHv9EZJ9yZL8nafb/T1FaoPDkuJfM+iPs0j8xnS7TaU/gEK0wCxeDYRYtJx9j4hUQq7pAu/T2yWy0vjcUHki952ZNbXnXxB8m8pV5x9E1sfLj5MZEgpU2XV8RHrVvWniCjsf6vgxmR7+KtwIbMjahitUGtHet1WdL+8MmdL29iQJC37pDXirir1NibxKKhFYRuJ3xW9O0r9+Vnh8diqbBuXqDbYR/MSoHvscOCm2t95dN5WBdRUoD7YCG/ZHWc7Ypv/x/al4fkB2lZlYhVWHxjaoeF9jEPI0gAN5XsvUI6hbzEzWMsNW/1orkNOnlskalgmpI4B2rm4Gc7LNui+MuMBrpnBvLkbYX9exe9g8tu7wLt7ScOjDcL99oOyR89Mh9L8rd4+43+JQyR6tsIfcPJo6T6FxHf11d/MGayJi+SWct/uhvvua0oOh+zXNIaUzgoBmu1XULjkpuA0Ghzctf30jbY1AOM49qbMZRYS9A+0S1HrHPnwRvpQY/Sj4xKPn0gdpv/+iTbKJb8zkPC4/9af0Jvesa+GDG0/iw3TswenMhqlh7BM9MW5txpeblsByx4WnJ/oHv6cc0dmM7tsV36lYkCTUXEf/0eKlnfivnN0g1g+j/Lk9et/uoa6TFCW0HgwFOIVFumEYdT675PfuTrYO5o8ZrWEIHtv2Ctlrv9J3TrslD/iKEwtipGHtn0Vak8B9wLL+kz+CIQ/VG4KJpXjx88CeCC4XaGitEdjAAA\"");
// Ajout d'un nouveau livre
var newAthlete = new AthleteEntity { Username = "Doe", LastName = "Doe", FirstName = "John", Email = "essaie.example.com", Password = "TheNewPassword", Sexe = "M", Length = 1.80, Weight = 90, DateOfBirth = new DateOnly(2024, 02, 22), IsCoach = false };
var newAthlete = new AthleteEntity { Username = "Doe", LastName = "Doe",ProfilPicture = picture,FirstName = "John", Email = "essaie.example.com", Password = "TheNewPassword", Sexe = "M", Length = 1.80, Weight = 90, DateOfBirth = new DateOnly(2024, 02, 22), IsCoach = false };
db.AthletesSet.Add(newAthlete);
db.SaveChanges();
@ -789,7 +791,7 @@ class Program
}
}
static void AddUpdateDeleteActivity(LibraryContext db)
static void AddUpdateDeleteActivity(HeartTrackContext db)
{
Console.WriteLine("Test d'ajout, de modification et de suppression des activités :");
@ -823,7 +825,7 @@ class Program
}
static void AddUpdateDeleteDataSource(LibraryContext db)
static void AddUpdateDeleteDataSource(HeartTrackContext db)
{
Console.WriteLine("Test d'ajout, de modification et de suppression des sources de données :");
@ -856,7 +858,7 @@ class Program
}
}
static void AddUpdateDeleteHeartRate(LibraryContext db)
static void AddUpdateDeleteHeartRate(HeartTrackContext db)
{
Console.WriteLine("Test d'ajout, de modification et de suppression des fréquences cardiaques :");
@ -889,7 +891,7 @@ class Program
}
}
static void AddUpdateDeleteNotification(LibraryContext db)
static void AddUpdateDeleteNotification(HeartTrackContext db)
{
Console.WriteLine("Test d'ajout, de modification et de suppression des notifications :");
@ -922,7 +924,7 @@ class Program
}
}
static void AddUpdateDeleteStatistic(LibraryContext db)
static void AddUpdateDeleteStatistic(HeartTrackContext db)
{
Console.WriteLine("Test d'ajout, de modification et de suppression des statistiques :");
@ -955,7 +957,7 @@ class Program
}
}
static void AddUpdateDeleteTraining(LibraryContext db)
static void AddUpdateDeleteTraining(HeartTrackContext db)
{
Console.WriteLine("Test d'ajout, de modification et de suppression des entrainements :");

@ -1,6 +1,8 @@

using DbContextLib;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using StubbedContextLib;
class Program
@ -9,8 +11,13 @@ class Program
{
try {
using (LibraryContext db = new TrainingStubbedContext())
var options = new DbContextOptionsBuilder<HeartTrackContext>()
.UseSqlite("Data Source=uca.HeartTrack.db")
.Options;
using (HeartTrackContext db = new TrainingStubbedContext(options))
{
db.Database.EnsureCreated();
ActivityTests(db);
DataSourceTests(db);
@ -25,7 +32,7 @@ class Program
Console.WriteLine($"Une erreur s'est produite : {ex.Message}");
}
}
static void ActivityTests(LibraryContext db)
static void ActivityTests(HeartTrackContext db)
{
Console.WriteLine("Accès à toutes les activités avec leurs fréquences cardiaques :");
@ -64,7 +71,7 @@ class Program
}
}
static void DataSourceTests(LibraryContext db)
static void DataSourceTests(HeartTrackContext db)
{
Console.WriteLine("Accès à toutes les sources de données avec leurs activités :");
@ -121,7 +128,7 @@ class Program
Console.WriteLine("---------------------------------\n");
}
static void AthleteTests(LibraryContext db)
static void AthleteTests(HeartTrackContext db)
{
Console.WriteLine("Accès à tous les athlètes avec leurs statistiques :");
@ -252,7 +259,7 @@ class Program
Console.WriteLine("---------------------------------\n");
}
static void FriendshipTests(LibraryContext db)
static void FriendshipTests(HeartTrackContext db)
{
Console.WriteLine("Accès à toutes les amitiés :");

Loading…
Cancel
Save