Add somes console tests for Entities

WORK-WebAPI
Antoine PEREDERII 1 year ago
parent b82b84b831
commit f9053b73e3

@ -1,38 +1,86 @@
using Entities;
using Microsoft.EntityFrameworkCore;
//-----------------------------------------------------------------------
// FILENAME: LibraryContext.cs
// PROJECT: DbContextLib
// SOLUTION: FitnessApp
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
namespace DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
public class LibraryContext : DbContext
namespace DbContextLib
{
public DbSet<AthleteEntity> AthletesSet { get; set; }
/// <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; }
public DbSet<ActivityEntity> ActivitiesSet { get; set; }
/// <summary>
/// Gets or sets the set of activities.
/// </summary>
public DbSet<ActivityEntity> ActivitiesSet { get; set; }
public DbSet<DataSourceEntity> DataSourcesSet { get; set; }
public DbSet<HeartRateEntity> HeartRatesSet { get; set; }
public DbSet<NotificationEntity> NotificationsSet { get; set; }
public DbSet<StatisticEntity> StatisticsSet { get; set; }
public DbSet<TrainingEntity> TrainingsSet { get; set; }
/// <summary>
/// Gets or sets the set of data sources.
/// </summary>
public DbSet<DataSourceEntity> DataSourcesSet { get; set; }
public LibraryContext()
:base()
{ }
/// <summary>
/// Gets or sets the set of heart rates.
/// </summary>
public DbSet<HeartRateEntity> HeartRatesSet { get; set; }
public LibraryContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
/// <summary>
/// Gets or sets the set of notifications.
/// </summary>
public DbSet<NotificationEntity> NotificationsSet { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if(!optionsBuilder.IsConfigured)
/// <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)
{
optionsBuilder.UseSqlite($"Data Source=uca.HeartTrack.db");
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite($"Data Source=uca.HeartTrack.db");
}
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
/// <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);
}
}
}

@ -1,35 +1,100 @@
//-----------------------------------------------------------------------
// FILENAME: ActivityEntity.cs
// PROJECT: Entities
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities;
namespace Entities
{
/// <summary>
/// Represents an activity entity in the database.
/// </summary>
[Table("Activity")]
public class ActivityEntity
{
/// <summary>
/// Gets or sets the unique identifier of the activity.
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdActivity { get; set; }
/// <summary>
/// Gets or sets the type of the activity.
/// </summary>
[Required]
[MaxLength(100)]
public string Type { get; set; }
/// <summary>
/// Gets or sets the date of the activity.
/// </summary>
[Required(ErrorMessage = "Activity Date is required")]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateOnly Date { get; set; }
[Table("Activity")]
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 DateOnly Date { get; set; }
[Required(ErrorMessage = "Start Activity Hour is required")]
[DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)]
public TimeOnly StartTime { get; set; }
[Required(ErrorMessage = "End Activity Hour is required")]
[DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)]
public TimeOnly EndTime { get; set; }
public int EffortFelt { get; set; }
public float Variability { get; set; }
public float Variance { get; set; }
public float StandardDeviation { get; set; }
public float Average { get; set; }
public int Maximum { get; set; }
public int Minimum { get; set; }
public float AverageTemperature { get; set; }
public bool HasAutoPause { get; set; }
/// <summary>
/// Gets or sets the start time of the activity.
/// </summary>
[Required(ErrorMessage = "Start Activity Hour is required")]
[DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)]
public TimeOnly StartTime { get; set; }
/// <summary>
/// Gets or sets the end time of the activity.
/// </summary>
[Required(ErrorMessage = "End Activity Hour is required")]
[DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)]
public TimeOnly EndTime { get; set; }
/// <summary>
/// Gets or sets the perceived effort of the activity.
/// </summary>
public int EffortFelt { get; set; }
/// <summary>
/// Gets or sets the variability of the activity.
/// </summary>
public float Variability { get; set; }
/// <summary>
/// Gets or sets the variance of the activity.
/// </summary>
public float Variance { get; set; }
/// <summary>
/// Gets or sets the standard deviation of the activity.
/// </summary>
public float StandardDeviation { get; set; }
/// <summary>
/// Gets or sets the average of the activity.
/// </summary>
public float Average { get; set; }
/// <summary>
/// Gets or sets the maximum value of the activity.
/// </summary>
public int Maximum { get; set; }
/// <summary>
/// Gets or sets the minimum value of the activity.
/// </summary>
public int Minimum { get; set; }
/// <summary>
/// Gets or sets the average temperature during the activity.
/// </summary>
public float AverageTemperature { get; set; }
/// <summary>
/// Gets or sets whether the activity has an automatic pause feature.
/// </summary>
public bool HasAutoPause { get; set; }
}
}

@ -1,32 +1,90 @@
//-----------------------------------------------------------------------
// FILENAME: AthleteEntity.cs
// PROJECT: Entities
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities;
[Table("Athlete")]
public class AthleteEntity
namespace Entities
{
// ! donner plus de contraintes !!
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdAthlete { get; set; }
[Required]
[MaxLength(100)]
public required string Username { get; set; }
[MaxLength(100)]
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 double Lenght { get; set; }
public float Weight { get; set; }
public required string Password { get; set; }
[Required(ErrorMessage = "Athlete Date of Birth is required")]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateOnly DateOfBirth { get; set; }
public bool IsCoach { get; set; }
/// <summary>
/// Represents an athlete entity in the database.
/// </summary>
[Table("Athlete")]
public class AthleteEntity
{
/// <summary>
/// Gets or sets the unique identifier of the athlete.
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdAthlete { get; set; }
/// <summary>
/// Gets or sets the username of the athlete.
/// </summary>
[MaxLength(100)]
[Required(ErrorMessage = "Athlete Username is required")]
public required string Username { get; set; }
/// <summary>
/// Gets or sets the last name of the athlete.
/// </summary>
[MaxLength(100)]
[Required(ErrorMessage = "Athlete Last Name is required")]
public required string LastName { get; set; }
/// <summary>
/// Gets or sets the first name of the athlete.
/// </summary>
[MaxLength(150)]
[Required(ErrorMessage = "Athlete First Name is required")]
public required string FirstName { get; set; }
/// <summary>
/// Gets or sets the email of the athlete.
/// </summary>
[MaxLength(100)]
[Required(ErrorMessage = "Athlete Email is required")]
public required string Email { get; set; }
/// <summary>
/// Gets or sets the gender of the athlete.
/// </summary>
[MaxLength(1)]
[Required(ErrorMessage = "Athlete Sexe is required")]
public required string Sexe { get; set; }
/// <summary>
/// Gets or sets the height of the athlete.
/// </summary>
public double Length { get; set; }
/// <summary>
/// Gets or sets the weight of the athlete.
/// </summary>
public float Weight { get; set; }
/// <summary>
/// Gets or sets the password of the athlete.
/// </summary>
[Required(ErrorMessage = "Athlete Password is required")]
public required string Password { get; set; }
/// <summary>
/// Gets or sets the date of birth of the athlete.
/// </summary>
[Required(ErrorMessage = "Athlete Date of Birth is required")]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateOnly DateOfBirth { get; set; }
/// <summary>
/// Gets or sets whether the athlete is a coach.
/// </summary>
public bool IsCoach { get; set; }
}
}

@ -1,17 +1,46 @@
//-----------------------------------------------------------------------
// FILENAME: DataSourceEntity.cs
// PROJECT: Entities
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities;
[Table("DataSource")]
public class DataSourceEntity
namespace Entities
{
[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; }
/// <summary>
/// Represents a data source entity in the database.
/// </summary>
[Table("DataSource")]
public class DataSourceEntity
{
/// <summary>
/// Gets or sets the unique identifier of the data source.
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdSource { get; set; }
/// <summary>
/// Gets or sets the type of the data source.
/// </summary>
[MaxLength(100)]
[Required]
public required string Type { get; set; }
/// <summary>
/// Gets or sets the model of the data source.
/// </summary>
[MaxLength(100)]
[Required]
public required string Model { get; set; }
/// <summary>
/// Gets or sets the precision of the data source.
/// </summary>
public float Precision { get; set; }
}
}

@ -1,20 +1,59 @@
//-----------------------------------------------------------------------
// FILENAME: HeartRateEntity.cs
// PROJECT: Entities
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities;
[Table("HeartRate")]
public class HeartRateEntity
namespace Entities
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdHeartRate { get; set; }
public double Altitude { get; set; }
[Required(ErrorMessage = "HeartRate Time is required")]
[DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)]
public TimeOnly Time { get; set; }
public float Temperature { get; set; }
public int Bpm { get; set; }
public float Longitude { get; set; }
public float Latitude { get; set; }
/// <summary>
/// Represents a heart rate entity in the database.
/// </summary>
[Table("HeartRate")]
public class HeartRateEntity
{
/// <summary>
/// Gets or sets the unique identifier of the heart rate entry.
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdHeartRate { get; set; }
/// <summary>
/// Gets or sets the altitude.
/// </summary>
public double Altitude { get; set; }
/// <summary>
/// Gets or sets the time of the heart rate measurement.
/// </summary>
[Required(ErrorMessage = "HeartRate Time is required")]
[DisplayFormat(DataFormatString = "{0:HH:mm;ss}", ApplyFormatInEditMode = true)]
public TimeOnly Time { get; set; }
/// <summary>
/// Gets or sets the temperature.
/// </summary>
public float Temperature { get; set; }
/// <summary>
/// Gets or sets the heart rate in beats per minute (bpm).
/// </summary>
public int Bpm { get; set; }
/// <summary>
/// Gets or sets the longitude.
/// </summary>
public float Longitude { get; set; }
/// <summary>
/// Gets or sets the latitude.
/// </summary>
public float Latitude { get; set; }
}
}

@ -1,21 +1,52 @@
//-----------------------------------------------------------------------
// FILENAME: NotificationEntity.cs
// PROJECT: Entities
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities;
[Table("Notification")]
public class NotificationEntity
namespace Entities
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdNotif { 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")]
[DisplayFormat(DataFormatString = "{0:HH.mm.ss - HH.mm.ss}", ApplyFormatInEditMode = true)]
public DateTime Date { get; set; }
public bool Statut { get; set; }
[MaxLength(100)]
public required string Urgence { get; set; }
/// <summary>
/// Represents a notification entity in the database.
/// </summary>
[Table("Notification")]
public class NotificationEntity
{
/// <summary>
/// Gets or sets the unique identifier of the notification.
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdNotif { get; set; }
/// <summary>
/// Gets or sets the message of the notification.
/// </summary>
[MaxLength(100)]
[Required(ErrorMessage = "Message is required")]
public string Message { get; set; } = null!;
/// <summary>
/// Gets or sets the date of the notification.
/// </summary>
[Required(ErrorMessage = "Notification Date is required")]
[DisplayFormat(DataFormatString = "{0:HH.mm.ss - HH.mm.ss}", ApplyFormatInEditMode = true)]
public DateTime Date { get; set; }
/// <summary>
/// Gets or sets the status of the notification.
/// </summary>
public bool Statut { get; set; }
/// <summary>
/// Gets or sets the urgency of the notification.
/// </summary>
[MaxLength(100)]
public string Urgence { get; set; } = null!;
}
}

@ -1,19 +1,54 @@
//-----------------------------------------------------------------------
// FILENAME: StatisticEntity.cs
// PROJECT: Entities
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Entities;
[Table("Statistic")]
public class StatisticEntity
namespace Entities
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdStatistic { get; set; }
public float Weight { get; set; }
public double AverageHeartRate { get; set; }
public double MaximumHeartRate { get; set; }
public double AverageCaloriesBurned { get; set; }
[Required(ErrorMessage = "Satistic Date is required")]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateOnly Date { get; set; }
/// <summary>
/// Represents a statistic entity in the database.
/// </summary>
[Table("Statistic")]
public class StatisticEntity
{
/// <summary>
/// Gets or sets the unique identifier of the statistic.
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdStatistic { get; set; }
/// <summary>
/// Gets or sets the weight recorded in the statistic.
/// </summary>
public float Weight { get; set; }
/// <summary>
/// Gets or sets the average heart rate recorded in the statistic.
/// </summary>
public double AverageHeartRate { get; set; }
/// <summary>
/// Gets or sets the maximum heart rate recorded in the statistic.
/// </summary>
public double MaximumHeartRate { get; set; }
/// <summary>
/// Gets or sets the average calories burned recorded in the statistic.
/// </summary>
public double AverageCaloriesBurned { get; set; }
/// <summary>
/// Gets or sets the date of the statistic.
/// </summary>
[Required(ErrorMessage = "Statistic Date is required")]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateOnly Date { get; set; }
}
}

@ -1,23 +1,56 @@
//-----------------------------------------------------------------------
// FILENAME: TrainingEntity.cs
// PROJECT: Entities
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.CompilerServices;
namespace Entities;
[Table("Training")]
public class TrainingEntity
namespace Entities
{
// ! donner plus de contraintes !!
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdTraining { get; set; }
[Required(ErrorMessage = "Training Date is required")]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateOnly Date { get; set; }
[MaxLength(300)]
public string? Description { get; set; }
public float Latitude { get; set; }
public float Longitude { get; set; }
[MaxLength(300)]
public string? FeedBack { get; set; }
/// <summary>
/// Represents a training entity in the database.
/// </summary>
[Table("Training")]
public class TrainingEntity
{
/// <summary>
/// Gets or sets the unique identifier of the training.
/// </summary>
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int IdTraining { get; set; }
/// <summary>
/// Gets or sets the date of the training.
/// </summary>
[Required(ErrorMessage = "Training Date is required")]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateOnly Date { get; set; }
/// <summary>
/// Gets or sets the description of the training.
/// </summary>
[MaxLength(300)]
public string? Description { get; set; }
/// <summary>
/// Gets or sets the latitude of the training location.
/// </summary>
public float Latitude { get; set; }
/// <summary>
/// Gets or sets the longitude of the training location.
/// </summary>
public float Longitude { get; set; }
/// <summary>
/// Gets or sets the feedback for the training.
/// </summary>
[MaxLength(300)]
public string? FeedBack { get; set; }
}
}

@ -1,31 +1,51 @@
//-----------------------------------------------------------------------
// FILENAME: ActivityStubbedContext.cs
// PROJECT: StubbedContextLib
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class ActivityStubbedContext : LibraryContext
namespace StubbedContextLib
{
public ActivityStubbedContext()
:base()
{ }
/// <summary>
/// Represents a stubbed context for activities.
/// </summary>
public class ActivityStubbedContext : LibraryContext
{
/// <summary>
/// Initializes a new instance of the <see cref="ActivityStubbedContext"/> class.
/// </summary>
public ActivityStubbedContext() : base() { }
public ActivityStubbedContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
/// <summary>
/// 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) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
/// <summary>
/// Configures the model for the activity context.
/// </summary>
/// <param name="modelBuilder">The model builder instance.</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ActivityEntity>().HasData(
new ActivityEntity { IdActivity = 1, Type = "Running", Date = new DateOnly(2023, 01, 10), StartTime = new TimeOnly(13, 00, 34), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 2, Type = "Cycling", Date = new DateOnly(2023, 01, 25), StartTime = new TimeOnly(13, 04, 34), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 3, Type = "Swimming", Date = new DateOnly(2023, 12, 10), StartTime = new TimeOnly(13, 30, 34), EndTime = new TimeOnly(15, 02, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 4, Type = "Walking", Date = new DateOnly(2024, 01, 02), StartTime = new TimeOnly(15, 00, 00), EndTime = new TimeOnly(16, 01, 55), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 5, Type = "Hiking", Date = new DateOnly(2024, 01, 12), StartTime = new TimeOnly(07, 45, 34), EndTime = new TimeOnly(09, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 6, Type = "Climbing", Date = new DateOnly(2024, 01, 27), StartTime = new TimeOnly(13, 30, 01), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 7, Type = "Yoga", Date = new DateOnly(2024, 02, 22), StartTime = new TimeOnly(22, 00, 34), EndTime = new TimeOnly(23, 50, 58), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }
);
// Seed data for activities
modelBuilder.Entity<ActivityEntity>().HasData(
new ActivityEntity { IdActivity = 1, Type = "Running", Date = new DateOnly(2023, 01, 10), StartTime = new TimeOnly(13, 00, 34), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 2, Type = "Cycling", Date = new DateOnly(2023, 01, 25), StartTime = new TimeOnly(13, 04, 34), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 3, Type = "Swimming", Date = new DateOnly(2023, 12, 10), StartTime = new TimeOnly(13, 30, 34), EndTime = new TimeOnly(15, 02, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 4, Type = "Walking", Date = new DateOnly(2024, 01, 02), StartTime = new TimeOnly(15, 00, 00), EndTime = new TimeOnly(16, 01, 55), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 5, Type = "Hiking", Date = new DateOnly(2024, 01, 12), StartTime = new TimeOnly(07, 45, 34), EndTime = new TimeOnly(09, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 6, Type = "Climbing", Date = new DateOnly(2024, 01, 27), StartTime = new TimeOnly(13, 30, 01), EndTime = new TimeOnly(14, 00, 22), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false },
new ActivityEntity { IdActivity = 7, Type = "Yoga", Date = new DateOnly(2024, 02, 22), StartTime = new TimeOnly(22, 00, 34), EndTime = new TimeOnly(23, 50, 58), EffortFelt = 5, Variability = 0.5f, Variance = 0.5f, StandardDeviation = 0.5f, Average = 0.5f, Maximum = 0, Minimum = 0, AverageTemperature = 20.0f, HasAutoPause = false }
);
}
}
}

@ -1,29 +1,48 @@
using DbContextLib;
//-----------------------------------------------------------------------
// FILENAME: AthleteStubbedContext.cs
// PROJECT: StubbedContextLib
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class AthleteStubbedContext : ActivityStubbedContext
namespace StubbedContextLib
{
public AthleteStubbedContext()
:base()
{ }
/// <summary>
/// Represents the stubbed context for athletes.
/// </summary>
public class AthleteStubbedContext : ActivityStubbedContext
{
/// <summary>
/// Initializes a new instance of the <see cref="AthleteStubbedContext"/> class.
/// </summary>
public AthleteStubbedContext() : base() { }
public AthleteStubbedContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
/// <summary>
/// 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) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
/// <summary>
/// Configures the model for the athlete stubbed context.
/// </summary>
/// <param name="modelBuilder">The model builder instance.</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<AthleteEntity>().HasData(
new AthleteEntity { IdAthlete = 1, Username = "Doe", LastName = "Doe", FirstName = "John", Email = "john.doe@example.com", Password = "password123", Sexe = "M", Lenght = 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", Lenght = 1.65, Weight = 60, DateOfBirth = new DateOnly(1995, 01, 01), IsCoach = false },
new AthleteEntity { IdAthlete = 3, Username = "Martin", LastName = "Martin", FirstName = "Paul", Email = "paul.martin@example.com", Password = "super789", Sexe = "M", Lenght = 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", Lenght = 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", Lenght = 2.0, Weight = 90, DateOfBirth = new DateOnly(1991, 01, 01), IsCoach = false }
);
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 },
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 }
);
}
}
}

@ -1,29 +1,48 @@
//-----------------------------------------------------------------------
// FILENAME: DataSourceStubbedContext.cs
// PROJECT: StubbedContextLib
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class DataSourceStubbedContext : AthleteStubbedContext
namespace StubbedContextLib
{
public DataSourceStubbedContext()
:base()
{ }
/// <summary>
/// Represents the stubbed context for data sources.
/// </summary>
public class DataSourceStubbedContext : AthleteStubbedContext
{
/// <summary>
/// Initializes a new instance of the <see cref="DataSourceStubbedContext"/> class.
/// </summary>
public DataSourceStubbedContext() : base() { }
public DataSourceStubbedContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
/// <summary>
/// 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) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
/// <summary>
/// Configures the model for the data source stubbed context.
/// </summary>
/// <param name="modelBuilder">The model builder instance.</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<DataSourceEntity>().HasData(
new DataSourceEntity { IdSource = 1, Type = "Smartwatch", Modele = "Garmin", Precision = 0.5f },
new DataSourceEntity { IdSource = 2, Type = "Smartwatch", Modele = "Polar", Precision = 0.5f },
new DataSourceEntity { IdSource = 3, Type = "Smartwatch", Modele = "Suunto", Precision = 0.5f },
new DataSourceEntity { IdSource = 4, Type = "Smartwatch", Modele = "Fitbit", Precision = 0.5f },
new DataSourceEntity { IdSource = 5, Type = "Smartwatch", Modele = "Apple Watch", Precision = 0.5f }
);
modelBuilder.Entity<DataSourceEntity>().HasData(
new DataSourceEntity { IdSource = 1, Type = "Smartwatch", Model = "Garmin", Precision = 0.5f },
new DataSourceEntity { IdSource = 2, Type = "Smartwatch", Model = "Polar", Precision = 0.5f },
new DataSourceEntity { IdSource = 3, Type = "Smartwatch", Model = "Suunto", Precision = 0.5f },
new DataSourceEntity { IdSource = 4, Type = "Smartwatch", Model = "Fitbit", Precision = 0.5f },
new DataSourceEntity { IdSource = 5, Type = "Smartwatch", Model = "Apple Watch", Precision = 0.5f }
);
}
}
}

@ -1,29 +1,48 @@
//-----------------------------------------------------------------------
// FILENAME: HeartRateStubbedContext.cs
// PROJECT: StubbedContextLib
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class HeartRateStubbedContext : DataSourceStubbedContext
namespace StubbedContextLib
{
public HeartRateStubbedContext()
:base()
{ }
/// <summary>
/// Represents the stubbed context for heart rate entities.
/// </summary>
public class HeartRateStubbedContext : DataSourceStubbedContext
{
/// <summary>
/// Initializes a new instance of the <see cref="HeartRateStubbedContext"/> class.
/// </summary>
public HeartRateStubbedContext() : base() { }
public HeartRateStubbedContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
/// <summary>
/// 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) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
/// <summary>
/// Configures the model for the heart rate stubbed context.
/// </summary>
/// <param name="modelBuilder">The model builder instance.</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<HeartRateEntity>().HasData(
new HeartRateEntity { IdHeartRate = 1, Altitude = 0.0, Time = new TimeOnly(13, 00, 30), Temperature = 20.0f, Bpm = 60, Longitude = 35f, Latitude = 66f },
new HeartRateEntity { IdHeartRate = 2, Altitude = 10, Time = new TimeOnly(13, 00, 31), Temperature = 20.5f, Bpm = 65, Longitude = 35f, Latitude = 67f },
new HeartRateEntity { IdHeartRate = 3, Altitude = 11, Time = new TimeOnly(13, 00, 32), Temperature = 20.0f, Bpm = 71, Longitude = 36f, Latitude = 66f },
new HeartRateEntity { IdHeartRate = 4, Altitude = 12, Time = new TimeOnly(13, 00, 33), Temperature = 20.5f, Bpm = 75, Longitude = 36f, Latitude = 67f },
new HeartRateEntity { IdHeartRate = 5, Altitude = 13, Time = new TimeOnly(13, 00, 34), Temperature = 20.0f, Bpm = 80, Longitude = 37f, Latitude = 66f }
);
modelBuilder.Entity<HeartRateEntity>().HasData(
new HeartRateEntity { IdHeartRate = 1, Altitude = 0.0, Time = new TimeOnly(13, 00, 30), Temperature = 20.0f, Bpm = 60, Longitude = 35f, Latitude = 66f },
new HeartRateEntity { IdHeartRate = 2, Altitude = 10, Time = new TimeOnly(13, 00, 31), Temperature = 20.5f, Bpm = 65, Longitude = 35f, Latitude = 67f },
new HeartRateEntity { IdHeartRate = 3, Altitude = 11, Time = new TimeOnly(13, 00, 32), Temperature = 20.0f, Bpm = 71, Longitude = 36f, Latitude = 66f },
new HeartRateEntity { IdHeartRate = 4, Altitude = 12, Time = new TimeOnly(13, 00, 33), Temperature = 20.5f, Bpm = 75, Longitude = 36f, Latitude = 67f },
new HeartRateEntity { IdHeartRate = 5, Altitude = 13, Time = new TimeOnly(13, 00, 34), Temperature = 20.0f, Bpm = 80, Longitude = 37f, Latitude = 66f }
);
}
}
}

@ -11,7 +11,7 @@ using StubbedContextLib;
namespace StubbedContextLib.Migrations
{
[DbContext(typeof(TrainingStubbedContext))]
[Migration("20240222102358_MyMigrations")]
[Migration("20240222104952_MyMigrations")]
partial class MyMigrations
{
/// <inheritdoc />
@ -220,7 +220,7 @@ namespace StubbedContextLib.Migrations
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double>("Lenght")
b.Property<double>("Length")
.HasColumnType("REAL");
b.Property<string>("Password")
@ -253,7 +253,7 @@ namespace StubbedContextLib.Migrations
FirstName = "John",
IsCoach = true,
LastName = "Doe",
Lenght = 1.8,
Length = 1.8,
Password = "password123",
Sexe = "M",
Username = "Doe",
@ -267,7 +267,7 @@ namespace StubbedContextLib.Migrations
FirstName = "Jane",
IsCoach = false,
LastName = "Smith",
Lenght = 1.6499999999999999,
Length = 1.6499999999999999,
Password = "secure456",
Sexe = "F",
Username = "Smith",
@ -281,7 +281,7 @@ namespace StubbedContextLib.Migrations
FirstName = "Paul",
IsCoach = true,
LastName = "Martin",
Lenght = 1.75,
Length = 1.75,
Password = "super789",
Sexe = "M",
Username = "Martin",
@ -295,7 +295,7 @@ namespace StubbedContextLib.Migrations
FirstName = "Anna",
IsCoach = false,
LastName = "Brown",
Lenght = 1.7,
Length = 1.7,
Password = "test000",
Sexe = "F",
Username = "Brown",
@ -309,7 +309,7 @@ namespace StubbedContextLib.Migrations
FirstName = "Bruce",
IsCoach = false,
LastName = "Lee",
Lenght = 2.0,
Length = 2.0,
Password = "hello321",
Sexe = "M",
Username = "Lee",
@ -323,7 +323,7 @@ namespace StubbedContextLib.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Modele")
b.Property<string>("Model")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
@ -344,35 +344,35 @@ namespace StubbedContextLib.Migrations
new
{
IdSource = 1,
Modele = "Garmin",
Model = "Garmin",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 2,
Modele = "Polar",
Model = "Polar",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 3,
Modele = "Suunto",
Model = "Suunto",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 4,
Modele = "Fitbit",
Model = "Fitbit",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 5,
Modele = "Apple Watch",
Model = "Apple Watch",
Precision = 0.5f,
Type = "Smartwatch"
});

@ -49,7 +49,7 @@ namespace StubbedContextLib.Migrations
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),
Lenght = table.Column<double>(type: "REAL", 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),
@ -67,7 +67,7 @@ namespace StubbedContextLib.Migrations
IdSource = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Type = table.Column<string>(type: "TEXT", maxLength: 100, nullable: false),
Modele = 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 =>
@ -159,7 +159,7 @@ namespace StubbedContextLib.Migrations
migrationBuilder.InsertData(
table: "Athlete",
columns: new[] { "IdAthlete", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Lenght", "Password", "Sexe", "Username", "Weight" },
columns: new[] { "IdAthlete", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Length", "Password", "Sexe", "Username", "Weight" },
values: new object[,]
{
{ 1, new DateOnly(1990, 1, 1), "john.doe@example.com", "John", true, "Doe", 1.8, "password123", "M", "Doe", 75f },
@ -171,7 +171,7 @@ namespace StubbedContextLib.Migrations
migrationBuilder.InsertData(
table: "DataSource",
columns: new[] { "IdSource", "Modele", "Precision", "Type" },
columns: new[] { "IdSource", "Model", "Precision", "Type" },
values: new object[,]
{
{ 1, "Garmin", 0.5f, "Smartwatch" },

@ -217,7 +217,7 @@ namespace StubbedContextLib.Migrations
.HasMaxLength(100)
.HasColumnType("TEXT");
b.Property<double>("Lenght")
b.Property<double>("Length")
.HasColumnType("REAL");
b.Property<string>("Password")
@ -250,7 +250,7 @@ namespace StubbedContextLib.Migrations
FirstName = "John",
IsCoach = true,
LastName = "Doe",
Lenght = 1.8,
Length = 1.8,
Password = "password123",
Sexe = "M",
Username = "Doe",
@ -264,7 +264,7 @@ namespace StubbedContextLib.Migrations
FirstName = "Jane",
IsCoach = false,
LastName = "Smith",
Lenght = 1.6499999999999999,
Length = 1.6499999999999999,
Password = "secure456",
Sexe = "F",
Username = "Smith",
@ -278,7 +278,7 @@ namespace StubbedContextLib.Migrations
FirstName = "Paul",
IsCoach = true,
LastName = "Martin",
Lenght = 1.75,
Length = 1.75,
Password = "super789",
Sexe = "M",
Username = "Martin",
@ -292,7 +292,7 @@ namespace StubbedContextLib.Migrations
FirstName = "Anna",
IsCoach = false,
LastName = "Brown",
Lenght = 1.7,
Length = 1.7,
Password = "test000",
Sexe = "F",
Username = "Brown",
@ -306,7 +306,7 @@ namespace StubbedContextLib.Migrations
FirstName = "Bruce",
IsCoach = false,
LastName = "Lee",
Lenght = 2.0,
Length = 2.0,
Password = "hello321",
Sexe = "M",
Username = "Lee",
@ -320,7 +320,7 @@ namespace StubbedContextLib.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Modele")
b.Property<string>("Model")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("TEXT");
@ -341,35 +341,35 @@ namespace StubbedContextLib.Migrations
new
{
IdSource = 1,
Modele = "Garmin",
Model = "Garmin",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 2,
Modele = "Polar",
Model = "Polar",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 3,
Modele = "Suunto",
Model = "Suunto",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 4,
Modele = "Fitbit",
Model = "Fitbit",
Precision = 0.5f,
Type = "Smartwatch"
},
new
{
IdSource = 5,
Modele = "Apple Watch",
Model = "Apple Watch",
Precision = 0.5f,
Type = "Smartwatch"
});

@ -1,29 +1,48 @@
//-----------------------------------------------------------------------
// FILENAME: NotificationStubbedContext.cs
// PROJECT: StubbedContextLib
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class NotificationStubbedContext : HeartRateStubbedContext
namespace StubbedContextLib
{
public NotificationStubbedContext()
:base()
{ }
/// <summary>
/// Represents the stubbed context for notification entities.
/// </summary>
public class NotificationStubbedContext : HeartRateStubbedContext
{
/// <summary>
/// Initializes a new instance of the <see cref="NotificationStubbedContext"/> class.
/// </summary>
public NotificationStubbedContext() : base() { }
public NotificationStubbedContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
/// <summary>
/// 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) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
/// <summary>
/// Configures the model for the notification stubbed context.
/// </summary>
/// <param name="modelBuilder">The model builder instance.</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<NotificationEntity>().HasData(
new NotificationEntity { IdNotif = 1, Message = "You have a new activity to check", Date = new DateTime(2023, 12, 25, 13, 00, 40), Statut = true, Urgence = "A" },
new NotificationEntity { IdNotif = 2, Message = "You have a new athlete to check", Date = new DateTime(2023, 12, 26, 13, 10, 40), Statut = false, Urgence = "3" },
new NotificationEntity { IdNotif = 3, Message = "You have a new heart rate to check", Date = new DateTime(2023, 12, 26, 16, 10, 04), Statut = true, Urgence = "2" },
new NotificationEntity { IdNotif = 4, Message = "You have a new data source to check", Date = new DateTime(2024, 01, 12, 09, 30, 50), Statut = false, Urgence = "1" },
new NotificationEntity { IdNotif = 5, Message = "You have a new notification to check", Date = new DateTime(2024, 02, 22, 12, 10, 00), Statut = true, Urgence = "3" }
);
modelBuilder.Entity<NotificationEntity>().HasData(
new NotificationEntity { IdNotif = 1, Message = "You have a new activity to check", Date = new DateTime(2023, 12, 25, 13, 00, 40), Statut = true, Urgence = "A" },
new NotificationEntity { IdNotif = 2, Message = "You have a new athlete to check", Date = new DateTime(2023, 12, 26, 13, 10, 40), Statut = false, Urgence = "3" },
new NotificationEntity { IdNotif = 3, Message = "You have a new heart rate to check", Date = new DateTime(2023, 12, 26, 16, 10, 04), Statut = true, Urgence = "2" },
new NotificationEntity { IdNotif = 4, Message = "You have a new data source to check", Date = new DateTime(2024, 01, 12, 09, 30, 50), Statut = false, Urgence = "1" },
new NotificationEntity { IdNotif = 5, Message = "You have a new notification to check", Date = new DateTime(2024, 02, 22, 12, 10, 00), Statut = true, Urgence = "3" }
);
}
}
}

@ -1,29 +1,48 @@
//-----------------------------------------------------------------------
// FILENAME: StatisticStubbedContext.cs
// PROJECT: StubbedContextLib
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class StatisticStubbedContext : NotificationStubbedContext
namespace StubbedContextLib
{
public StatisticStubbedContext()
:base()
{ }
/// <summary>
/// Represents the stubbed context for statistic entities.
/// </summary>
public class StatisticStubbedContext : NotificationStubbedContext
{
/// <summary>
/// Initializes a new instance of the <see cref="StatisticStubbedContext"/> class.
/// </summary>
public StatisticStubbedContext() : base() { }
public StatisticStubbedContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
/// <summary>
/// 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) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
/// <summary>
/// Configures the model for the statistic stubbed context.
/// </summary>
/// <param name="modelBuilder">The model builder instance.</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<StatisticEntity>().HasData(
new StatisticEntity { IdStatistic = 1, Weight = 75, AverageHeartRate = 120, MaximumHeartRate = 180, AverageCaloriesBurned = 500, Date = new DateOnly(2021, 12, 12) },
new StatisticEntity { IdStatistic = 2, Weight = 60, AverageHeartRate = 130, MaximumHeartRate = 190, AverageCaloriesBurned = 600, Date = new DateOnly(2021, 01, 11) },
new StatisticEntity { IdStatistic = 3, Weight = 68, AverageHeartRate = 125, MaximumHeartRate = 185, AverageCaloriesBurned = 550, Date = new DateOnly(2022, 12, 30) },
new StatisticEntity { IdStatistic = 4, Weight = 58, AverageHeartRate = 135, MaximumHeartRate = 195, AverageCaloriesBurned = 650, Date = new DateOnly(2023, 02, 20) },
new StatisticEntity { IdStatistic = 5, Weight = 90, AverageHeartRate = 110, MaximumHeartRate = 170, AverageCaloriesBurned = 450, Date = new DateOnly(2024, 01, 10) }
);
modelBuilder.Entity<StatisticEntity>().HasData(
new StatisticEntity { IdStatistic = 1, Weight = 75, AverageHeartRate = 120, MaximumHeartRate = 180, AverageCaloriesBurned = 500, Date = new DateOnly(2021, 12, 12) },
new StatisticEntity { IdStatistic = 2, Weight = 60, AverageHeartRate = 130, MaximumHeartRate = 190, AverageCaloriesBurned = 600, Date = new DateOnly(2021, 01, 11) },
new StatisticEntity { IdStatistic = 3, Weight = 68, AverageHeartRate = 125, MaximumHeartRate = 185, AverageCaloriesBurned = 550, Date = new DateOnly(2022, 12, 30) },
new StatisticEntity { IdStatistic = 4, Weight = 58, AverageHeartRate = 135, MaximumHeartRate = 195, AverageCaloriesBurned = 650, Date = new DateOnly(2023, 02, 20) },
new StatisticEntity { IdStatistic = 5, Weight = 90, AverageHeartRate = 110, MaximumHeartRate = 170, AverageCaloriesBurned = 450, Date = new DateOnly(2024, 01, 10) }
);
}
}
}

@ -1,29 +1,48 @@
//-----------------------------------------------------------------------
// FILENAME: TrainingStubbedContext.cs
// PROJECT: StubbedContextLib
// SOLUTION: HeartTrack
// DATE CREATED: 22/02/2024
// AUTHOR: Antoine PEREDERII
//-----------------------------------------------------------------------
using DbContextLib;
using Entities;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib;
public class TrainingStubbedContext : StatisticStubbedContext
namespace StubbedContextLib
{
public TrainingStubbedContext()
:base()
{ }
/// <summary>
/// Represents the stubbed context for training entities.
/// </summary>
public class TrainingStubbedContext : StatisticStubbedContext
{
/// <summary>
/// Initializes a new instance of the <see cref="TrainingStubbedContext"/> class.
/// </summary>
public TrainingStubbedContext() : base() { }
public TrainingStubbedContext(DbContextOptions<LibraryContext> options)
:base(options)
{ }
/// <summary>
/// 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) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
/// <summary>
/// Configures the model for the training stubbed context.
/// </summary>
/// <param name="modelBuilder">The model builder instance.</param>
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<TrainingEntity>().HasData(
new TrainingEntity { IdTraining = 1, Date = new DateOnly(2024, 01, 19), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" },
new TrainingEntity { IdTraining = 2, Date = new DateOnly(2024, 02, 20), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f },
new TrainingEntity { IdTraining = 3, Date = new DateOnly(2024, 02, 21), Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" },
new TrainingEntity { IdTraining = 4, Date = new DateOnly(2024, 02, 22), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" },
new TrainingEntity { IdTraining = 5, Date = new DateOnly(2024, 02, 23), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f }
);
modelBuilder.Entity<TrainingEntity>().HasData(
new TrainingEntity { IdTraining = 1, Date = new DateOnly(2024, 01, 19), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" },
new TrainingEntity { IdTraining = 2, Date = new DateOnly(2024, 02, 20), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f },
new TrainingEntity { IdTraining = 3, Date = new DateOnly(2024, 02, 21), Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" },
new TrainingEntity { IdTraining = 4, Date = new DateOnly(2024, 02, 22), Description = "Running", Latitude = 48.8566f, Longitude = 2.3522f, FeedBack = "Good" },
new TrainingEntity { IdTraining = 5, Date = new DateOnly(2024, 02, 23), Description = "Cycling", Latitude = 48.8566f, Longitude = 2.3522f }
);
}
}
}

@ -12,33 +12,33 @@ class Program
try {
using (LibraryContext db = new TrainingStubbedContext())
{
// AthletesTests(db);
AthletesTests(db);
// ActivityTests(db);
ActivityTests(db);
// DataSourceTests(db);
DataSourceTests(db);
// HeartRateTests(db);
HeartRateTests(db);
// NotificationTests(db);
NotificationTests(db);
// StatisticTests(db);
// TrainingTests(db);
AddUpdateDeleteAthlete(db);
// AddUpdateDeleteAthlete(db);
AddUpdateDeleteActivity(db);
// AddUpdateDeleteActivity(db);
AddUpdateDeleteDataSource(db);
// AddUpdateDeleteDataSource(db);
AddUpdateDeleteHeartRate(db);
// AddUpdateDeleteHeartRate(db);
AddUpdateDeleteNotification(db);
// AddUpdateDeleteNotification(db);
AddUpdateDeleteStatistic(db);
// AddUpdateDeleteStatistic(db);
AddUpdateDeleteTraining(db);
// AddUpdateDeleteTraining(db);
}
}
catch (Exception ex)
@ -47,7 +47,6 @@ class Program
}
}
static void AthletesTests(LibraryContext db)
{
Console.WriteLine("Accès à tous les athletes :");
@ -58,7 +57,7 @@ class Program
foreach (var athlete in db.AthletesSet)
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -67,7 +66,7 @@ class Program
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.IdAthlete == 2))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -76,7 +75,7 @@ class Program
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.Username == "Doe"))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -85,7 +84,7 @@ class Program
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.Sexe == "F"))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -94,7 +93,7 @@ class Program
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.Email == "bruce.lee@example.com"))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -103,26 +102,25 @@ class Program
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.Weight == 90))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'athlete de taille '1.80' :");
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.Lenght == 1.80))
foreach (var athlete in db.AthletesSet.Where(a => a.Length == 1.80))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
// ! A revoir !!
Console.WriteLine("Accès à l'athlete de date de naissance '01/01/2000' :");
Console.WriteLine("Accès à l'athlete de date de naissance '01/01/1990' :");
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.DateOfBirth == new DateOnly()))
foreach (var athlete in db.AthletesSet.Where(a => a.DateOfBirth == new DateOnly(1990, 01, 01)))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -131,7 +129,7 @@ class Program
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.LastName == "Martin"))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -140,7 +138,7 @@ class Program
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.FirstName == "Anna"))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -149,7 +147,7 @@ class Program
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.LastName == "Brown" && a.FirstName == "Anna"))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -158,7 +156,7 @@ class Program
Console.WriteLine("---------------------------------");
foreach (var athlete in db.AthletesSet.Where(a => a.IsCoach == true))
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
Console.WriteLine("---------------------------------\n");
@ -198,35 +196,85 @@ class Program
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'activité de date '01/01/2022' :");
Console.WriteLine("Accès à l'activité de date '10/01/2023' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateOnly(2023, 01, 10)))
{
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 temps '13:00:34' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34)))
{
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 temps '13:00:34' et de type 'Running' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && 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 temps '13:00:34' et de type 'Running' et de date '10/01/2023' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10)))
{
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 temps '13:00:34' et de type 'Running' et de date '10/01/2023' et de temps de fin '14:00:22' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateOnly(2000,01, 01)))
foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10) && a.EndTime == new TimeOnly(14, 00, 22)))
{
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("Accès à l'activité de temps '13:00:34' et de type 'Running' et de date '10/01/2023' et de temps de fin '14:00:22' et de ressenti d'effort '5' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.Date == new DateOnly(2022, 01, 01) && a.Type == "Running"))
foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10) && a.EndTime == new TimeOnly(14, 00, 22) && a.EffortFelt == 5))
{
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("---------------------------------");
Console.WriteLine("Accès à l'activité de temps '13:00:34' et de type 'Running' et de date '10/01/2023' et de temps de fin '14:00:22' et de ressenti d'effort '5' et de variabilité '0.5' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10) && a.EndTime == new TimeOnly(14, 00, 22) && a.EffortFelt == 5 && a.Variability == 0.5F))
{
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}");
}
// 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");
// Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'activité de temps '13:00:34' et de type 'Running' et de date '10/01/2023' et de temps de fin '14:00:22' et de ressenti d'effort '5' et de variabilité '0.5' et de variance '0.5' :");
Console.WriteLine("---------------------------------");
foreach (var activity in db.ActivitiesSet.Where(a => a.StartTime == new TimeOnly(13, 00, 34) && a.Type == "Running" && a.Date == new DateOnly(2023, 01, 10) && a.EndTime == new TimeOnly(14, 00, 22) && a.EffortFelt == 5 && a.Variability == 0.5F && a.Variance == 0.5F))
{
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)
@ -238,7 +286,7 @@ class Program
foreach (var dataSource in db.DataSourcesSet)
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}");
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}");
}
Console.WriteLine("---------------------------------\n");
@ -248,21 +296,50 @@ class Program
foreach (var dataSource in db.DataSourcesSet.Where(d => d.IdSource == 2))
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}");
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la source de données de type 'Smartwatch' :");
Console.WriteLine("---------------------------------");
foreach (var dataSource in db.DataSourcesSet.Where(d => d.Type == "Smartwatch"))
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la source de données de modèle 'Garmin' :");
Console.WriteLine("---------------------------------");
foreach (var dataSource in db.DataSourcesSet.Where(d => d.Model == "Garmin"))
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la source de données de type 'Polar' :");
Console.WriteLine("Accès à la source de données de précision '0.5' :");
Console.WriteLine("---------------------------------");
foreach (var dataSource in db.DataSourcesSet.Where(d => d.Type == "Polar"))
foreach (var dataSource in db.DataSourcesSet.Where(d => d.Precision == 0.5f))
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}");
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la source de données de type 'Smartwatch' et de modèle 'Garmin' :");
Console.WriteLine("---------------------------------");
foreach (var dataSource in db.DataSourcesSet.Where(d => d.Type == "Smartwatch" && d.Model == "Garmin"))
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}");
}
Console.WriteLine("---------------------------------\n");
}
static void HeartRateTests(LibraryContext db)
@ -288,6 +365,66 @@ class Program
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la fréquence cardiaque d'altitude '10' :");
Console.WriteLine("---------------------------------");
foreach (var heartRate in db.HeartRatesSet.Where(h => h.Altitude == 10))
{
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 de température '20.5' :");
Console.WriteLine("---------------------------------");
foreach (var heartRate in db.HeartRatesSet.Where(h => h.Temperature == 20.5f))
{
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 de bpm '65' :");
Console.WriteLine("---------------------------------");
foreach (var heartRate in db.HeartRatesSet.Where(h => h.Bpm == 65))
{
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 de longitude '35' :");
Console.WriteLine("---------------------------------");
foreach (var heartRate in db.HeartRatesSet.Where(h => h.Longitude == 35))
{
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 de latitude '66' :");
Console.WriteLine("---------------------------------");
foreach (var heartRate in db.HeartRatesSet.Where(h => h.Latitude == 66))
{
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'altitude '10' et de température '20.5' :");
Console.WriteLine("---------------------------------");
foreach (var heartRate in db.HeartRatesSet.Where(h => h.Altitude == 10 && h.Temperature == 20.5f))
{
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)
@ -313,6 +450,56 @@ class Program
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la notification de message 'You have a new activity to check' :");
Console.WriteLine("---------------------------------");
foreach (var notification in db.NotificationsSet.Where(n => n.Message == "You have a new activity to check"))
{
Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la notification de date '25/12/2023' :");
Console.WriteLine("---------------------------------");
foreach (var notification in db.NotificationsSet.Where(n => n.Date == new DateTime(2023, 12, 25, 13, 00, 40)))
{
Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la notification de statut 'true' :");
Console.WriteLine("---------------------------------");
foreach (var notification in db.NotificationsSet.Where(n => n.Statut == true))
{
Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la notification d'urgence 'A' :");
Console.WriteLine("---------------------------------");
foreach (var notification in db.NotificationsSet.Where(n => n.Urgence == "A"))
{
Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la notification de message 'You have a new activity to check' et de date '25/12/2023' :");
Console.WriteLine("---------------------------------");
foreach (var notification in db.NotificationsSet.Where(n => n.Message == "You have a new activity to check" && n.Date == new DateTime(2023, 12, 25, 13, 00, 40)))
{
Console.WriteLine($"\t{notification.IdNotif} - {notification.Message}, {notification.Date}, {notification.Statut}, {notification.Urgence}");
}
Console.WriteLine("---------------------------------\n");
}
static void StatisticTests(LibraryContext db)
@ -338,6 +525,116 @@ class Program
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de poids '60' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de fréquence cardiaque moyenne '130' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.AverageHeartRate == 130))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de fréquence cardiaque maximale '190' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.MaximumHeartRate == 190))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de calories brûlées en moyenne '550' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.AverageCaloriesBurned == 550))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de date '30/12/2022' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.Date == new DateOnly(2022, 12, 30)))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' et de calories brûlées en moyenne '600' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190 && s.AverageCaloriesBurned == 600))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' et de calories brûlées en moyenne '600' et de date '11/01/2021' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190 && s.AverageCaloriesBurned == 600 && s.Date == new DateOnly(2021, 01, 11)))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' et de calories brûlées en moyenne '600' et de date '11/01/2021' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190 && s.AverageCaloriesBurned == 600 && s.Date == new DateOnly(2021, 01, 11)))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à la statistique de poids '60' et de fréquence cardiaque moyenne '130' et de fréquence cardiaque maximale '190' et de calories brûlées en moyenne '600' et de date '11/01/2021' :");
Console.WriteLine("---------------------------------");
foreach (var statistic in db.StatisticsSet.Where(s => s.Weight == 60 && s.AverageHeartRate == 130 && s.MaximumHeartRate == 190 && s.AverageCaloriesBurned == 600 && s.Date == new DateOnly(2021, 01, 11)))
{
Console.WriteLine($"\t{statistic.IdStatistic} - {statistic.Weight}, {statistic.AverageHeartRate}, {statistic.MaximumHeartRate}, {statistic.AverageCaloriesBurned}, {statistic.Date}");
}
Console.WriteLine("---------------------------------\n");
}
static void TrainingTests(LibraryContext db)
{
@ -362,6 +659,96 @@ class Program
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement de date '21/02/2024' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 02, 21)))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement de description 'Running' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.Description == "Running"))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement de latitude '48.8566f' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.Latitude == 48.8566f))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement de longitude '2.3522f' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.Longitude == 2.3522f))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement de feedback 'Good' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.FeedBack == "Good"))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement de date '20/02/2024' et de description 'Cycling' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 02, 20) && t.Description == "Cycling"))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement de date '22/02/2024' et de description 'Running' et de latitude '48.8566f' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 02, 22) && t.Description == "Running" && t.Latitude == 48.8566f))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement de date '23/02/2024' et de description 'Cycling' et de latitude '48.8566f' et de longitude '2.3522f' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 02, 23) && t.Description == "Cycling" && t.Latitude == 48.8566f && t.Longitude == 2.3522f))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
Console.WriteLine("Accès à l'entrainement de date '19/01/2024' et de description 'Running' et de latitude '48.8566f' et de longitude '2.3522f' et de feedback 'Good' :");
Console.WriteLine("---------------------------------");
foreach (var training in db.TrainingsSet.Where(t => t.Date == new DateOnly(2024, 01, 19) && t.Description == "Running" && t.Latitude == 48.8566f && t.Longitude == 2.3522f && t.FeedBack == "Good"))
{
Console.WriteLine($"\t{training.IdTraining} - {training.Date}, {training.Description}, {training.Latitude}, {training.Longitude}, {training.FeedBack}");
}
Console.WriteLine("---------------------------------\n");
}
static void AddUpdateDeleteAthlete(LibraryContext db)
@ -369,7 +756,7 @@ class Program
Console.WriteLine("Test d'ajout, de modification et de suppression des athletes :");
// Ajout d'un nouveau livre
var newAthlete = new AthleteEntity { Username = "Doe", LastName = "Doe", FirstName = "John", Email = "essaie.example.com", Password = "TheNewPassword", Sexe = "M", Lenght = 1.80, Weight = 90, DateOfBirth = new DateOnly(2024, 02, 22), IsCoach = false };
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 };
db.AthletesSet.Add(newAthlete);
db.SaveChanges();
@ -377,7 +764,7 @@ class Program
Console.WriteLine("Athlete après ajout :");
foreach (var athlete in db.AthletesSet)
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
// Modification du titre du nouveau livre
@ -388,7 +775,7 @@ class Program
Console.WriteLine("Livres après modification :");
foreach (var athlete in db.AthletesSet)
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
// Suppression du nouveau livre
@ -399,7 +786,7 @@ class Program
Console.WriteLine("Livres après suppression :");
foreach (var athlete in db.AthletesSet)
{
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Lenght}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
Console.WriteLine($"\t{athlete.IdAthlete} - {athlete.Username}, {athlete.LastName}, {athlete.FirstName}, {athlete.Email}, {athlete.Sexe}, {athlete.Length}, {athlete.Weight}, {athlete.DateOfBirth}, {athlete.IsCoach}");
}
}
@ -441,14 +828,14 @@ class Program
{
Console.WriteLine("Test d'ajout, de modification et de suppression des sources de données :");
var newDataSource = new DataSourceEntity { Type = "Polar", Modele = "Polar Vantage V2", Precision = 0.5F };
var newDataSource = new DataSourceEntity { Type = "Polar", Model = "Polar Vantage V2", Precision = 0.5F };
db.DataSourcesSet.Add(newDataSource);
db.SaveChanges();
Console.WriteLine("Source de données après ajout :");
foreach (var dataSource in db.DataSourcesSet)
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}");
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}");
}
newDataSource.Type = "Garmin";
@ -457,7 +844,7 @@ class Program
Console.WriteLine("Source de données après modification :");
foreach (var dataSource in db.DataSourcesSet)
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}");
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}");
}
db.DataSourcesSet.Remove(newDataSource);
@ -466,7 +853,7 @@ class Program
Console.WriteLine("Source de données après suppression :");
foreach (var dataSource in db.DataSourcesSet)
{
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Modele}, {dataSource.Precision}");
Console.WriteLine($"\t{dataSource.IdSource} - {dataSource.Type}, {dataSource.Model}, {dataSource.Precision}");
}
}

Loading…
Cancel
Save