From adfab882fee3f411944188fe4fdbc548bc973821 Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 13 Mar 2024 17:59:08 +0100 Subject: [PATCH 01/74] push --- src/ApiMappeur/AthleteMappeur.cs | 95 +++++++++--- src/DbContextLib/DbContextLib.csproj | 11 +- src/DbContextLib/Identity/AuthDbContext.cs | 25 ++++ src/Dto/ActivityFitFileDto.cs | 9 ++ src/Entities/AthleteEntity.cs | 33 +++-- src/Entities/Entities.csproj | 6 + src/HeartTrackAPI/AppBootstrap.cs | 137 ++++++++++++++++++ .../Controllers/ActivityController.cs | 17 +++ .../Controllers/UsersController.cs | 55 ++++++- src/HeartTrackAPI/HeartTrackAPI.csproj | 5 + src/HeartTrackAPI/Program.cs | 30 ++-- src/HeartTrackAPI/Utils/SwaggerOptions.cs | 64 ++++++++ src/HeartTrackAPI/appsettings.json | 5 +- src/Model/Manager/ActivityManager.cs | 9 ++ .../Manager/Contract/IActivityManager.cs | 7 + src/Model/Manager/UserManager.cs | 6 + src/Model/Model.csproj | 11 ++ src/Model/Repository/IUserRepository.cs | 2 + src/Model/Service/EmailSender.cs | 31 ++++ src/Model/User.cs | 4 +- src/Model2Entities/DbDataManager.cs | 1 - src/Model2Entities/UserRepository.cs | 5 + src/StubAPI/AthleteService.cs | 17 +++ 23 files changed, 526 insertions(+), 59 deletions(-) create mode 100644 src/DbContextLib/Identity/AuthDbContext.cs create mode 100644 src/Dto/ActivityFitFileDto.cs create mode 100644 src/HeartTrackAPI/AppBootstrap.cs create mode 100644 src/HeartTrackAPI/Utils/SwaggerOptions.cs create mode 100644 src/Model/Manager/ActivityManager.cs create mode 100644 src/Model/Manager/Contract/IActivityManager.cs create mode 100644 src/Model/Manager/UserManager.cs create mode 100644 src/Model/Service/EmailSender.cs diff --git a/src/ApiMappeur/AthleteMappeur.cs b/src/ApiMappeur/AthleteMappeur.cs index 6737e3b..55ffc17 100644 --- a/src/ApiMappeur/AthleteMappeur.cs +++ b/src/ApiMappeur/AthleteMappeur.cs @@ -1,10 +1,13 @@ -using Dto; +using System.Buffers; +using Dto; using Model; namespace ApiMappeur; -// anotine public static class UserMappeur { + private static readonly ArrayPool UserDtoPool = ArrayPool.Create(); + private static readonly Dictionary userToDtoMap = new Dictionary(); + private static readonly Dictionary dtoToUserMap = new Dictionary(); public static UserDto ToDto(this User user) { return new UserDto @@ -27,8 +30,71 @@ public static class UserMappeur public static User ToModel(this UserDto userDto) { - if (userDto.IsCoach) + return new User { + Username = userDto.Username, + ProfilePicture = userDto.ProfilePicture, + LastName = userDto.LastName, + FirstName = userDto.FirstName, + Email = userDto.Email, + MotDePasse = userDto.Password, + Sexe = userDto.Sexe, + Lenght = userDto.Lenght, + Weight = userDto.Weight, + DateOfBirth = userDto.DateOfBirth, + Role = userDto.IsCoach ? new Coach() : new Athlete() + + }; + } +} +/* +using Dto; +using Model; +using System.Buffers; + +namespace ApiMappeur +{ + // anotine + public static class UserMappeur + { + private static readonly ArrayPool UserDtoPool = ArrayPool.Create(); + + public static UserDto ToDto(this User user) + { + UserDto userDto = UserDtoPool.Rent(); + userDto.Id = user.Id; + userDto.Username = user.Username; + userDto.ProfilePicture = user.ProfilePicture; + userDto.LastName = user.LastName; + userDto.FirstName = user.FirstName; + userDto.Email = user.Email; + userDto.Password = user.MotDePasse; + userDto.Sexe = user.Sexe; + userDto.Lenght = user.Lenght; + userDto.Weight = user.Weight; + userDto.DateOfBirth = user.DateOfBirth; + userDto.IsCoach = user.Role is Coach; + return userDto; + } + + public static User ToModel(this UserDto userDto) + { + if (userDto.IsCoach) + { + return new User( + userDto.Username, + userDto.ProfilePicture, + userDto.LastName, + userDto.FirstName, + userDto.Email, + userDto.Password, + userDto.Sexe, + userDto.Lenght, + userDto.Weight, + userDto.DateOfBirth, + new Coach() + ); + } return new User( userDto.Username, userDto.ProfilePicture, @@ -40,20 +106,13 @@ public static class UserMappeur userDto.Lenght, userDto.Weight, userDto.DateOfBirth, - new Coach() - ); + new Athlete()); + } + + public static void ReturnToPool(this UserDto userDto) + { + UserDtoPool.Return(userDto); } - return new User( - userDto.Username, - userDto.ProfilePicture, - userDto.LastName, - userDto.FirstName, - userDto.Email, - userDto.Password, - userDto.Sexe, - userDto.Lenght, - userDto.Weight, - userDto.DateOfBirth, - new Athlete()); } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/src/DbContextLib/DbContextLib.csproj b/src/DbContextLib/DbContextLib.csproj index 928ae7a..a2d1b08 100644 --- a/src/DbContextLib/DbContextLib.csproj +++ b/src/DbContextLib/DbContextLib.csproj @@ -6,13 +6,14 @@ enable - - - + + + + - - + + diff --git a/src/DbContextLib/Identity/AuthDbContext.cs b/src/DbContextLib/Identity/AuthDbContext.cs new file mode 100644 index 0000000..89924a7 --- /dev/null +++ b/src/DbContextLib/Identity/AuthDbContext.cs @@ -0,0 +1,25 @@ +using Entities; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; + +namespace DbContextLib.Identity; + +public class AuthDbContext: IdentityDbContext +{ + + public AuthDbContext(DbContextOptions options) : base(options) { } + public AuthDbContext() { } + /* + /// + /// Configures the database options if they are not already configured. + /// + /// The options builder instance. + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + optionsBuilder.UseSqlite($"Data Source=uca.HeartTrack.db"); + } + }*/ +} \ No newline at end of file diff --git a/src/Dto/ActivityFitFileDto.cs b/src/Dto/ActivityFitFileDto.cs new file mode 100644 index 0000000..eb8fec0 --- /dev/null +++ b/src/Dto/ActivityFitFileDto.cs @@ -0,0 +1,9 @@ +namespace Dto; + +public class ActivityFitFileDto +{ + public string ActivityName { get; set; } + public string ActivityType { get; set; } + public int EffortFeel { get; set; } + //public IFormFile +} \ No newline at end of file diff --git a/src/Entities/AthleteEntity.cs b/src/Entities/AthleteEntity.cs index cc883d6..e37379a 100644 --- a/src/Entities/AthleteEntity.cs +++ b/src/Entities/AthleteEntity.cs @@ -8,6 +8,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.AspNetCore.Identity; namespace Entities { @@ -15,8 +16,10 @@ namespace Entities /// Represents an athlete entity in the database. /// [Table("Athlete")] - public class AthleteEntity + public class AthleteEntity : IdentityUser { + public AthleteEntity() : base() { } + /// /// Gets or sets the unique identifier of the athlete. /// @@ -28,36 +31,36 @@ namespace Entities /// Gets or sets the username of the athlete. /// [MaxLength(100)] - [Required(ErrorMessage = "Athlete Username is required")] - public required string Username { get; set; } + [Required(ErrorMessage = "Athlete Username is ")] + public string Username { get; set; } /// /// Gets or sets the last name of the athlete. /// [MaxLength(100)] - [Required(ErrorMessage = "Athlete Last Name is required")] - public required string LastName { get; set; } + [Required(ErrorMessage = "Athlete Last Name is ")] + public string LastName { get; set; } /// /// Gets or sets the first name of the athlete. /// [MaxLength(150)] - [Required(ErrorMessage = "Athlete First Name is required")] - public required string FirstName { get; set; } + [Required(ErrorMessage = "Athlete First Name is ")] + public string FirstName { get; set; } /// /// Gets or sets the email of the athlete. /// [MaxLength(100)] - [Required(ErrorMessage = "Athlete Email is required")] - public required string Email { get; set; } + [Required(ErrorMessage = "Athlete Email is ")] + public string Email { get; set; } /// /// Gets or sets the gender of the athlete. /// [MaxLength(1)] - [Required(ErrorMessage = "Athlete Sexe is required")] - public required string Sexe { get; set; } + [Required(ErrorMessage = "Athlete Sexe is ")] + public string Sexe { get; set; } /// /// Gets or sets the height of the athlete. @@ -72,13 +75,13 @@ namespace Entities /// /// Gets or sets the password of the athlete. /// - [Required(ErrorMessage = "Athlete Password is required")] - public required string Password { get; set; } + [Required(ErrorMessage = "Athlete Password is ")] + public string Password { get; set; } /// /// Gets or sets the date of birth of the athlete. /// - [Required(ErrorMessage = "Athlete Date of Birth is required")] + [Required(ErrorMessage = "Athlete Date of Birth is ")] [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)] public DateOnly DateOfBirth { get; set; } @@ -87,7 +90,7 @@ namespace Entities /// public bool IsCoach { get; set; } - public required byte[] ProfilPicture { get; set; } + public byte[] ProfilPicture { get; set; } diff --git a/src/Entities/Entities.csproj b/src/Entities/Entities.csproj index bb23fb7..e37f82e 100644 --- a/src/Entities/Entities.csproj +++ b/src/Entities/Entities.csproj @@ -6,4 +6,10 @@ enable + + + ..\..\..\..\..\.nuget\packages\microsoft.extensions.identity.stores\8.0.2\lib\net8.0\Microsoft.Extensions.Identity.Stores.dll + + + diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs new file mode 100644 index 0000000..1e1b452 --- /dev/null +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -0,0 +1,137 @@ +using DbContextLib.Identity; +using Entities; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.UI.Services; +using Microsoft.AspNetCore.Mvc.ApiExplorer; +using Microsoft.AspNetCore.Mvc.Versioning; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Model.Manager; +using Model.Service; + +using StubAPI; +using Swashbuckle.AspNetCore.SwaggerGen; + + +namespace HeartTrackAPI; + +public class AppBootstrap(IConfiguration configuration) +{ + private IConfiguration Configuration { get; } = configuration; + + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers(); + services.AddEndpointsApiExplorer(); + //services.AddTransient, ConfigureSwaggerOption>(); + // include Xml comment + // addsecurityRequiment + // securityDef + services.AddSwaggerGen(); + AddHeartTrackContextServices(services); + AddModelService(services); + AddIdentityServices(services); + AddApiVersioning(services); + AddSwagger(services); + + services.AddHealthChecks(); + + } + + private void AddHeartTrackContextServices(IServiceCollection services) + { + var connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection"); + if (string.IsNullOrWhiteSpace(connectionString)) + { + throw new InvalidOperationException("The connection string for the database is not set."); + } + else + { + services.AddDbContext(options => options.UseInMemoryDatabase("AuthDb")); +// builder.Services.AddDbContext(options => options.UseSqlite(connectionString)); + services.AddSingleton(); + } + + } + private void AddModelService(IServiceCollection services) + { + services.AddSingleton(); + services.AddTransient(); + } + + private void AddIdentityServices(IServiceCollection services) + { +// services.AddTransient, EmailSender>(); + services.AddAuthorization(); + + services.AddIdentityApiEndpoints() + .AddEntityFrameworkStores(); + //services.AddIdentity() + // .AddEntityFrameworkStores().AddDefaultTokenProviders(); + } + + private void AddApiVersioning(IServiceCollection services) + { + + services.AddApiVersioning(opt => + { + opt.ReportApiVersions = true; + opt.AssumeDefaultVersionWhenUnspecified = true; + opt.DefaultApiVersion = new Microsoft.AspNetCore.Mvc.ApiVersion(1, 0); +// options.ApiVersionReader = new HeaderApiVersionReader("api-version"); + + opt.ApiVersionReader = ApiVersionReader.Combine(new UrlSegmentApiVersionReader(), + new HeaderApiVersionReader("x-api-version"), + new MediaTypeApiVersionReader("x-api-version")); + }); + + } + private void AddSwagger(IServiceCollection services) + { + services.AddSwaggerGen(options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "HeartTrackAPI", Version = "v1" }); + options.SwaggerDoc("v2", new OpenApiInfo { Title = "HeartTrackAPI", Version = "v2" }); + }); + + services.AddVersionedApiExplorer(setup => + { + setup.GroupNameFormat = "'v'VVV"; + setup.SubstituteApiVersionInUrl = true; + }); + } + + public void Configure(WebApplication app, IWebHostEnvironment env) + { + app.UseHttpsRedirection(); + + app.MapControllers(); + app.UseAuthorization(); + app.MapIdentityApi(); + + app.MapHealthChecks("/health"); + + // Configure the HTTP request pipeline. + if (true) + { + var apiVersionDescriptionProvider = app.Services.GetRequiredService(); + app.UseSwagger(); + app.UseSwaggerUI(); + app.MapSwagger(); + app.UseSwaggerUI(options => + { + foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions) + + //foreach (var description in apiVersionDescriptionProvider) + { + options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", + description.GroupName.ToUpperInvariant()); + } + }); + + } + + + } +} diff --git a/src/HeartTrackAPI/Controllers/ActivityController.cs b/src/HeartTrackAPI/Controllers/ActivityController.cs index 0319803..6ad3e22 100644 --- a/src/HeartTrackAPI/Controllers/ActivityController.cs +++ b/src/HeartTrackAPI/Controllers/ActivityController.cs @@ -5,6 +5,7 @@ using HeartTrackAPI.Responce; using Microsoft.AspNetCore.Mvc; using Shared; using Model; +using Model.Manager; using Model.Repository; namespace HeartTrackAPI.Controllers; @@ -14,6 +15,7 @@ public class ActivityController : Controller { private readonly IActivityRepository _activityService; private readonly ILogger _logger; + private readonly IActivityManager _activityManager; public ActivityController(IActivityRepository activityService, ILogger logger) { @@ -46,6 +48,21 @@ public class ActivityController : Controller return StatusCode(500); } } + /* + public async Task PostFitFile([FromForm] IFormFile file) + { + if (file == null) + { + return BadRequest("No file was provided"); + } + var activity = await _activityManager.AddActivityFromFitFile(file); + if (activity == null) + { + return BadRequest("The file provided is not a valid fit file"); + } + return CreatedAtAction(nameof(GetActivities), activity.ToDto()); + }*/ + /* [HttpGet("{id}")] public async Task> GetActivity(int id) diff --git a/src/HeartTrackAPI/Controllers/UsersController.cs b/src/HeartTrackAPI/Controllers/UsersController.cs index ea98a15..b3369c7 100644 --- a/src/HeartTrackAPI/Controllers/UsersController.cs +++ b/src/HeartTrackAPI/Controllers/UsersController.cs @@ -1,7 +1,9 @@ using ApiMappeur; using Dto; +using Entities; using HeartTrackAPI.Request; using HeartTrackAPI.Responce; +using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Model; using Model.Manager; @@ -11,11 +13,13 @@ using Shared; namespace HeartTrackAPI.Controllers; [ApiController] -[Route("api/users")] +[ApiVersion("1.0")] +[Route("api/v{version:apiVersion}/users")] public class UsersController : Controller { private readonly ILogger _logger; private readonly IUserRepository _userService; + // private readonly public UsersController(ILogger logger, IDataManager dataManager) { _logger = logger; @@ -156,5 +160,52 @@ public class UsersController : Controller } } - + + [HttpPost("{id}/friend/{friendId}")] + [ProducesResponseType(200)] + [ProducesResponseType(404)] + [ProducesResponseType(500)] + public async Task AddFriend(int id, int friendId) + { + try + { + _logger.LogInformation("Executing {Action} with parameters: {Parameters} for {Id}", nameof(AddFriend), friendId,id); + var athlete = await _userService.GetItemById(id); + if (athlete == null) + { + _logger.LogError("Athlete with id {id} not found", id); + return NotFound($"Athlete with id {id} not found"); + } + var friend = await _userService.GetItemById(friendId); + if (friend == null) + { + _logger.LogError("Athlete with id {id} not found", friendId); + return NotFound($"Athlete with id {friendId} not found"); + } + var isAdded = await _userService.AddFriend(athlete, friend); + if(!isAdded) + { + _logger.LogError("Error while adding friend with id {friendId} to athlete with id {id}", friendId, id); + return StatusCode(500); + } + return Ok(); + } + catch (Exception e) + { + _logger.LogError(e, "Error while getting the number of users"); + return StatusCode(500); + } + } + + [HttpPost("logout")] + [ProducesResponseType(200)] + [ProducesResponseType(401)] + [ProducesResponseType(500)] + public async Task Logout(SignInManager signInManager, [FromBody] object? empty) + { + if (empty == null) return Unauthorized(); + await signInManager.SignOutAsync(); + return Ok(); + } + } \ No newline at end of file diff --git a/src/HeartTrackAPI/HeartTrackAPI.csproj b/src/HeartTrackAPI/HeartTrackAPI.csproj index c572e11..e0f7022 100644 --- a/src/HeartTrackAPI/HeartTrackAPI.csproj +++ b/src/HeartTrackAPI/HeartTrackAPI.csproj @@ -8,12 +8,17 @@ + + + + + diff --git a/src/HeartTrackAPI/Program.cs b/src/HeartTrackAPI/Program.cs index b43dfbe..c79cc12 100644 --- a/src/HeartTrackAPI/Program.cs +++ b/src/HeartTrackAPI/Program.cs @@ -1,25 +1,23 @@ -using Model; +using DbContextLib; +using DbContextLib.Identity; +using Entities; +using HeartTrackAPI; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc.Versioning; +using Microsoft.EntityFrameworkCore; +using Microsoft.OpenApi.Models; using Model.Manager; -using Model.Repository; using StubAPI; - var builder = WebApplication.CreateBuilder(args); -// Add services to the container. -// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddSwaggerGen(); -builder.Services.AddControllers(); -builder.Services.AddSingleton(); -var app = builder.Build(); - -// Configure the HTTP request pipeline. +builder.Logging.AddConsole(); - app.UseSwagger(); - app.UseSwaggerUI(); +var init = new AppBootstrap(builder.Configuration); +init.ConfigureServices(builder.Services); -app.UseHttpsRedirection(); +var app = builder.Build(); -app.MapControllers(); +init.Configure(app, app.Environment); +// app?.Services?.GetService()?.Database.EnsureCreated(); app.Run(); \ No newline at end of file diff --git a/src/HeartTrackAPI/Utils/SwaggerOptions.cs b/src/HeartTrackAPI/Utils/SwaggerOptions.cs new file mode 100644 index 0000000..7754a52 --- /dev/null +++ b/src/HeartTrackAPI/Utils/SwaggerOptions.cs @@ -0,0 +1,64 @@ +using Microsoft.AspNetCore.Mvc.ApiExplorer; +using Microsoft.Extensions.Options; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; +namespace HeartTrackAPI.Utils; + +public class SwaggerOptions: IConfigureNamedOptions + + { + private readonly IApiVersionDescriptionProvider _provider; + + public SwaggerOptions( + IApiVersionDescriptionProvider provider) + { + _provider = provider; + } + + /// + /// Configure each API discovered for Swagger Documentation + /// + /// + public void Configure(SwaggerGenOptions options) + { + // add swagger document for every API version discovered + foreach (var description in _provider.ApiVersionDescriptions) + { + options.SwaggerDoc( + description.GroupName, + CreateVersionInfo(description)); + } + } + + /// + /// Configure Swagger Options. Inherited from the Interface + /// + /// + /// + public void Configure(string name, SwaggerGenOptions options) + { + Configure(options); + } + + /// + /// Create information about the version of the API + /// + /// + /// Information about the API + private OpenApiInfo CreateVersionInfo( + ApiVersionDescription desc) + { + var info = new OpenApiInfo() + { + Title = ".NET Core (.NET 6) Web API For Lol", + Version = desc.ApiVersion.ToString() + }; + + if (desc.IsDeprecated) + { + info.Description += " This API version has been deprecated. Please use one of the new APIs available from the explorer."; + } + + return info; + } + } diff --git a/src/HeartTrackAPI/appsettings.json b/src/HeartTrackAPI/appsettings.json index 4d56694..952a46c 100644 --- a/src/HeartTrackAPI/appsettings.json +++ b/src/HeartTrackAPI/appsettings.json @@ -5,5 +5,8 @@ "Microsoft.AspNetCore": "Warning" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "ConnectionStrings": { + "HeartTrackAuthConnection": "Data Source=uca.HeartTrack.db" + } } diff --git a/src/Model/Manager/ActivityManager.cs b/src/Model/Manager/ActivityManager.cs new file mode 100644 index 0000000..6cd1ef1 --- /dev/null +++ b/src/Model/Manager/ActivityManager.cs @@ -0,0 +1,9 @@ +namespace Model.Manager; + +public class ActivityManager : IActivityManager +{ + public void AddActivityFromFitFile(byte filePath) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/Model/Manager/Contract/IActivityManager.cs b/src/Model/Manager/Contract/IActivityManager.cs new file mode 100644 index 0000000..5722a41 --- /dev/null +++ b/src/Model/Manager/Contract/IActivityManager.cs @@ -0,0 +1,7 @@ +using Microsoft.AspNetCore.Http; +namespace Model.Manager; + +public interface IActivityManager +{ + public void AddActivityFromFitFile(byte filePath); +} \ No newline at end of file diff --git a/src/Model/Manager/UserManager.cs b/src/Model/Manager/UserManager.cs new file mode 100644 index 0000000..d1b697a --- /dev/null +++ b/src/Model/Manager/UserManager.cs @@ -0,0 +1,6 @@ +namespace Model.Manager; + +public class UserManager +{ + +} \ No newline at end of file diff --git a/src/Model/Model.csproj b/src/Model/Model.csproj index 18de4eb..915e21e 100644 --- a/src/Model/Model.csproj +++ b/src/Model/Model.csproj @@ -7,7 +7,18 @@ + + + + + + + + ..\..\..\..\..\.dotnet\shared\Microsoft.AspNetCore.App\8.0.1\Microsoft.AspNetCore.Identity.dll + + + diff --git a/src/Model/Repository/IUserRepository.cs b/src/Model/Repository/IUserRepository.cs index d6d528c..4c38ba4 100644 --- a/src/Model/Repository/IUserRepository.cs +++ b/src/Model/Repository/IUserRepository.cs @@ -5,4 +5,6 @@ namespace Model.Repository; public interface IUserRepository : IGenericRepository { public Task> GetUsers(int index, int count, AthleteOrderCriteria? criteria , bool descending = false); + + public Task AddFriend(User user, User friend); } \ No newline at end of file diff --git a/src/Model/Service/EmailSender.cs b/src/Model/Service/EmailSender.cs new file mode 100644 index 0000000..fc9d5e6 --- /dev/null +++ b/src/Model/Service/EmailSender.cs @@ -0,0 +1,31 @@ + +using Entities; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Identity.UI.Services; + +namespace Model.Service; + +public class EmailSender : IEmailSender +{ + private IEmailSender _emailSenderImplementation; + + public async Task SendEmailAsync(string email, string subject, string htmlMessage) + { + throw new NotImplementedException(); + } + + public async Task SendConfirmationLinkAsync(AthleteEntity user, string email, string confirmationLink) + { + throw new NotImplementedException(); + } + + public async Task SendPasswordResetLinkAsync(AthleteEntity user, string email, string resetLink) + { + throw new NotImplementedException(); + } + + public async Task SendPasswordResetCodeAsync(AthleteEntity user, string email, string resetCode) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/Model/User.cs b/src/Model/User.cs index 6efffa8..0991ca5 100644 --- a/src/Model/User.cs +++ b/src/Model/User.cs @@ -8,7 +8,7 @@ public class User public string LastName { get; set; } public string FirstName { get; set; } public string Email { get; set; } - public string MotDePasse { get; set; } + public string? MotDePasse { get; set; } public string Sexe { get; set; } public float Lenght { get; set; } public float Weight { get; set; } @@ -17,6 +17,8 @@ public class User protected List Notifications { get; set; } = new List(); + public List Users { get; set; } = new List(); + public User( string username, string profilePicture, string nom, string prenom, string email, string motDePasse, string sexe, float taille, float poids, DateTime dateNaissance, Role role) { Username = username; diff --git a/src/Model2Entities/DbDataManager.cs b/src/Model2Entities/DbDataManager.cs index ec2a3fe..b89d82b 100644 --- a/src/Model2Entities/DbDataManager.cs +++ b/src/Model2Entities/DbDataManager.cs @@ -8,7 +8,6 @@ public partial class DbDataManager: IDataManager { public IActivityRepository ActivityRepo { get; } public IUserRepository UserRepo { get; } - protected HeartTrackContext DbContext { get; } diff --git a/src/Model2Entities/UserRepository.cs b/src/Model2Entities/UserRepository.cs index e9716f1..020dcb6 100644 --- a/src/Model2Entities/UserRepository.cs +++ b/src/Model2Entities/UserRepository.cs @@ -49,5 +49,10 @@ public partial class DbDataManager { throw new NotImplementedException(); } + + public async Task AddFriend(User user, User friend) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/src/StubAPI/AthleteService.cs b/src/StubAPI/AthleteService.cs index b1b1a28..d666873 100644 --- a/src/StubAPI/AthleteService.cs +++ b/src/StubAPI/AthleteService.cs @@ -34,6 +34,23 @@ public class UserService : IUserRepository public async Task> GetUsers(int index, int count, AthleteOrderCriteria? orderingProperty = null, bool descending = false) => athletes.GetItemsWithFilterAndOrdering(c=>true,index, count,orderingProperty != AthleteOrderCriteria.None ? orderingProperty: null , descending); + public async Task AddFriend(User user, User friend) + { + if (user == null || friend == null) + { + return false; + } + + if (user.Users.Contains(friend)) + { + return false; + } + + user.Users.Add(friend); + + return true; + } + public async Task> GetItems(int index, int count, string? orderingProperty = null, bool descending = false) { From 998d32dc695e0d819424423c5ad7314b28a6f3ec Mon Sep 17 00:00:00 2001 From: David D'ALMEIDA Date: Wed, 13 Mar 2024 18:23:08 +0100 Subject: [PATCH 02/74] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 51019cc..b3304ee 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,9 +3,6 @@ type: docker name: HeartTrack-API trigger: - branch: - - WORK-CD - - WORK-EF_WebAPI event: - push From 86ed9d849a52e727b3eb58f44148b516c05bf30e Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 05:58:51 +0100 Subject: [PATCH 03/74] change gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a7bcc21..277a353 100644 --- a/.gitignore +++ b/.gitignore @@ -564,5 +564,6 @@ xcuserdata/ /dataSources/ /dataSources.local.xml .ideaMigration/ -Migration/ +Migration*/ + *.db \ No newline at end of file From 3b1c19fb9c075107469e46de847f6217479122d4 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 05:59:07 +0100 Subject: [PATCH 04/74] git --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 277a353..70b6c0a 100644 --- a/.gitignore +++ b/.gitignore @@ -564,6 +564,8 @@ xcuserdata/ /dataSources/ /dataSources.local.xml .ideaMigration/ -Migration*/ +Migration/ +Migrations/ + *.db \ No newline at end of file From d36bd185514dc0ff278c2887b075a15065a461dc Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 06:03:06 +0100 Subject: [PATCH 05/74] update with working db api --- src/APIMappers/APIMappers.csproj | 14 + src/APIMappers/ActivityMapper.cs | 53 + src/APIMappers/UserMappeur.cs | 54 + src/DbContextLib/HeartTrackContext.cs | 6 +- src/Dto/ActivityDto.cs | 22 +- src/Entities/AthleteEntity.cs | 14 +- src/HeartTrack.sln | 6 + src/HeartTrackAPI/AppBootstrap.cs | 28 +- .../Controllers/ActivityController.cs | 28 +- .../Controllers/UsersController.cs | 24 +- src/HeartTrackAPI/HeartTrackAPI.csproj | 7 +- src/HeartTrackAPI/HeartTrackAPI.http | 6 - src/HeartTrackAPI/Program.cs | 13 +- .../appsettings.Development.json | 3 + src/Model/Model.csproj | 12 +- src/Model2Entities/ActivityRepository.cs | 2 +- src/Model2Entities/DbDataManager.cs | 1 + src/Model2Entities/Extension.cs | 28 +- src/Model2Entities/Model2Entities.csproj | 8 + .../20240312203935_MyMigrations.Designer.cs | 986 ------------------ .../Migrations/20240312203935_MyMigrations.cs | 492 --------- .../TrainingStubbedContextModelSnapshot.cs | 983 ----------------- .../StubbedContextLib.csproj | 18 +- 23 files changed, 243 insertions(+), 2565 deletions(-) create mode 100644 src/APIMappers/APIMappers.csproj create mode 100644 src/APIMappers/ActivityMapper.cs create mode 100644 src/APIMappers/UserMappeur.cs delete mode 100644 src/HeartTrackAPI/HeartTrackAPI.http delete mode 100644 src/StubbedContextLib/Migrations/20240312203935_MyMigrations.Designer.cs delete mode 100644 src/StubbedContextLib/Migrations/20240312203935_MyMigrations.cs delete mode 100644 src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs diff --git a/src/APIMappers/APIMappers.csproj b/src/APIMappers/APIMappers.csproj new file mode 100644 index 0000000..3bb04a5 --- /dev/null +++ b/src/APIMappers/APIMappers.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/src/APIMappers/ActivityMapper.cs b/src/APIMappers/ActivityMapper.cs new file mode 100644 index 0000000..a842429 --- /dev/null +++ b/src/APIMappers/ActivityMapper.cs @@ -0,0 +1,53 @@ +using Dto; +using Model; +using Shared; + +namespace APIMappers; + +public static class ActivityMapper +{ + private static GenericMapper _mapper = new GenericMapper(); + + public static ActivityDto? ToDto(this Activity activity) + { + return activity.ToU(_mapper, activityDto => new ActivityDto + { + Id = activity.Id, + Type = activity.Type, + Date = activity.Date, + StartTime = activity.StartTime, + EndTime = activity.EndTime, + EffortFelt = activity.Effort, + Variability = activity.Variability, + Variance = activity.Variance, + StandardDeviation = activity.StandardDeviation, + Average = activity.Average, + Maximum = activity.Maximum, + Minimum = activity.Minimum, + AverageTemperature = activity.AverageTemperature, + HasAutoPause = activity.HasAutoPause + }); + } + + public static Activity? ToModel(this ActivityDto activityDto) + { + return activityDto.ToT(_mapper, activity => new Activity + { + Id = activityDto.Id, + Type = activityDto.Type, + Date = activityDto.Date, + StartTime = activityDto.StartTime, + EndTime = activityDto.EndTime, + Effort = activityDto.EffortFelt, + Variability = activityDto.Variability, + Variance = activityDto.Variance, + StandardDeviation = activityDto.StandardDeviation, + Average = activityDto.Average, + Maximum = activityDto.Maximum, + Minimum = activityDto.Minimum, + AverageTemperature = activityDto.AverageTemperature, + HasAutoPause = activityDto.HasAutoPause + }); + } + +} \ No newline at end of file diff --git a/src/APIMappers/UserMappeur.cs b/src/APIMappers/UserMappeur.cs new file mode 100644 index 0000000..6d94da6 --- /dev/null +++ b/src/APIMappers/UserMappeur.cs @@ -0,0 +1,54 @@ +using Dto; +using Model; +using Shared; + +namespace APIMappers; + +public static class UserMappeur +{ + private static GenericMapper _mapper = new GenericMapper(); + + public static UserDto? ToDto(this User user) + { + return user.ToU(_mapper, userDto => new UserDto + { + Id = user.Id, + Username = user.Username, + ProfilePicture = user.ProfilePicture, + LastName = user.LastName, + FirstName = user.FirstName, + Email = user.Email, + Password = user.MotDePasse, + Sexe = user.Sexe, + Lenght = user.Lenght, + Weight = user.Weight, + DateOfBirth = user.DateOfBirth, + IsCoach = user.Role is Coach + }); + // ), (activity, entity) => activity.Id = entity.IdActivity); + + } + // ochestrateur => api gateway + // corégraphie => microservice TCP + + + public static User? ToModel(this UserDto userDto) + { + return userDto.ToT(_mapper, user => new User + { + Username = userDto.Username, + ProfilePicture = userDto.ProfilePicture, + LastName = userDto.LastName, + FirstName = userDto.FirstName, + Email = userDto.Email, + MotDePasse = userDto.Password, + Sexe = userDto.Sexe, + Lenght = userDto.Lenght, + Weight = userDto.Weight, + DateOfBirth = userDto.DateOfBirth, + Role = userDto.IsCoach ? new Coach() : new Athlete() + + }); + } + +} \ No newline at end of file diff --git a/src/DbContextLib/HeartTrackContext.cs b/src/DbContextLib/HeartTrackContext.cs index 5dbb584..3264346 100644 --- a/src/DbContextLib/HeartTrackContext.cs +++ b/src/DbContextLib/HeartTrackContext.cs @@ -55,13 +55,15 @@ namespace DbContextLib /// /// Initializes a new instance of the class. /// - public HeartTrackContext() : base() { } + public HeartTrackContext() : base() + { } /// /// Initializes a new instance of the class with the specified options. /// /// The options for the context. - public HeartTrackContext(DbContextOptions options) : base(options) { } + public HeartTrackContext(DbContextOptions options) : base(options) + { } /// /// Configures the database options if they are not already configured. diff --git a/src/Dto/ActivityDto.cs b/src/Dto/ActivityDto.cs index d4bf5f1..b2a0a91 100644 --- a/src/Dto/ActivityDto.cs +++ b/src/Dto/ActivityDto.cs @@ -3,17 +3,17 @@ namespace Dto; public class ActivityDto { public int Id { get; set; } - public string Name { get; set; } public string Type { get; set; } public DateTime Date { get; set; } - public TimeSpan Duration { get; set; } - public float Distance { get; set; } - public float Elevation { get; set; } - public float AverageSpeed { get; set; } - public int AverageHeartRate { get; set; } - public int Calories { get; set; } - public string Description { get; set; } - public string? Gpx { get; set; } - public string? Image { get; set; } - public int AthleteId { get; set; } + public DateTime StartTime { get; set; } + public DateTime 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; } } \ No newline at end of file diff --git a/src/Entities/AthleteEntity.cs b/src/Entities/AthleteEntity.cs index e37379a..65010de 100644 --- a/src/Entities/AthleteEntity.cs +++ b/src/Entities/AthleteEntity.cs @@ -16,7 +16,7 @@ namespace Entities /// Represents an athlete entity in the database. /// [Table("Athlete")] - public class AthleteEntity : IdentityUser + public class AthleteEntity { public AthleteEntity() : base() { } @@ -32,35 +32,35 @@ namespace Entities /// [MaxLength(100)] [Required(ErrorMessage = "Athlete Username is ")] - public string Username { get; set; } + public required string Username { get; set; } /// /// Gets or sets the last name of the athlete. /// [MaxLength(100)] [Required(ErrorMessage = "Athlete Last Name is ")] - public string LastName { get; set; } + public required string LastName { get; set; } /// /// Gets or sets the first name of the athlete. /// [MaxLength(150)] [Required(ErrorMessage = "Athlete First Name is ")] - public string FirstName { get; set; } + public required string FirstName { get; set; } /// /// Gets or sets the email of the athlete. /// [MaxLength(100)] [Required(ErrorMessage = "Athlete Email is ")] - public string Email { get; set; } + public required string Email { get; set; } /// /// Gets or sets the gender of the athlete. /// [MaxLength(1)] [Required(ErrorMessage = "Athlete Sexe is ")] - public string Sexe { get; set; } + public required string Sexe { get; set; } /// /// Gets or sets the height of the athlete. @@ -76,7 +76,7 @@ namespace Entities /// Gets or sets the password of the athlete. /// [Required(ErrorMessage = "Athlete Password is ")] - public string Password { get; set; } + public required string Password { get; set; } /// /// Gets or sets the date of birth of the athlete. diff --git a/src/HeartTrack.sln b/src/HeartTrack.sln index 57167ac..b4faecf 100644 --- a/src/HeartTrack.sln +++ b/src/HeartTrack.sln @@ -41,6 +41,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTestEFMapper", "Test EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFMappers", "EFMappers\EFMappers.csproj", "{9397795D-F482-44C4-8443-A20AC26671AA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APIMappers", "APIMappers\APIMappers.csproj", "{41D18203-1688-43BD-A3AC-FD0C2BD81909}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -134,6 +136,10 @@ Global {9397795D-F482-44C4-8443-A20AC26671AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {9397795D-F482-44C4-8443-A20AC26671AA}.Release|Any CPU.ActiveCfg = Release|Any CPU {9397795D-F482-44C4-8443-A20AC26671AA}.Release|Any CPU.Build.0 = Release|Any CPU + {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Debug|Any CPU.Build.0 = Debug|Any CPU + {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Release|Any CPU.ActiveCfg = Release|Any CPU + {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {477D2129-A6C9-4FF8-8BE9-5E9E8E5282F8} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 1e1b452..ce01163 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -1,15 +1,17 @@ +using DbContextLib; using DbContextLib.Identity; using Entities; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Versioning; +using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using Microsoft.OpenApi.Models; using Model.Manager; using Model.Service; - +using Model2Entities; using StubAPI; using Swashbuckle.AspNetCore.SwaggerGen; @@ -49,15 +51,29 @@ public class AppBootstrap(IConfiguration configuration) else { services.AddDbContext(options => options.UseInMemoryDatabase("AuthDb")); -// builder.Services.AddDbContext(options => options.UseSqlite(connectionString)); - services.AddSingleton(); + //options => options.UseSqlite(connectionString) + //services.AddDbContext(); + services.AddDbContext(options => + options.UseSqlite(connectionString), ServiceLifetime.Singleton); +/* + services.AddSingleton>(provider => + { + var connection = new SqliteConnection("DataSource=:memory:"); + connection.Open(); + + var options = new DbContextOptionsBuilder() + .UseSqlite(connection) + .Options; + + return options; + });*/ } } private void AddModelService(IServiceCollection services) { - services.AddSingleton(); - services.AddTransient(); + services.AddSingleton(provider => new DbDataManager(provider.GetService())); + //services.AddTransient(); } private void AddIdentityServices(IServiceCollection services) @@ -105,10 +121,10 @@ public class AppBootstrap(IConfiguration configuration) public void Configure(WebApplication app, IWebHostEnvironment env) { app.UseHttpsRedirection(); + app.MapIdentityApi(); app.MapControllers(); app.UseAuthorization(); - app.MapIdentityApi(); app.MapHealthChecks("/health"); diff --git a/src/HeartTrackAPI/Controllers/ActivityController.cs b/src/HeartTrackAPI/Controllers/ActivityController.cs index 81ee0d4..3827b10 100644 --- a/src/HeartTrackAPI/Controllers/ActivityController.cs +++ b/src/HeartTrackAPI/Controllers/ActivityController.cs @@ -1,3 +1,4 @@ +using APIMappers; using Dto; using HeartTrackAPI.Request; using HeartTrackAPI.Responce; @@ -16,9 +17,9 @@ public class ActivityController : Controller private readonly ILogger _logger; private readonly IActivityManager _activityManager; - public ActivityController(IActivityRepository activityService, ILogger logger) + public ActivityController(IDataManager dataManager, ILogger logger) { - _activityService = activityService; + _activityService = dataManager.ActivityRepo; _logger = logger; } @@ -38,8 +39,8 @@ public class ActivityController : Controller } _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(GetActivities), pageRequest); var activities = await _activityService.GetActivities(pageRequest.Index, pageRequest.Count, ActivityOrderCriteria.None, pageRequest.Descending ?? false); - // var pageResponse = new PageResponse(pageRequest.Index, pageRequest.Count, totalCount, activities.Select(a => a.ToDto())); - // return Ok(pageResponse); + var pageResponse = new PageResponse(pageRequest.Index, pageRequest.Count, totalCount, activities.Select(a => a.ToDto())); + return Ok(pageResponse); return Ok(); } catch (Exception e) @@ -56,14 +57,17 @@ public class ActivityController : Controller return BadRequest("No file was provided"); } var activity = await _activityManager.AddActivityFromFitFile(file); + à l'intérieur du AddActivityFromFitFile ya un truc comme var result = await _activityRepo.AddActivity(activity); + if (activity == null) { return BadRequest("The file provided is not a valid fit file"); } + return CreatedAtAction(nameof(GetActivity), new { id = result.Id }, result.ToDto()); + return CreatedAtAction(nameof(GetActivities), activity.ToDto()); }*/ -/* [HttpGet("{id}")] public async Task> GetActivity(int id) { @@ -75,18 +79,6 @@ public class ActivityController : Controller return Ok(activity.ToDto()); } - [HttpPost] - public async Task> PostActivity(ActivityDto activityDto) - { - var activity = activityDto.ToModel(); - var result = await _activityService.AddActivity(activity); - if (result == null) - { - return BadRequest(); - } - return CreatedAtAction(nameof(GetActivity), new { id = result.Id }, result.ToDto()); - } - [HttpPut("{id}")] public async Task PutActivity(int id, ActivityDto activityDto) { @@ -112,5 +104,5 @@ public class ActivityController : Controller return NotFound(); } return NoContent(); - }*/ + } } \ No newline at end of file diff --git a/src/HeartTrackAPI/Controllers/UsersController.cs b/src/HeartTrackAPI/Controllers/UsersController.cs index 435a56b..5b1486f 100644 --- a/src/HeartTrackAPI/Controllers/UsersController.cs +++ b/src/HeartTrackAPI/Controllers/UsersController.cs @@ -1,3 +1,4 @@ +using APIMappers; using Dto; using Entities; using HeartTrackAPI.Request; @@ -18,7 +19,6 @@ public class UsersController : Controller { private readonly ILogger _logger; private readonly IUserRepository _userService; - // private readonly public UsersController(ILogger logger, IDataManager dataManager) { _logger = logger; @@ -43,9 +43,8 @@ public class UsersController : Controller _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), null); var athletes = await _userService.GetUsers(request.Index, request.Count, Enum.TryParse(request.OrderingPropertyName, out AthleteOrderCriteria result) ? result : AthleteOrderCriteria.None, request.Descending ?? false); - // var pageResponse = new PageResponse(request.Index, request.Count, totalCount, athletes.Select(a => a.ToDto())); - // return Ok(pageResponse); - return Ok(); + var pageResponse = new PageResponse(request.Index, request.Count, totalCount, athletes.Select(a => a.ToDto())); + return Ok(pageResponse); } catch (Exception e) { @@ -69,8 +68,7 @@ public class UsersController : Controller _logger.LogError("Athlete with id {id} not found", id); return NotFound($"Athlete with id {id} not found"); } - // return Ok(athlete.ToDto()); - return Ok(); + return Ok(athlete.ToDto()); } catch (Exception e) { @@ -113,13 +111,13 @@ public class UsersController : Controller _logger.LogError("Athlete with id {id} not found", id); return NotFound($"Athlete with id {id} not found"); } - // var updatedAthlete = await _userService.UpdateItem(id, user.ToModel()); - // if(updatedAthlete == null) - // { - // _logger.LogError("Error while updating athlete with id {id}", id); - // return StatusCode(500); - // } - // return Ok(updatedAthlete.ToDto()); + var updatedAthlete = await _userService.UpdateItem(id, user.ToModel()); + if(updatedAthlete == null) + { + _logger.LogError("Error while updating athlete with id {id}", id); + return StatusCode(500); + } + return Ok(updatedAthlete.ToDto()); return Ok(); } diff --git a/src/HeartTrackAPI/HeartTrackAPI.csproj b/src/HeartTrackAPI/HeartTrackAPI.csproj index 6252aa2..133b59f 100644 --- a/src/HeartTrackAPI/HeartTrackAPI.csproj +++ b/src/HeartTrackAPI/HeartTrackAPI.csproj @@ -12,14 +12,19 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - + + diff --git a/src/HeartTrackAPI/HeartTrackAPI.http b/src/HeartTrackAPI/HeartTrackAPI.http deleted file mode 100644 index 97c9a67..0000000 --- a/src/HeartTrackAPI/HeartTrackAPI.http +++ /dev/null @@ -1,6 +0,0 @@ -@HeartTrackAPI_HostAddress = http://localhost:5030 - -GET {{HeartTrackAPI_HostAddress}}/weatherforecast/ -Accept: application/json - -### diff --git a/src/HeartTrackAPI/Program.cs b/src/HeartTrackAPI/Program.cs index c79cc12..9b4e118 100644 --- a/src/HeartTrackAPI/Program.cs +++ b/src/HeartTrackAPI/Program.cs @@ -1,13 +1,6 @@ using DbContextLib; -using DbContextLib.Identity; -using Entities; using HeartTrackAPI; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc.Versioning; -using Microsoft.EntityFrameworkCore; -using Microsoft.OpenApi.Models; -using Model.Manager; -using StubAPI; + var builder = WebApplication.CreateBuilder(args); builder.Logging.AddConsole(); @@ -19,5 +12,7 @@ init.ConfigureServices(builder.Services); var app = builder.Build(); init.Configure(app, app.Environment); -// app?.Services?.GetService()?.Database.EnsureCreated(); + +app.Services.GetService()!.Database.EnsureCreated(); + app.Run(); \ No newline at end of file diff --git a/src/HeartTrackAPI/appsettings.Development.json b/src/HeartTrackAPI/appsettings.Development.json index ff66ba6..c603414 100644 --- a/src/HeartTrackAPI/appsettings.Development.json +++ b/src/HeartTrackAPI/appsettings.Development.json @@ -4,5 +4,8 @@ "Default": "Information", "Microsoft.AspNetCore": "Warning" } + }, + "ConnectionStrings": { + "HeartTrackAuthConnection": "Data Source=uca.HeartTrack.db" } } diff --git a/src/Model/Model.csproj b/src/Model/Model.csproj index 915e21e..a957f97 100644 --- a/src/Model/Model.csproj +++ b/src/Model/Model.csproj @@ -7,18 +7,18 @@ - - + + - + - - ..\..\..\..\..\.dotnet\shared\Microsoft.AspNetCore.App\8.0.1\Microsoft.AspNetCore.Identity.dll - + + ..\..\..\..\..\.dotnet\shared\Microsoft.AspNetCore.App\8.0.1\Microsoft.AspNetCore.Identity.dll + diff --git a/src/Model2Entities/ActivityRepository.cs b/src/Model2Entities/ActivityRepository.cs index facb34c..5878da0 100644 --- a/src/Model2Entities/ActivityRepository.cs +++ b/src/Model2Entities/ActivityRepository.cs @@ -38,7 +38,7 @@ public partial class DbDataManager : IDataManager { _logger.LogInformation($"GetActivityByIdAsync with id {id}", id); // ! By None don't pass the filter - var activity = _dataManager.DbContext.ActivitiesSet.GetItemsWithFilterAndOrdering(b => b.IdActivity == id, 0, 1, ActivityOrderCriteria.ByType, false).First().ToModel(); + var activity = _dataManager.DbContext.ActivitiesSet.GetItemsWithFilterAndOrdering(b => b.IdActivity == id, 0, 1, ActivityOrderCriteria.None, false).First().ToModel(); if (activity != null) _logger.LogInformation($"Retrieved activity with ID {id}"); diff --git a/src/Model2Entities/DbDataManager.cs b/src/Model2Entities/DbDataManager.cs index 946a719..d336fe9 100644 --- a/src/Model2Entities/DbDataManager.cs +++ b/src/Model2Entities/DbDataManager.cs @@ -18,6 +18,7 @@ public partial class DbDataManager: IDataManager DbContext = dbContext; ActivityRepo = new ActivityRepository(this); UserRepo = new UserRepository(this); + DbContext.Database.EnsureCreated(); ActivityMapper.Reset(); // Faire pour les autres reset() des autres mappers } diff --git a/src/Model2Entities/Extension.cs b/src/Model2Entities/Extension.cs index 24c1e2b..ea02563 100644 --- a/src/Model2Entities/Extension.cs +++ b/src/Model2Entities/Extension.cs @@ -7,28 +7,25 @@ namespace Model2Entities; public static class Extensions { - internal static Task AddItem(this HeartTrackContext context, T? item) where T :class + internal static async Task AddItem(this HeartTrackContext context, T? item) where T :class { if(item == null || context.Set().Contains(item)) { - return Task.FromResult(default(T)); + return await Task.FromResult(null); } - context.Set().Add(item); - context.SaveChangesAsync(); + var entry = context.Set().Add(item); + await context.SaveChangesAsync(); - return Task.FromResult(item); + return await Task.FromResult(entry.Entity); } - internal static Task DeleteItem(this HeartTrackContext context, int? id) where T:class + internal static async Task DeleteItem(this HeartTrackContext context, int? id) where T:class { - var item = context.Set().Find(id); - if(item == null) - { - return Task.FromResult(false); - } + var item = await context.Set().FindAsync(id); + if(item == null) return await Task.FromResult(false); context.Set().Remove(item); - context.SaveChangesAsync(); - return Task.FromResult(true); + await context.SaveChangesAsync(); + return await Task.FromResult(true); } internal static async Task UpdateItem(this IList collection, T? oldItem, T? newItem) where T : class @@ -50,10 +47,11 @@ public static class Extensions { var filteredList = list.Where(filter); - if(orderCriterium != null) + if(orderCriterium != null && orderCriterium.ToString() != "None") { filteredList = filteredList.OrderByCriteria(orderCriterium, descending); - } + } + return filteredList .Skip(index * count) .Take(count); diff --git a/src/Model2Entities/Model2Entities.csproj b/src/Model2Entities/Model2Entities.csproj index bb068f4..d298015 100644 --- a/src/Model2Entities/Model2Entities.csproj +++ b/src/Model2Entities/Model2Entities.csproj @@ -10,6 +10,14 @@ + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + diff --git a/src/StubbedContextLib/Migrations/20240312203935_MyMigrations.Designer.cs b/src/StubbedContextLib/Migrations/20240312203935_MyMigrations.Designer.cs deleted file mode 100644 index 9e2f6ad..0000000 --- a/src/StubbedContextLib/Migrations/20240312203935_MyMigrations.Designer.cs +++ /dev/null @@ -1,986 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using StubbedContextLib; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - [DbContext(typeof(TrainingStubbedContext))] - [Migration("20240312203935_MyMigrations")] - partial class MyMigrations - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.2"); - - modelBuilder.Entity("AthleteEntityNotificationEntity", b => - { - b.Property("NotificationsReceivedIdNotif") - .HasColumnType("INTEGER"); - - b.Property("ReceiversIdAthlete") - .HasColumnType("INTEGER"); - - b.HasKey("NotificationsReceivedIdNotif", "ReceiversIdAthlete"); - - b.HasIndex("ReceiversIdAthlete"); - - b.ToTable("AthleteEntityNotificationEntity"); - }); - - modelBuilder.Entity("AthleteEntityTrainingEntity", b => - { - b.Property("AthletesIdAthlete") - .HasColumnType("INTEGER"); - - b.Property("TrainingsAthleteIdTraining") - .HasColumnType("INTEGER"); - - b.HasKey("AthletesIdAthlete", "TrainingsAthleteIdTraining"); - - b.HasIndex("TrainingsAthleteIdTraining"); - - b.ToTable("AthleteEntityTrainingEntity"); - }); - - modelBuilder.Entity("Entities.ActivityEntity", b => - { - b.Property("IdActivity") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("AthleteId") - .HasColumnType("INTEGER"); - - b.Property("Average") - .HasColumnType("REAL"); - - b.Property("AverageTemperature") - .HasColumnType("REAL"); - - b.Property("DataSourceId") - .HasColumnType("INTEGER"); - - b.Property("Date") - .HasColumnType("TEXT"); - - b.Property("EffortFelt") - .HasColumnType("INTEGER"); - - b.Property("EndTime") - .HasColumnType("TEXT"); - - b.Property("HasAutoPause") - .HasColumnType("INTEGER"); - - b.Property("Maximum") - .HasColumnType("INTEGER"); - - b.Property("Minimum") - .HasColumnType("INTEGER"); - - b.Property("StandardDeviation") - .HasColumnType("REAL"); - - b.Property("StartTime") - .HasColumnType("TEXT"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Variability") - .HasColumnType("REAL"); - - b.Property("Variance") - .HasColumnType("REAL"); - - b.HasKey("IdActivity"); - - b.HasIndex("AthleteId"); - - b.HasIndex("DataSourceId"); - - b.ToTable("Activity"); - - b.HasData( - new - { - IdActivity = 1, - AthleteId = 1, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 1, - Date = new DateOnly(2023, 1, 10), - EffortFelt = 5, - EndTime = new TimeOnly(14, 0, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(13, 0, 34), - Type = "Running", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 2, - AthleteId = 2, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 2, - Date = new DateOnly(2023, 1, 25), - EffortFelt = 5, - EndTime = new TimeOnly(14, 0, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(13, 4, 34), - Type = "Cycling", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 3, - AthleteId = 1, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 1, - Date = new DateOnly(2023, 12, 10), - EffortFelt = 5, - EndTime = new TimeOnly(15, 2, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(13, 30, 34), - Type = "Swimming", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 4, - AthleteId = 5, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 3, - Date = new DateOnly(2024, 1, 2), - EffortFelt = 5, - EndTime = new TimeOnly(16, 1, 55), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(15, 0, 0), - Type = "Walking", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 5, - AthleteId = 4, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 4, - Date = new DateOnly(2024, 1, 12), - EffortFelt = 5, - EndTime = new TimeOnly(9, 0, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(7, 45, 34), - Type = "Hiking", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 6, - AthleteId = 4, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 4, - Date = new DateOnly(2024, 1, 27), - EffortFelt = 5, - EndTime = new TimeOnly(14, 0, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(13, 30, 1), - Type = "Climbing", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 7, - AthleteId = 3, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 5, - Date = new DateOnly(2024, 2, 22), - EffortFelt = 5, - EndTime = new TimeOnly(23, 50, 58), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(22, 0, 34), - Type = "Yoga", - Variability = 0.5f, - Variance = 0.5f - }); - }); - - modelBuilder.Entity("Entities.AthleteEntity", b => - { - b.Property("IdAthlete") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("DataSourceId") - .HasColumnType("INTEGER"); - - b.Property("DateOfBirth") - .HasColumnType("TEXT"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("TEXT"); - - b.Property("IsCoach") - .HasColumnType("INTEGER"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Length") - .HasColumnType("REAL"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ProfilPicture") - .IsRequired() - .HasColumnType("BLOB"); - - b.Property("Sexe") - .IsRequired() - .HasMaxLength(1) - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Weight") - .HasColumnType("REAL"); - - b.HasKey("IdAthlete"); - - b.HasIndex("DataSourceId"); - - b.ToTable("Athlete"); - - b.HasData( - new - { - IdAthlete = 1, - DateOfBirth = new DateOnly(1990, 1, 1), - Email = "john.doe@example.com", - FirstName = "John", - IsCoach = true, - LastName = "Doe", - Length = 1.8, - Password = "password123", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "M", - Username = "Doe", - Weight = 75f - }, - new - { - IdAthlete = 2, - DataSourceId = 1, - DateOfBirth = new DateOnly(1995, 1, 1), - Email = "jane.smith@exemple.com", - FirstName = "Jane", - IsCoach = false, - LastName = "Smith", - Length = 1.6499999999999999, - Password = "secure456", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "F", - Username = "Smith", - Weight = 60f - }, - new - { - IdAthlete = 3, - DateOfBirth = new DateOnly(1992, 1, 1), - Email = "paul.martin@example.com", - FirstName = "Paul", - IsCoach = true, - LastName = "Martin", - Length = 1.75, - Password = "super789", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "M", - Username = "Martin", - Weight = 68f - }, - new - { - IdAthlete = 4, - DateOfBirth = new DateOnly(1993, 1, 1), - Email = "anna.brown@example.com", - FirstName = "Anna", - IsCoach = false, - LastName = "Brown", - Length = 1.7, - Password = "test000", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "F", - Username = "Brown", - Weight = 58f - }, - new - { - IdAthlete = 5, - DataSourceId = 3, - DateOfBirth = new DateOnly(1991, 1, 1), - Email = "bruce.lee@example.com", - FirstName = "Bruce", - IsCoach = false, - LastName = "Lee", - Length = 2.0, - Password = "hello321", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "M", - Username = "Lee", - Weight = 90f - }); - }); - - modelBuilder.Entity("Entities.DataSourceEntity", b => - { - b.Property("IdSource") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Model") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Precision") - .HasColumnType("REAL"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.HasKey("IdSource"); - - b.ToTable("DataSource"); - - b.HasData( - new - { - IdSource = 1, - Model = "Garmin", - Precision = 0.5f, - Type = "Smartwatch" - }, - new - { - IdSource = 2, - Model = "Polar", - Precision = 0.5f, - Type = "Smartwatch" - }, - new - { - IdSource = 3, - Model = "Suunto", - Precision = 0.5f, - Type = "Smartwatch" - }, - new - { - IdSource = 4, - Model = "Fitbit", - Precision = 0.5f, - Type = "Smartwatch" - }, - new - { - IdSource = 5, - Model = "Apple Watch", - Precision = 0.5f, - Type = "Smartwatch" - }); - }); - - modelBuilder.Entity("Entities.FriendshipEntity", b => - { - b.Property("FollowingId") - .HasColumnType("INTEGER"); - - b.Property("FollowerId") - .HasColumnType("INTEGER"); - - b.Property("StartDate") - .HasColumnType("TEXT"); - - b.HasKey("FollowingId", "FollowerId"); - - b.HasIndex("FollowerId"); - - b.ToTable("FriendshipEntity"); - - b.HasData( - new - { - FollowingId = 2, - FollowerId = 1, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 3, - FollowerId = 1, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 4, - FollowerId = 1, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 5, - FollowerId = 1, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 1, - FollowerId = 2, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 3, - FollowerId = 2, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }); - }); - - modelBuilder.Entity("Entities.HeartRateEntity", b => - { - b.Property("IdHeartRate") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ActivityId") - .HasColumnType("INTEGER"); - - b.Property("Altitude") - .HasColumnType("REAL"); - - b.Property("Bpm") - .HasColumnType("INTEGER"); - - b.Property("Latitude") - .HasColumnType("REAL"); - - b.Property("Longitude") - .HasColumnType("REAL"); - - b.Property("Temperature") - .HasColumnType("REAL"); - - b.Property("Time") - .HasColumnType("TEXT"); - - b.HasKey("IdHeartRate"); - - b.HasIndex("ActivityId"); - - b.ToTable("HeartRate"); - - b.HasData( - new - { - IdHeartRate = 1, - ActivityId = 1, - Altitude = 0.0, - Bpm = 60, - Latitude = 66f, - Longitude = 35f, - Temperature = 20f, - Time = new TimeOnly(13, 0, 30) - }, - new - { - IdHeartRate = 2, - ActivityId = 2, - Altitude = 10.0, - Bpm = 65, - Latitude = 67f, - Longitude = 35f, - Temperature = 20.5f, - Time = new TimeOnly(13, 0, 31) - }, - new - { - IdHeartRate = 3, - ActivityId = 1, - Altitude = 11.0, - Bpm = 71, - Latitude = 66f, - Longitude = 36f, - Temperature = 20f, - Time = new TimeOnly(13, 0, 32) - }, - new - { - IdHeartRate = 4, - ActivityId = 2, - Altitude = 12.0, - Bpm = 75, - Latitude = 67f, - Longitude = 36f, - Temperature = 20.5f, - Time = new TimeOnly(13, 0, 33) - }, - new - { - IdHeartRate = 5, - ActivityId = 4, - Altitude = 13.0, - Bpm = 80, - Latitude = 66f, - Longitude = 37f, - Temperature = 20f, - Time = new TimeOnly(13, 0, 34) - }); - }); - - modelBuilder.Entity("Entities.NotificationEntity", b => - { - b.Property("IdNotif") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Date") - .HasColumnType("TEXT"); - - b.Property("Message") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("SenderId") - .HasColumnType("INTEGER"); - - b.Property("Statut") - .HasColumnType("INTEGER"); - - b.Property("Urgence") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.HasKey("IdNotif"); - - b.HasIndex("SenderId"); - - b.ToTable("Notification"); - - b.HasData( - new - { - IdNotif = 1, - Date = new DateTime(2023, 12, 25, 13, 0, 40, 0, DateTimeKind.Unspecified), - Message = "You have a new activity to check", - SenderId = 1, - Statut = true, - Urgence = "A" - }, - new - { - IdNotif = 2, - Date = new DateTime(2023, 12, 26, 13, 10, 40, 0, DateTimeKind.Unspecified), - Message = "You have a new athlete to check", - SenderId = 2, - Statut = false, - Urgence = "3" - }, - new - { - IdNotif = 3, - Date = new DateTime(2023, 12, 26, 16, 10, 4, 0, DateTimeKind.Unspecified), - Message = "You have a new heart rate to check", - SenderId = 3, - Statut = true, - Urgence = "2" - }, - new - { - IdNotif = 4, - Date = new DateTime(2024, 1, 12, 9, 30, 50, 0, DateTimeKind.Unspecified), - Message = "You have a new data source to check", - SenderId = 4, - Statut = false, - Urgence = "1" - }, - new - { - IdNotif = 5, - Date = new DateTime(2024, 2, 22, 12, 10, 0, 0, DateTimeKind.Unspecified), - Message = "You have a new notification to check", - SenderId = 5, - Statut = true, - Urgence = "3" - }); - }); - - modelBuilder.Entity("Entities.StatisticEntity", b => - { - b.Property("IdStatistic") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("AthleteId") - .HasColumnType("INTEGER"); - - b.Property("AverageCaloriesBurned") - .HasColumnType("REAL"); - - b.Property("AverageHeartRate") - .HasColumnType("REAL"); - - b.Property("Date") - .HasColumnType("TEXT"); - - b.Property("MaximumHeartRate") - .HasColumnType("REAL"); - - b.Property("Weight") - .HasColumnType("REAL"); - - b.HasKey("IdStatistic"); - - b.HasIndex("AthleteId"); - - b.ToTable("Statistic"); - - b.HasData( - new - { - IdStatistic = 1, - AthleteId = 1, - AverageCaloriesBurned = 500.0, - AverageHeartRate = 120.0, - Date = new DateOnly(2021, 12, 12), - MaximumHeartRate = 180.0, - Weight = 75f - }, - new - { - IdStatistic = 2, - AthleteId = 2, - AverageCaloriesBurned = 600.0, - AverageHeartRate = 130.0, - Date = new DateOnly(2021, 1, 11), - MaximumHeartRate = 190.0, - Weight = 60f - }, - new - { - IdStatistic = 3, - AthleteId = 1, - AverageCaloriesBurned = 550.0, - AverageHeartRate = 125.0, - Date = new DateOnly(2022, 12, 30), - MaximumHeartRate = 185.0, - Weight = 68f - }, - new - { - IdStatistic = 4, - AthleteId = 3, - AverageCaloriesBurned = 650.0, - AverageHeartRate = 135.0, - Date = new DateOnly(2023, 2, 20), - MaximumHeartRate = 195.0, - Weight = 58f - }, - new - { - IdStatistic = 5, - AthleteId = 4, - AverageCaloriesBurned = 450.0, - AverageHeartRate = 110.0, - Date = new DateOnly(2024, 1, 10), - MaximumHeartRate = 170.0, - Weight = 90f - }); - }); - - modelBuilder.Entity("Entities.TrainingEntity", b => - { - b.Property("IdTraining") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CoachId") - .HasColumnType("INTEGER"); - - b.Property("Date") - .HasColumnType("TEXT"); - - b.Property("Description") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("FeedBack") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("Latitude") - .HasColumnType("REAL"); - - b.Property("Longitude") - .HasColumnType("REAL"); - - b.HasKey("IdTraining"); - - b.HasIndex("CoachId"); - - b.ToTable("Training"); - - b.HasData( - new - { - IdTraining = 1, - CoachId = 1, - Date = new DateOnly(2024, 1, 19), - Description = "Running", - FeedBack = "Good", - Latitude = 48.8566f, - Longitude = 2.3522f - }, - new - { - IdTraining = 2, - CoachId = 5, - Date = new DateOnly(2024, 2, 20), - Description = "Cycling", - Latitude = 48.8566f, - Longitude = 2.3522f - }, - new - { - IdTraining = 3, - CoachId = 4, - Date = new DateOnly(2024, 2, 21), - FeedBack = "Good", - Latitude = 48.8566f, - Longitude = 2.3522f - }, - new - { - IdTraining = 4, - CoachId = 3, - Date = new DateOnly(2024, 2, 22), - Description = "Running", - FeedBack = "Good", - Latitude = 48.8566f, - Longitude = 2.3522f - }, - new - { - IdTraining = 5, - CoachId = 1, - Date = new DateOnly(2024, 2, 23), - Description = "Cycling", - Latitude = 48.8566f, - Longitude = 2.3522f - }); - }); - - modelBuilder.Entity("AthleteEntityNotificationEntity", b => - { - b.HasOne("Entities.NotificationEntity", null) - .WithMany() - .HasForeignKey("NotificationsReceivedIdNotif") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.AthleteEntity", null) - .WithMany() - .HasForeignKey("ReceiversIdAthlete") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("AthleteEntityTrainingEntity", b => - { - b.HasOne("Entities.AthleteEntity", null) - .WithMany() - .HasForeignKey("AthletesIdAthlete") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.TrainingEntity", null) - .WithMany() - .HasForeignKey("TrainingsAthleteIdTraining") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Entities.ActivityEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Athlete") - .WithMany("Activities") - .HasForeignKey("AthleteId"); - - b.HasOne("Entities.DataSourceEntity", "DataSource") - .WithMany("Activities") - .HasForeignKey("DataSourceId"); - - b.Navigation("Athlete"); - - b.Navigation("DataSource"); - }); - - modelBuilder.Entity("Entities.AthleteEntity", b => - { - b.HasOne("Entities.DataSourceEntity", "DataSource") - .WithMany("Athletes") - .HasForeignKey("DataSourceId"); - - b.Navigation("DataSource"); - }); - - modelBuilder.Entity("Entities.FriendshipEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Follower") - .WithMany("Followers") - .HasForeignKey("FollowerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.AthleteEntity", "Following") - .WithMany("Followings") - .HasForeignKey("FollowingId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Follower"); - - b.Navigation("Following"); - }); - - modelBuilder.Entity("Entities.HeartRateEntity", b => - { - b.HasOne("Entities.ActivityEntity", "Activity") - .WithMany("HeartRates") - .HasForeignKey("ActivityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Activity"); - }); - - modelBuilder.Entity("Entities.NotificationEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Sender") - .WithMany("NotificationsSent") - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Entities.StatisticEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Athlete") - .WithMany("Statistics") - .HasForeignKey("AthleteId"); - - b.Navigation("Athlete"); - }); - - modelBuilder.Entity("Entities.TrainingEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Coach") - .WithMany("TrainingsCoach") - .HasForeignKey("CoachId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Coach"); - }); - - modelBuilder.Entity("Entities.ActivityEntity", b => - { - b.Navigation("HeartRates"); - }); - - modelBuilder.Entity("Entities.AthleteEntity", b => - { - b.Navigation("Activities"); - - b.Navigation("Followers"); - - b.Navigation("Followings"); - - b.Navigation("NotificationsSent"); - - b.Navigation("Statistics"); - - b.Navigation("TrainingsCoach"); - }); - - modelBuilder.Entity("Entities.DataSourceEntity", b => - { - b.Navigation("Activities"); - - b.Navigation("Athletes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/StubbedContextLib/Migrations/20240312203935_MyMigrations.cs b/src/StubbedContextLib/Migrations/20240312203935_MyMigrations.cs deleted file mode 100644 index ee2a463..0000000 --- a/src/StubbedContextLib/Migrations/20240312203935_MyMigrations.cs +++ /dev/null @@ -1,492 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace StubbedContextLib.Migrations -{ - /// - public partial class MyMigrations : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "DataSource", - columns: table => new - { - IdSource = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Type = table.Column(type: "TEXT", maxLength: 100, nullable: false), - Model = table.Column(type: "TEXT", maxLength: 100, nullable: false), - Precision = table.Column(type: "REAL", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_DataSource", x => x.IdSource); - }); - - migrationBuilder.CreateTable( - name: "Athlete", - columns: table => new - { - IdAthlete = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Username = table.Column(type: "TEXT", maxLength: 100, nullable: false), - LastName = table.Column(type: "TEXT", maxLength: 100, nullable: false), - FirstName = table.Column(type: "TEXT", maxLength: 150, nullable: false), - Email = table.Column(type: "TEXT", maxLength: 100, nullable: false), - Sexe = table.Column(type: "TEXT", maxLength: 1, nullable: false), - Length = table.Column(type: "REAL", nullable: false), - Weight = table.Column(type: "REAL", nullable: false), - Password = table.Column(type: "TEXT", nullable: false), - DateOfBirth = table.Column(type: "TEXT", nullable: false), - IsCoach = table.Column(type: "INTEGER", nullable: false), - ProfilPicture = table.Column(type: "BLOB", nullable: false), - DataSourceId = table.Column(type: "INTEGER", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Athlete", x => x.IdAthlete); - table.ForeignKey( - name: "FK_Athlete_DataSource_DataSourceId", - column: x => x.DataSourceId, - principalTable: "DataSource", - principalColumn: "IdSource"); - }); - - migrationBuilder.CreateTable( - name: "Activity", - columns: table => new - { - IdActivity = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Type = table.Column(type: "TEXT", maxLength: 100, nullable: false), - Date = table.Column(type: "TEXT", nullable: false), - StartTime = table.Column(type: "TEXT", nullable: false), - EndTime = table.Column(type: "TEXT", nullable: false), - EffortFelt = table.Column(type: "INTEGER", nullable: false), - Variability = table.Column(type: "REAL", nullable: false), - Variance = table.Column(type: "REAL", nullable: false), - StandardDeviation = table.Column(type: "REAL", nullable: false), - Average = table.Column(type: "REAL", nullable: false), - Maximum = table.Column(type: "INTEGER", nullable: false), - Minimum = table.Column(type: "INTEGER", nullable: false), - AverageTemperature = table.Column(type: "REAL", nullable: false), - HasAutoPause = table.Column(type: "INTEGER", nullable: false), - DataSourceId = table.Column(type: "INTEGER", nullable: false), - AthleteId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Activity", x => x.IdActivity); - table.ForeignKey( - name: "FK_Activity_Athlete_AthleteId", - column: x => x.AthleteId, - principalTable: "Athlete", - principalColumn: "IdAthlete"); - table.ForeignKey( - name: "FK_Activity_DataSource_DataSourceId", - column: x => x.DataSourceId, - principalTable: "DataSource", - principalColumn: "IdSource"); - }); - - migrationBuilder.CreateTable( - name: "FriendshipEntity", - columns: table => new - { - FollowingId = table.Column(type: "INTEGER", nullable: false), - FollowerId = table.Column(type: "INTEGER", nullable: false), - StartDate = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_FriendshipEntity", x => new { x.FollowingId, x.FollowerId }); - table.ForeignKey( - name: "FK_FriendshipEntity_Athlete_FollowerId", - column: x => x.FollowerId, - principalTable: "Athlete", - principalColumn: "IdAthlete", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_FriendshipEntity_Athlete_FollowingId", - column: x => x.FollowingId, - principalTable: "Athlete", - principalColumn: "IdAthlete", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Notification", - columns: table => new - { - IdNotif = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Message = table.Column(type: "TEXT", maxLength: 100, nullable: false), - Date = table.Column(type: "TEXT", nullable: false), - Statut = table.Column(type: "INTEGER", nullable: false), - Urgence = table.Column(type: "TEXT", maxLength: 100, nullable: false), - SenderId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Notification", x => x.IdNotif); - table.ForeignKey( - name: "FK_Notification_Athlete_SenderId", - column: x => x.SenderId, - principalTable: "Athlete", - principalColumn: "IdAthlete", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Statistic", - columns: table => new - { - IdStatistic = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Weight = table.Column(type: "REAL", nullable: false), - AverageHeartRate = table.Column(type: "REAL", nullable: false), - MaximumHeartRate = table.Column(type: "REAL", nullable: false), - AverageCaloriesBurned = table.Column(type: "REAL", nullable: false), - Date = table.Column(type: "TEXT", nullable: false), - AthleteId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Statistic", x => x.IdStatistic); - table.ForeignKey( - name: "FK_Statistic_Athlete_AthleteId", - column: x => x.AthleteId, - principalTable: "Athlete", - principalColumn: "IdAthlete"); - }); - - migrationBuilder.CreateTable( - name: "Training", - columns: table => new - { - IdTraining = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Date = table.Column(type: "TEXT", nullable: false), - Description = table.Column(type: "TEXT", maxLength: 300, nullable: true), - Latitude = table.Column(type: "REAL", nullable: false), - Longitude = table.Column(type: "REAL", nullable: false), - FeedBack = table.Column(type: "TEXT", maxLength: 300, nullable: true), - CoachId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Training", x => x.IdTraining); - table.ForeignKey( - name: "FK_Training_Athlete_CoachId", - column: x => x.CoachId, - principalTable: "Athlete", - principalColumn: "IdAthlete", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "HeartRate", - columns: table => new - { - IdHeartRate = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Altitude = table.Column(type: "REAL", nullable: false), - Time = table.Column(type: "TEXT", nullable: false), - Temperature = table.Column(type: "REAL", nullable: false), - Bpm = table.Column(type: "INTEGER", nullable: false), - Longitude = table.Column(type: "REAL", nullable: false), - Latitude = table.Column(type: "REAL", nullable: false), - ActivityId = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_HeartRate", x => x.IdHeartRate); - table.ForeignKey( - name: "FK_HeartRate_Activity_ActivityId", - column: x => x.ActivityId, - principalTable: "Activity", - principalColumn: "IdActivity", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AthleteEntityNotificationEntity", - columns: table => new - { - NotificationsReceivedIdNotif = table.Column(type: "INTEGER", nullable: false), - ReceiversIdAthlete = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AthleteEntityNotificationEntity", x => new { x.NotificationsReceivedIdNotif, x.ReceiversIdAthlete }); - table.ForeignKey( - name: "FK_AthleteEntityNotificationEntity_Athlete_ReceiversIdAthlete", - column: x => x.ReceiversIdAthlete, - principalTable: "Athlete", - principalColumn: "IdAthlete", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AthleteEntityNotificationEntity_Notification_NotificationsReceivedIdNotif", - column: x => x.NotificationsReceivedIdNotif, - principalTable: "Notification", - principalColumn: "IdNotif", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AthleteEntityTrainingEntity", - columns: table => new - { - AthletesIdAthlete = table.Column(type: "INTEGER", nullable: false), - TrainingsAthleteIdTraining = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AthleteEntityTrainingEntity", x => new { x.AthletesIdAthlete, x.TrainingsAthleteIdTraining }); - table.ForeignKey( - name: "FK_AthleteEntityTrainingEntity_Athlete_AthletesIdAthlete", - column: x => x.AthletesIdAthlete, - principalTable: "Athlete", - principalColumn: "IdAthlete", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AthleteEntityTrainingEntity_Training_TrainingsAthleteIdTraining", - column: x => x.TrainingsAthleteIdTraining, - principalTable: "Training", - principalColumn: "IdTraining", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - table: "Athlete", - columns: new[] { "IdAthlete", "DataSourceId", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Length", "Password", "ProfilPicture", "Sexe", "Username", "Weight" }, - values: new object[,] - { - { 1, null, new DateOnly(1990, 1, 1), "john.doe@example.com", "John", true, "Doe", 1.8, "password123", new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, "M", "Doe", 75f }, - { 3, null, new DateOnly(1992, 1, 1), "paul.martin@example.com", "Paul", true, "Martin", 1.75, "super789", new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, "M", "Martin", 68f }, - { 4, null, new DateOnly(1993, 1, 1), "anna.brown@example.com", "Anna", false, "Brown", 1.7, "test000", new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, "F", "Brown", 58f } - }); - - migrationBuilder.InsertData( - table: "DataSource", - columns: new[] { "IdSource", "Model", "Precision", "Type" }, - values: new object[,] - { - { 1, "Garmin", 0.5f, "Smartwatch" }, - { 2, "Polar", 0.5f, "Smartwatch" }, - { 3, "Suunto", 0.5f, "Smartwatch" }, - { 4, "Fitbit", 0.5f, "Smartwatch" }, - { 5, "Apple Watch", 0.5f, "Smartwatch" } - }); - - migrationBuilder.InsertData( - table: "Activity", - columns: new[] { "IdActivity", "AthleteId", "Average", "AverageTemperature", "DataSourceId", "Date", "EffortFelt", "EndTime", "HasAutoPause", "Maximum", "Minimum", "StandardDeviation", "StartTime", "Type", "Variability", "Variance" }, - values: new object[,] - { - { 1, 1, 0.5f, 20f, 1, new DateOnly(2023, 1, 10), 5, new TimeOnly(14, 0, 22), false, 0, 0, 0.5f, new TimeOnly(13, 0, 34), "Running", 0.5f, 0.5f }, - { 3, 1, 0.5f, 20f, 1, new DateOnly(2023, 12, 10), 5, new TimeOnly(15, 2, 22), false, 0, 0, 0.5f, new TimeOnly(13, 30, 34), "Swimming", 0.5f, 0.5f }, - { 5, 4, 0.5f, 20f, 4, new DateOnly(2024, 1, 12), 5, new TimeOnly(9, 0, 22), false, 0, 0, 0.5f, new TimeOnly(7, 45, 34), "Hiking", 0.5f, 0.5f }, - { 6, 4, 0.5f, 20f, 4, new DateOnly(2024, 1, 27), 5, new TimeOnly(14, 0, 22), false, 0, 0, 0.5f, new TimeOnly(13, 30, 1), "Climbing", 0.5f, 0.5f }, - { 7, 3, 0.5f, 20f, 5, new DateOnly(2024, 2, 22), 5, new TimeOnly(23, 50, 58), false, 0, 0, 0.5f, new TimeOnly(22, 0, 34), "Yoga", 0.5f, 0.5f } - }); - - migrationBuilder.InsertData( - table: "Athlete", - columns: new[] { "IdAthlete", "DataSourceId", "DateOfBirth", "Email", "FirstName", "IsCoach", "LastName", "Length", "Password", "ProfilPicture", "Sexe", "Username", "Weight" }, - values: new object[,] - { - { 2, 1, new DateOnly(1995, 1, 1), "jane.smith@exemple.com", "Jane", false, "Smith", 1.6499999999999999, "secure456", new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, "F", "Smith", 60f }, - { 5, 3, new DateOnly(1991, 1, 1), "bruce.lee@example.com", "Bruce", false, "Lee", 2.0, "hello321", new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, "M", "Lee", 90f } - }); - - migrationBuilder.InsertData( - table: "FriendshipEntity", - columns: new[] { "FollowerId", "FollowingId", "StartDate" }, - values: new object[,] - { - { 1, 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, - { 1, 4, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) } - }); - - migrationBuilder.InsertData( - table: "Notification", - columns: new[] { "IdNotif", "Date", "Message", "SenderId", "Statut", "Urgence" }, - values: new object[,] - { - { 1, new DateTime(2023, 12, 25, 13, 0, 40, 0, DateTimeKind.Unspecified), "You have a new activity to check", 1, true, "A" }, - { 3, new DateTime(2023, 12, 26, 16, 10, 4, 0, DateTimeKind.Unspecified), "You have a new heart rate to check", 3, true, "2" }, - { 4, new DateTime(2024, 1, 12, 9, 30, 50, 0, DateTimeKind.Unspecified), "You have a new data source to check", 4, false, "1" } - }); - - migrationBuilder.InsertData( - table: "Statistic", - columns: new[] { "IdStatistic", "AthleteId", "AverageCaloriesBurned", "AverageHeartRate", "Date", "MaximumHeartRate", "Weight" }, - values: new object[,] - { - { 1, 1, 500.0, 120.0, new DateOnly(2021, 12, 12), 180.0, 75f }, - { 3, 1, 550.0, 125.0, new DateOnly(2022, 12, 30), 185.0, 68f }, - { 4, 3, 650.0, 135.0, new DateOnly(2023, 2, 20), 195.0, 58f }, - { 5, 4, 450.0, 110.0, new DateOnly(2024, 1, 10), 170.0, 90f } - }); - - migrationBuilder.InsertData( - table: "Training", - columns: new[] { "IdTraining", "CoachId", "Date", "Description", "FeedBack", "Latitude", "Longitude" }, - values: new object[,] - { - { 1, 1, new DateOnly(2024, 1, 19), "Running", "Good", 48.8566f, 2.3522f }, - { 3, 4, new DateOnly(2024, 2, 21), null, "Good", 48.8566f, 2.3522f }, - { 4, 3, new DateOnly(2024, 2, 22), "Running", "Good", 48.8566f, 2.3522f }, - { 5, 1, new DateOnly(2024, 2, 23), "Cycling", null, 48.8566f, 2.3522f } - }); - - migrationBuilder.InsertData( - table: "Activity", - columns: new[] { "IdActivity", "AthleteId", "Average", "AverageTemperature", "DataSourceId", "Date", "EffortFelt", "EndTime", "HasAutoPause", "Maximum", "Minimum", "StandardDeviation", "StartTime", "Type", "Variability", "Variance" }, - values: new object[,] - { - { 2, 2, 0.5f, 20f, 2, new DateOnly(2023, 1, 25), 5, new TimeOnly(14, 0, 22), false, 0, 0, 0.5f, new TimeOnly(13, 4, 34), "Cycling", 0.5f, 0.5f }, - { 4, 5, 0.5f, 20f, 3, new DateOnly(2024, 1, 2), 5, new TimeOnly(16, 1, 55), false, 0, 0, 0.5f, new TimeOnly(15, 0, 0), "Walking", 0.5f, 0.5f } - }); - - migrationBuilder.InsertData( - table: "FriendshipEntity", - columns: new[] { "FollowerId", "FollowingId", "StartDate" }, - values: new object[,] - { - { 2, 1, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, - { 1, 2, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, - { 2, 3, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) }, - { 1, 5, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) } - }); - - migrationBuilder.InsertData( - table: "HeartRate", - columns: new[] { "IdHeartRate", "ActivityId", "Altitude", "Bpm", "Latitude", "Longitude", "Temperature", "Time" }, - values: new object[,] - { - { 1, 1, 0.0, 60, 66f, 35f, 20f, new TimeOnly(13, 0, 30) }, - { 3, 1, 11.0, 71, 66f, 36f, 20f, new TimeOnly(13, 0, 32) } - }); - - migrationBuilder.InsertData( - table: "Notification", - columns: new[] { "IdNotif", "Date", "Message", "SenderId", "Statut", "Urgence" }, - values: new object[,] - { - { 2, new DateTime(2023, 12, 26, 13, 10, 40, 0, DateTimeKind.Unspecified), "You have a new athlete to check", 2, false, "3" }, - { 5, new DateTime(2024, 2, 22, 12, 10, 0, 0, DateTimeKind.Unspecified), "You have a new notification to check", 5, true, "3" } - }); - - migrationBuilder.InsertData( - table: "Statistic", - columns: new[] { "IdStatistic", "AthleteId", "AverageCaloriesBurned", "AverageHeartRate", "Date", "MaximumHeartRate", "Weight" }, - values: new object[] { 2, 2, 600.0, 130.0, new DateOnly(2021, 1, 11), 190.0, 60f }); - - migrationBuilder.InsertData( - table: "Training", - columns: new[] { "IdTraining", "CoachId", "Date", "Description", "FeedBack", "Latitude", "Longitude" }, - values: new object[] { 2, 5, new DateOnly(2024, 2, 20), "Cycling", null, 48.8566f, 2.3522f }); - - migrationBuilder.InsertData( - table: "HeartRate", - columns: new[] { "IdHeartRate", "ActivityId", "Altitude", "Bpm", "Latitude", "Longitude", "Temperature", "Time" }, - values: new object[,] - { - { 2, 2, 10.0, 65, 67f, 35f, 20.5f, new TimeOnly(13, 0, 31) }, - { 4, 2, 12.0, 75, 67f, 36f, 20.5f, new TimeOnly(13, 0, 33) }, - { 5, 4, 13.0, 80, 66f, 37f, 20f, new TimeOnly(13, 0, 34) } - }); - - migrationBuilder.CreateIndex( - name: "IX_Activity_AthleteId", - table: "Activity", - column: "AthleteId"); - - migrationBuilder.CreateIndex( - name: "IX_Activity_DataSourceId", - table: "Activity", - column: "DataSourceId"); - - migrationBuilder.CreateIndex( - name: "IX_Athlete_DataSourceId", - table: "Athlete", - column: "DataSourceId"); - - migrationBuilder.CreateIndex( - name: "IX_AthleteEntityNotificationEntity_ReceiversIdAthlete", - table: "AthleteEntityNotificationEntity", - column: "ReceiversIdAthlete"); - - migrationBuilder.CreateIndex( - name: "IX_AthleteEntityTrainingEntity_TrainingsAthleteIdTraining", - table: "AthleteEntityTrainingEntity", - column: "TrainingsAthleteIdTraining"); - - migrationBuilder.CreateIndex( - name: "IX_FriendshipEntity_FollowerId", - table: "FriendshipEntity", - column: "FollowerId"); - - migrationBuilder.CreateIndex( - name: "IX_HeartRate_ActivityId", - table: "HeartRate", - column: "ActivityId"); - - migrationBuilder.CreateIndex( - name: "IX_Notification_SenderId", - table: "Notification", - column: "SenderId"); - - migrationBuilder.CreateIndex( - name: "IX_Statistic_AthleteId", - table: "Statistic", - column: "AthleteId"); - - migrationBuilder.CreateIndex( - name: "IX_Training_CoachId", - table: "Training", - column: "CoachId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AthleteEntityNotificationEntity"); - - migrationBuilder.DropTable( - name: "AthleteEntityTrainingEntity"); - - migrationBuilder.DropTable( - name: "FriendshipEntity"); - - migrationBuilder.DropTable( - name: "HeartRate"); - - migrationBuilder.DropTable( - name: "Statistic"); - - migrationBuilder.DropTable( - name: "Notification"); - - migrationBuilder.DropTable( - name: "Training"); - - migrationBuilder.DropTable( - name: "Activity"); - - migrationBuilder.DropTable( - name: "Athlete"); - - migrationBuilder.DropTable( - name: "DataSource"); - } - } -} diff --git a/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs b/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs deleted file mode 100644 index d8803de..0000000 --- a/src/StubbedContextLib/Migrations/TrainingStubbedContextModelSnapshot.cs +++ /dev/null @@ -1,983 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using StubbedContextLib; - -#nullable disable - -namespace StubbedContextLib.Migrations -{ - [DbContext(typeof(TrainingStubbedContext))] - partial class TrainingStubbedContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.2"); - - modelBuilder.Entity("AthleteEntityNotificationEntity", b => - { - b.Property("NotificationsReceivedIdNotif") - .HasColumnType("INTEGER"); - - b.Property("ReceiversIdAthlete") - .HasColumnType("INTEGER"); - - b.HasKey("NotificationsReceivedIdNotif", "ReceiversIdAthlete"); - - b.HasIndex("ReceiversIdAthlete"); - - b.ToTable("AthleteEntityNotificationEntity"); - }); - - modelBuilder.Entity("AthleteEntityTrainingEntity", b => - { - b.Property("AthletesIdAthlete") - .HasColumnType("INTEGER"); - - b.Property("TrainingsAthleteIdTraining") - .HasColumnType("INTEGER"); - - b.HasKey("AthletesIdAthlete", "TrainingsAthleteIdTraining"); - - b.HasIndex("TrainingsAthleteIdTraining"); - - b.ToTable("AthleteEntityTrainingEntity"); - }); - - modelBuilder.Entity("Entities.ActivityEntity", b => - { - b.Property("IdActivity") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("AthleteId") - .HasColumnType("INTEGER"); - - b.Property("Average") - .HasColumnType("REAL"); - - b.Property("AverageTemperature") - .HasColumnType("REAL"); - - b.Property("DataSourceId") - .HasColumnType("INTEGER"); - - b.Property("Date") - .HasColumnType("TEXT"); - - b.Property("EffortFelt") - .HasColumnType("INTEGER"); - - b.Property("EndTime") - .HasColumnType("TEXT"); - - b.Property("HasAutoPause") - .HasColumnType("INTEGER"); - - b.Property("Maximum") - .HasColumnType("INTEGER"); - - b.Property("Minimum") - .HasColumnType("INTEGER"); - - b.Property("StandardDeviation") - .HasColumnType("REAL"); - - b.Property("StartTime") - .HasColumnType("TEXT"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Variability") - .HasColumnType("REAL"); - - b.Property("Variance") - .HasColumnType("REAL"); - - b.HasKey("IdActivity"); - - b.HasIndex("AthleteId"); - - b.HasIndex("DataSourceId"); - - b.ToTable("Activity"); - - b.HasData( - new - { - IdActivity = 1, - AthleteId = 1, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 1, - Date = new DateOnly(2023, 1, 10), - EffortFelt = 5, - EndTime = new TimeOnly(14, 0, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(13, 0, 34), - Type = "Running", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 2, - AthleteId = 2, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 2, - Date = new DateOnly(2023, 1, 25), - EffortFelt = 5, - EndTime = new TimeOnly(14, 0, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(13, 4, 34), - Type = "Cycling", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 3, - AthleteId = 1, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 1, - Date = new DateOnly(2023, 12, 10), - EffortFelt = 5, - EndTime = new TimeOnly(15, 2, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(13, 30, 34), - Type = "Swimming", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 4, - AthleteId = 5, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 3, - Date = new DateOnly(2024, 1, 2), - EffortFelt = 5, - EndTime = new TimeOnly(16, 1, 55), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(15, 0, 0), - Type = "Walking", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 5, - AthleteId = 4, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 4, - Date = new DateOnly(2024, 1, 12), - EffortFelt = 5, - EndTime = new TimeOnly(9, 0, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(7, 45, 34), - Type = "Hiking", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 6, - AthleteId = 4, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 4, - Date = new DateOnly(2024, 1, 27), - EffortFelt = 5, - EndTime = new TimeOnly(14, 0, 22), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(13, 30, 1), - Type = "Climbing", - Variability = 0.5f, - Variance = 0.5f - }, - new - { - IdActivity = 7, - AthleteId = 3, - Average = 0.5f, - AverageTemperature = 20f, - DataSourceId = 5, - Date = new DateOnly(2024, 2, 22), - EffortFelt = 5, - EndTime = new TimeOnly(23, 50, 58), - HasAutoPause = false, - Maximum = 0, - Minimum = 0, - StandardDeviation = 0.5f, - StartTime = new TimeOnly(22, 0, 34), - Type = "Yoga", - Variability = 0.5f, - Variance = 0.5f - }); - }); - - modelBuilder.Entity("Entities.AthleteEntity", b => - { - b.Property("IdAthlete") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("DataSourceId") - .HasColumnType("INTEGER"); - - b.Property("DateOfBirth") - .HasColumnType("TEXT"); - - b.Property("Email") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("TEXT"); - - b.Property("IsCoach") - .HasColumnType("INTEGER"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Length") - .HasColumnType("REAL"); - - b.Property("Password") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("ProfilPicture") - .IsRequired() - .HasColumnType("BLOB"); - - b.Property("Sexe") - .IsRequired() - .HasMaxLength(1) - .HasColumnType("TEXT"); - - b.Property("Username") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Weight") - .HasColumnType("REAL"); - - b.HasKey("IdAthlete"); - - b.HasIndex("DataSourceId"); - - b.ToTable("Athlete"); - - b.HasData( - new - { - IdAthlete = 1, - DateOfBirth = new DateOnly(1990, 1, 1), - Email = "john.doe@example.com", - FirstName = "John", - IsCoach = true, - LastName = "Doe", - Length = 1.8, - Password = "password123", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "M", - Username = "Doe", - Weight = 75f - }, - new - { - IdAthlete = 2, - DataSourceId = 1, - DateOfBirth = new DateOnly(1995, 1, 1), - Email = "jane.smith@exemple.com", - FirstName = "Jane", - IsCoach = false, - LastName = "Smith", - Length = 1.6499999999999999, - Password = "secure456", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "F", - Username = "Smith", - Weight = 60f - }, - new - { - IdAthlete = 3, - DateOfBirth = new DateOnly(1992, 1, 1), - Email = "paul.martin@example.com", - FirstName = "Paul", - IsCoach = true, - LastName = "Martin", - Length = 1.75, - Password = "super789", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "M", - Username = "Martin", - Weight = 68f - }, - new - { - IdAthlete = 4, - DateOfBirth = new DateOnly(1993, 1, 1), - Email = "anna.brown@example.com", - FirstName = "Anna", - IsCoach = false, - LastName = "Brown", - Length = 1.7, - Password = "test000", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "F", - Username = "Brown", - Weight = 58f - }, - new - { - IdAthlete = 5, - DataSourceId = 3, - DateOfBirth = new DateOnly(1991, 1, 1), - Email = "bruce.lee@example.com", - FirstName = "Bruce", - IsCoach = false, - LastName = "Lee", - Length = 2.0, - Password = "hello321", - ProfilPicture = new byte[] { 34, 85, 107, 108, 71, 82, 116, 119, 68, 65, 65, 66, 88, 82, 85, 74, 81, 86, 108, 65, 52, 73, 78, 65, 68, 65, 65, 65, 119, 69, 65, 67, 100, 65, 83, 111, 113, 65, 67, 111, 65, 65, 77, 65, 83, 74, 90, 103, 67, 100, 77, 111, 83, 67, 122, 54, 53, 53, 110, 100, 85, 52, 88, 88, 65, 80, 50, 121, 88, 73, 103, 101, 53, 110, 101, 77, 47, 81, 100, 54, 87, 67, 102, 79, 56, 101, 118, 111, 106, 50, 83, 48, 65, 47, 112, 55, 43, 102, 48, 65, 110, 56, 53, 99, 66, 120, 108, 76, 68, 103, 80, 67, 56, 106, 79, 47, 48, 110, 115, 108, 47, 49, 51, 47, 79, 56, 118, 118, 122, 106, 55, 65, 102, 56, 115, 47, 112, 51, 47, 72, 52, 70, 85, 54, 116, 100, 52, 77, 67, 119, 113, 50, 51, 122, 49, 72, 50, 117, 122, 111, 75, 73, 88, 97, 113, 74, 110, 105, 80, 73, 47, 98, 82, 77, 102, 56, 113, 122, 118, 48, 90, 112, 43, 72, 69, 49, 82, 67, 66, 119, 53, 87, 81, 49, 106, 47, 74, 111, 118, 100, 77, 49, 70, 83, 53, 50, 43, 81, 99, 97, 65, 65, 65, 47, 118, 47, 43, 78, 120, 85, 52, 68, 112, 80, 107, 51, 43, 120, 81, 80, 87, 55, 116, 99, 109, 85, 82, 83, 111, 57, 118, 67, 52, 113, 99, 43, 88, 77, 120, 78, 86, 66, 122, 69, 77, 53, 69, 56, 97, 99, 116, 68, 122, 57, 56, 103, 109, 119, 84, 88, 103, 68, 54, 50, 101, 57, 69, 109, 71, 47, 101, 114, 118, 100, 100, 50, 111, 118, 70, 70, 83, 117, 120, 89, 112, 112, 87, 108, 47, 119, 116, 97, 88, 51, 114, 107, 110, 48, 120, 114, 116, 56, 113, 79, 113, 108, 47, 53, 73, 50, 106, 102, 76, 79, 110, 67, 85, 48, 107, 65, 76, 76, 99, 87, 52, 70, 47, 119, 84, 106, 85, 49, 48, 113, 115, 120, 90, 88, 87, 57, 102, 120, 97, 117, 67, 54, 79, 80, 86, 82, 70, 50, 56, 115, 99, 57, 52, 86, 57, 111, 99, 109, 111, 83, 87, 121, 43, 115, 102, 54, 106, 87, 51, 118, 89, 107, 86, 79, 104, 43, 103, 69, 47, 82, 69, 48, 76, 54, 98, 50, 100, 51, 111, 70, 121, 72, 109, 107, 82, 74, 110, 102, 89, 119, 71, 56, 111, 51, 112, 54, 102, 118, 57, 112, 105, 118, 78, 70, 53, 97, 111, 112, 73, 66, 122, 70, 110, 106, 122, 119, 98, 47, 86, 113, 83, 113, 51, 47, 98, 43, 77, 87, 75, 70, 109, 106, 114, 56, 84, 49, 113, 101, 52, 47, 102, 73, 84, 111, 50, 118, 66, 87, 69, 113, 68, 121, 111, 103, 86, 51, 90, 86, 71, 110, 68, 86, 105, 50, 68, 98, 105, 69, 70, 86, 83, 85, 114, 50, 101, 88, 84, 78, 90, 81, 57, 86, 47, 68, 57, 81, 67, 47, 43, 118, 67, 82, 53, 84, 71, 121, 88, 57, 81, 79, 86, 66, 103, 116, 65, 89, 116, 109, 47, 90, 84, 73, 119, 122, 80, 69, 89, 66, 57, 78, 114, 86, 49, 78, 101, 79, 49, 47, 115, 65, 122, 55, 56, 117, 48, 116, 87, 53, 57, 114, 48, 73, 43, 83, 79, 53, 74, 103, 109, 51, 66, 57, 105, 49, 116, 111, 82, 117, 114, 122, 72, 118, 57, 69, 90, 74, 57, 121, 90, 76, 56, 110, 97, 102, 98, 47, 84, 49, 70, 97, 111, 80, 68, 107, 117, 74, 102, 77, 43, 105, 80, 115, 48, 106, 56, 120, 110, 83, 55, 84, 97, 85, 47, 103, 69, 75, 48, 119, 67, 120, 101, 68, 89, 82, 89, 116, 74, 120, 57, 106, 52, 104, 85, 81, 113, 55, 112, 65, 117, 47, 84, 50, 121, 87, 121, 48, 118, 106, 99, 85, 72, 107, 105, 57, 53, 50, 90, 78, 98, 88, 110, 88, 120, 66, 56, 109, 56, 112, 86, 53, 120, 57, 69, 49, 115, 102, 76, 106, 53, 77, 90, 69, 103, 112, 85, 50, 88, 86, 56, 82, 72, 114, 86, 118, 87, 110, 105, 67, 106, 115, 102, 54, 118, 103, 120, 109, 82, 55, 43, 75, 116, 119, 73, 98, 77, 106, 97, 104, 105, 116, 85, 71, 116, 72, 101, 116, 49, 87, 100, 76, 43, 56, 77, 109, 100, 76, 50, 57, 105, 81, 74, 67, 51, 55, 112, 68, 88, 105, 114, 105, 114, 49, 78, 105, 98, 120, 75, 75, 104, 70, 89, 82, 117, 74, 51, 120, 87, 57, 79, 48, 114, 57, 43, 86, 110, 104, 56, 100, 105, 113, 98, 66, 117, 88, 113, 68, 98, 89, 82, 47, 77, 83, 111, 72, 118, 115, 99, 79, 67, 109, 50, 116, 57, 53, 100, 78, 53, 87, 66, 100, 82, 85, 111, 68, 55, 89, 67, 71, 47, 90, 72, 87, 99, 55, 89, 112, 118, 47, 120, 47, 97, 108, 52, 102, 107, 66, 50, 108, 90, 108, 89, 104, 86, 87, 72, 120, 106, 97, 111, 101, 70, 57, 106, 69, 80, 73, 48, 103, 65, 78, 53, 88, 115, 118, 85, 73, 54, 104, 98, 122, 69, 122, 87, 77, 115, 78, 87, 47, 49, 111, 114, 107, 78, 79, 110, 108, 115, 107, 97, 108, 103, 109, 112, 73, 52, 66, 50, 114, 109, 52, 71, 99, 55, 76, 78, 117, 105, 43, 77, 117, 77, 66, 114, 112, 110, 66, 118, 76, 107, 98, 89, 88, 57, 101, 120, 101, 57, 103, 56, 116, 117, 55, 119, 76, 116, 55, 83, 99, 79, 106, 68, 99, 76, 57, 57, 111, 79, 121, 82, 56, 57, 77, 104, 57, 76, 56, 114, 100, 52, 43, 52, 51, 43, 74, 81, 121, 82, 54, 116, 115, 73, 102, 99, 80, 74, 111, 54, 84, 54, 70, 120, 72, 102, 49, 49, 100, 47, 77, 71, 97, 121, 74, 105, 43, 83, 87, 99, 116, 47, 117, 104, 118, 118, 117, 97, 48, 111, 79, 104, 43, 122, 88, 78, 73, 97, 85, 122, 103, 111, 66, 109, 117, 49, 88, 85, 76, 106, 107, 112, 117, 65, 48, 71, 104, 122, 99, 116, 102, 51, 48, 106, 98, 89, 49, 65, 79, 77, 52, 57, 113, 98, 77, 90, 82, 89, 83, 57, 65, 43, 48, 83, 49, 72, 114, 72, 80, 110, 119, 82, 118, 112, 81, 89, 47, 83, 106, 52, 120, 75, 80, 110, 48, 103, 100, 112, 118, 47, 43, 105, 84, 98, 75, 74, 98, 56, 122, 107, 80, 67, 52, 47, 57, 97, 102, 48, 74, 118, 101, 115, 97, 43, 71, 68, 71, 48, 47, 105, 119, 51, 84, 115, 119, 101, 110, 77, 104, 113, 108, 104, 55, 66, 77, 57, 77, 87, 53, 116, 120, 112, 101, 98, 108, 115, 66, 121, 120, 52, 87, 110, 74, 47, 111, 72, 118, 54, 99, 99, 48, 100, 109, 77, 55, 116, 115, 86, 51, 54, 108, 89, 107, 67, 84, 85, 88, 69, 102, 47, 48, 101, 75, 108, 110, 102, 105, 118, 110, 78, 48, 103, 49, 103, 43, 106, 47, 76, 107, 57, 101, 116, 47, 117, 111, 97, 54, 84, 70, 67, 87, 48, 72, 103, 119, 70, 79, 73, 86, 70, 117, 109, 69, 89, 100, 84, 54, 55, 53, 80, 102, 117, 84, 114, 89, 79, 53, 111, 56, 90, 114, 87, 69, 73, 72, 116, 118, 50, 67, 116, 108, 114, 118, 57, 74, 51, 84, 114, 115, 108, 68, 47, 105, 75, 69, 119, 116, 105, 112, 71, 72, 116, 110, 48, 86, 97, 107, 56, 66, 57, 119, 76, 76, 43, 107, 122, 43, 67, 73, 81, 47, 86, 71, 52, 75, 74, 112, 88, 106, 120, 56, 56, 67, 101, 67, 67, 52, 88, 97, 71, 105, 116, 69, 100, 106, 65, 65, 65, 34 }, - Sexe = "M", - Username = "Lee", - Weight = 90f - }); - }); - - modelBuilder.Entity("Entities.DataSourceEntity", b => - { - b.Property("IdSource") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Model") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("Precision") - .HasColumnType("REAL"); - - b.Property("Type") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.HasKey("IdSource"); - - b.ToTable("DataSource"); - - b.HasData( - new - { - IdSource = 1, - Model = "Garmin", - Precision = 0.5f, - Type = "Smartwatch" - }, - new - { - IdSource = 2, - Model = "Polar", - Precision = 0.5f, - Type = "Smartwatch" - }, - new - { - IdSource = 3, - Model = "Suunto", - Precision = 0.5f, - Type = "Smartwatch" - }, - new - { - IdSource = 4, - Model = "Fitbit", - Precision = 0.5f, - Type = "Smartwatch" - }, - new - { - IdSource = 5, - Model = "Apple Watch", - Precision = 0.5f, - Type = "Smartwatch" - }); - }); - - modelBuilder.Entity("Entities.FriendshipEntity", b => - { - b.Property("FollowingId") - .HasColumnType("INTEGER"); - - b.Property("FollowerId") - .HasColumnType("INTEGER"); - - b.Property("StartDate") - .HasColumnType("TEXT"); - - b.HasKey("FollowingId", "FollowerId"); - - b.HasIndex("FollowerId"); - - b.ToTable("FriendshipEntity"); - - b.HasData( - new - { - FollowingId = 2, - FollowerId = 1, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 3, - FollowerId = 1, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 4, - FollowerId = 1, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 5, - FollowerId = 1, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 1, - FollowerId = 2, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }, - new - { - FollowingId = 3, - FollowerId = 2, - StartDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) - }); - }); - - modelBuilder.Entity("Entities.HeartRateEntity", b => - { - b.Property("IdHeartRate") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("ActivityId") - .HasColumnType("INTEGER"); - - b.Property("Altitude") - .HasColumnType("REAL"); - - b.Property("Bpm") - .HasColumnType("INTEGER"); - - b.Property("Latitude") - .HasColumnType("REAL"); - - b.Property("Longitude") - .HasColumnType("REAL"); - - b.Property("Temperature") - .HasColumnType("REAL"); - - b.Property("Time") - .HasColumnType("TEXT"); - - b.HasKey("IdHeartRate"); - - b.HasIndex("ActivityId"); - - b.ToTable("HeartRate"); - - b.HasData( - new - { - IdHeartRate = 1, - ActivityId = 1, - Altitude = 0.0, - Bpm = 60, - Latitude = 66f, - Longitude = 35f, - Temperature = 20f, - Time = new TimeOnly(13, 0, 30) - }, - new - { - IdHeartRate = 2, - ActivityId = 2, - Altitude = 10.0, - Bpm = 65, - Latitude = 67f, - Longitude = 35f, - Temperature = 20.5f, - Time = new TimeOnly(13, 0, 31) - }, - new - { - IdHeartRate = 3, - ActivityId = 1, - Altitude = 11.0, - Bpm = 71, - Latitude = 66f, - Longitude = 36f, - Temperature = 20f, - Time = new TimeOnly(13, 0, 32) - }, - new - { - IdHeartRate = 4, - ActivityId = 2, - Altitude = 12.0, - Bpm = 75, - Latitude = 67f, - Longitude = 36f, - Temperature = 20.5f, - Time = new TimeOnly(13, 0, 33) - }, - new - { - IdHeartRate = 5, - ActivityId = 4, - Altitude = 13.0, - Bpm = 80, - Latitude = 66f, - Longitude = 37f, - Temperature = 20f, - Time = new TimeOnly(13, 0, 34) - }); - }); - - modelBuilder.Entity("Entities.NotificationEntity", b => - { - b.Property("IdNotif") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Date") - .HasColumnType("TEXT"); - - b.Property("Message") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.Property("SenderId") - .HasColumnType("INTEGER"); - - b.Property("Statut") - .HasColumnType("INTEGER"); - - b.Property("Urgence") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("TEXT"); - - b.HasKey("IdNotif"); - - b.HasIndex("SenderId"); - - b.ToTable("Notification"); - - b.HasData( - new - { - IdNotif = 1, - Date = new DateTime(2023, 12, 25, 13, 0, 40, 0, DateTimeKind.Unspecified), - Message = "You have a new activity to check", - SenderId = 1, - Statut = true, - Urgence = "A" - }, - new - { - IdNotif = 2, - Date = new DateTime(2023, 12, 26, 13, 10, 40, 0, DateTimeKind.Unspecified), - Message = "You have a new athlete to check", - SenderId = 2, - Statut = false, - Urgence = "3" - }, - new - { - IdNotif = 3, - Date = new DateTime(2023, 12, 26, 16, 10, 4, 0, DateTimeKind.Unspecified), - Message = "You have a new heart rate to check", - SenderId = 3, - Statut = true, - Urgence = "2" - }, - new - { - IdNotif = 4, - Date = new DateTime(2024, 1, 12, 9, 30, 50, 0, DateTimeKind.Unspecified), - Message = "You have a new data source to check", - SenderId = 4, - Statut = false, - Urgence = "1" - }, - new - { - IdNotif = 5, - Date = new DateTime(2024, 2, 22, 12, 10, 0, 0, DateTimeKind.Unspecified), - Message = "You have a new notification to check", - SenderId = 5, - Statut = true, - Urgence = "3" - }); - }); - - modelBuilder.Entity("Entities.StatisticEntity", b => - { - b.Property("IdStatistic") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("AthleteId") - .HasColumnType("INTEGER"); - - b.Property("AverageCaloriesBurned") - .HasColumnType("REAL"); - - b.Property("AverageHeartRate") - .HasColumnType("REAL"); - - b.Property("Date") - .HasColumnType("TEXT"); - - b.Property("MaximumHeartRate") - .HasColumnType("REAL"); - - b.Property("Weight") - .HasColumnType("REAL"); - - b.HasKey("IdStatistic"); - - b.HasIndex("AthleteId"); - - b.ToTable("Statistic"); - - b.HasData( - new - { - IdStatistic = 1, - AthleteId = 1, - AverageCaloriesBurned = 500.0, - AverageHeartRate = 120.0, - Date = new DateOnly(2021, 12, 12), - MaximumHeartRate = 180.0, - Weight = 75f - }, - new - { - IdStatistic = 2, - AthleteId = 2, - AverageCaloriesBurned = 600.0, - AverageHeartRate = 130.0, - Date = new DateOnly(2021, 1, 11), - MaximumHeartRate = 190.0, - Weight = 60f - }, - new - { - IdStatistic = 3, - AthleteId = 1, - AverageCaloriesBurned = 550.0, - AverageHeartRate = 125.0, - Date = new DateOnly(2022, 12, 30), - MaximumHeartRate = 185.0, - Weight = 68f - }, - new - { - IdStatistic = 4, - AthleteId = 3, - AverageCaloriesBurned = 650.0, - AverageHeartRate = 135.0, - Date = new DateOnly(2023, 2, 20), - MaximumHeartRate = 195.0, - Weight = 58f - }, - new - { - IdStatistic = 5, - AthleteId = 4, - AverageCaloriesBurned = 450.0, - AverageHeartRate = 110.0, - Date = new DateOnly(2024, 1, 10), - MaximumHeartRate = 170.0, - Weight = 90f - }); - }); - - modelBuilder.Entity("Entities.TrainingEntity", b => - { - b.Property("IdTraining") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("CoachId") - .HasColumnType("INTEGER"); - - b.Property("Date") - .HasColumnType("TEXT"); - - b.Property("Description") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("FeedBack") - .HasMaxLength(300) - .HasColumnType("TEXT"); - - b.Property("Latitude") - .HasColumnType("REAL"); - - b.Property("Longitude") - .HasColumnType("REAL"); - - b.HasKey("IdTraining"); - - b.HasIndex("CoachId"); - - b.ToTable("Training"); - - b.HasData( - new - { - IdTraining = 1, - CoachId = 1, - Date = new DateOnly(2024, 1, 19), - Description = "Running", - FeedBack = "Good", - Latitude = 48.8566f, - Longitude = 2.3522f - }, - new - { - IdTraining = 2, - CoachId = 5, - Date = new DateOnly(2024, 2, 20), - Description = "Cycling", - Latitude = 48.8566f, - Longitude = 2.3522f - }, - new - { - IdTraining = 3, - CoachId = 4, - Date = new DateOnly(2024, 2, 21), - FeedBack = "Good", - Latitude = 48.8566f, - Longitude = 2.3522f - }, - new - { - IdTraining = 4, - CoachId = 3, - Date = new DateOnly(2024, 2, 22), - Description = "Running", - FeedBack = "Good", - Latitude = 48.8566f, - Longitude = 2.3522f - }, - new - { - IdTraining = 5, - CoachId = 1, - Date = new DateOnly(2024, 2, 23), - Description = "Cycling", - Latitude = 48.8566f, - Longitude = 2.3522f - }); - }); - - modelBuilder.Entity("AthleteEntityNotificationEntity", b => - { - b.HasOne("Entities.NotificationEntity", null) - .WithMany() - .HasForeignKey("NotificationsReceivedIdNotif") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.AthleteEntity", null) - .WithMany() - .HasForeignKey("ReceiversIdAthlete") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("AthleteEntityTrainingEntity", b => - { - b.HasOne("Entities.AthleteEntity", null) - .WithMany() - .HasForeignKey("AthletesIdAthlete") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.TrainingEntity", null) - .WithMany() - .HasForeignKey("TrainingsAthleteIdTraining") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Entities.ActivityEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Athlete") - .WithMany("Activities") - .HasForeignKey("AthleteId"); - - b.HasOne("Entities.DataSourceEntity", "DataSource") - .WithMany("Activities") - .HasForeignKey("DataSourceId"); - - b.Navigation("Athlete"); - - b.Navigation("DataSource"); - }); - - modelBuilder.Entity("Entities.AthleteEntity", b => - { - b.HasOne("Entities.DataSourceEntity", "DataSource") - .WithMany("Athletes") - .HasForeignKey("DataSourceId"); - - b.Navigation("DataSource"); - }); - - modelBuilder.Entity("Entities.FriendshipEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Follower") - .WithMany("Followers") - .HasForeignKey("FollowerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Entities.AthleteEntity", "Following") - .WithMany("Followings") - .HasForeignKey("FollowingId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Follower"); - - b.Navigation("Following"); - }); - - modelBuilder.Entity("Entities.HeartRateEntity", b => - { - b.HasOne("Entities.ActivityEntity", "Activity") - .WithMany("HeartRates") - .HasForeignKey("ActivityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Activity"); - }); - - modelBuilder.Entity("Entities.NotificationEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Sender") - .WithMany("NotificationsSent") - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Entities.StatisticEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Athlete") - .WithMany("Statistics") - .HasForeignKey("AthleteId"); - - b.Navigation("Athlete"); - }); - - modelBuilder.Entity("Entities.TrainingEntity", b => - { - b.HasOne("Entities.AthleteEntity", "Coach") - .WithMany("TrainingsCoach") - .HasForeignKey("CoachId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Coach"); - }); - - modelBuilder.Entity("Entities.ActivityEntity", b => - { - b.Navigation("HeartRates"); - }); - - modelBuilder.Entity("Entities.AthleteEntity", b => - { - b.Navigation("Activities"); - - b.Navigation("Followers"); - - b.Navigation("Followings"); - - b.Navigation("NotificationsSent"); - - b.Navigation("Statistics"); - - b.Navigation("TrainingsCoach"); - }); - - modelBuilder.Entity("Entities.DataSourceEntity", b => - { - b.Navigation("Activities"); - - b.Navigation("Athletes"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/StubbedContextLib/StubbedContextLib.csproj b/src/StubbedContextLib/StubbedContextLib.csproj index ecea2c4..bdd147f 100644 --- a/src/StubbedContextLib/StubbedContextLib.csproj +++ b/src/StubbedContextLib/StubbedContextLib.csproj @@ -1,16 +1,16 @@  - - - + + + - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + From 4c21afda8626ed7cbd795a50a4e60ae3e8b890f7 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 06:08:46 +0100 Subject: [PATCH 06/74] fix CI by Removing wrong ref --- src/Entities/AthleteEntity.cs | 1 - src/Entities/Entities.csproj | 7 ------- 2 files changed, 8 deletions(-) diff --git a/src/Entities/AthleteEntity.cs b/src/Entities/AthleteEntity.cs index 65010de..88fac38 100644 --- a/src/Entities/AthleteEntity.cs +++ b/src/Entities/AthleteEntity.cs @@ -8,7 +8,6 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.AspNetCore.Identity; namespace Entities { diff --git a/src/Entities/Entities.csproj b/src/Entities/Entities.csproj index e37f82e..b007a4d 100644 --- a/src/Entities/Entities.csproj +++ b/src/Entities/Entities.csproj @@ -5,11 +5,4 @@ enable enable - - - - ..\..\..\..\..\.nuget\packages\microsoft.extensions.identity.stores\8.0.2\lib\net8.0\Microsoft.Extensions.Identity.Stores.dll - - - From cc834989d52fd7de68b43d103d7f280aca4fe82a Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 06:25:33 +0100 Subject: [PATCH 07/74] fix ci --- src/Entities/AthleteEntity.cs | 2 +- src/HeartTrackAPI/AppBootstrap.cs | 4 --- .../Controllers/ActivityController.cs | 6 ++-- src/HeartTrackAPI/HeartTrackAPI.csproj | 8 +---- src/HeartTrackAPI/Utils/SwaggerOptions.cs | 2 +- .../Manager/Contract/IActivityManager.cs | 1 - src/Model/Model.csproj | 6 ---- src/Model/Service/EmailSender.cs | 31 ------------------- 8 files changed, 7 insertions(+), 53 deletions(-) delete mode 100644 src/Model/Service/EmailSender.cs diff --git a/src/Entities/AthleteEntity.cs b/src/Entities/AthleteEntity.cs index 88fac38..6d6f351 100644 --- a/src/Entities/AthleteEntity.cs +++ b/src/Entities/AthleteEntity.cs @@ -89,7 +89,7 @@ namespace Entities /// public bool IsCoach { get; set; } - public byte[] ProfilPicture { get; set; } + public byte[]? ProfilPicture { get; set; } diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index ce01163..61be631 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -10,11 +10,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using Microsoft.OpenApi.Models; using Model.Manager; -using Model.Service; using Model2Entities; -using StubAPI; -using Swashbuckle.AspNetCore.SwaggerGen; - namespace HeartTrackAPI; diff --git a/src/HeartTrackAPI/Controllers/ActivityController.cs b/src/HeartTrackAPI/Controllers/ActivityController.cs index 3827b10..f5498e3 100644 --- a/src/HeartTrackAPI/Controllers/ActivityController.cs +++ b/src/HeartTrackAPI/Controllers/ActivityController.cs @@ -15,7 +15,6 @@ public class ActivityController : Controller { private readonly IActivityRepository _activityService; private readonly ILogger _logger; - private readonly IActivityManager _activityManager; public ActivityController(IDataManager dataManager, ILogger logger) { @@ -39,9 +38,12 @@ public class ActivityController : Controller } _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(GetActivities), pageRequest); var activities = await _activityService.GetActivities(pageRequest.Index, pageRequest.Count, ActivityOrderCriteria.None, pageRequest.Descending ?? false); + if(activities == null) + { + return BadRequest("No activities found"); + } var pageResponse = new PageResponse(pageRequest.Index, pageRequest.Count, totalCount, activities.Select(a => a.ToDto())); return Ok(pageResponse); - return Ok(); } catch (Exception e) { diff --git a/src/HeartTrackAPI/HeartTrackAPI.csproj b/src/HeartTrackAPI/HeartTrackAPI.csproj index 133b59f..2329d47 100644 --- a/src/HeartTrackAPI/HeartTrackAPI.csproj +++ b/src/HeartTrackAPI/HeartTrackAPI.csproj @@ -29,11 +29,5 @@ - - - - ..\..\..\..\..\.nuget\packages\newtonsoft.json\13.0.1\lib\netstandard2.0\Newtonsoft.Json.dll - - - + diff --git a/src/HeartTrackAPI/Utils/SwaggerOptions.cs b/src/HeartTrackAPI/Utils/SwaggerOptions.cs index 7754a52..e9aed2c 100644 --- a/src/HeartTrackAPI/Utils/SwaggerOptions.cs +++ b/src/HeartTrackAPI/Utils/SwaggerOptions.cs @@ -35,7 +35,7 @@ public class SwaggerOptions: IConfigureNamedOptions /// /// /// - public void Configure(string name, SwaggerGenOptions options) + public void Configure(string? name, SwaggerGenOptions options) { Configure(options); } diff --git a/src/Model/Manager/Contract/IActivityManager.cs b/src/Model/Manager/Contract/IActivityManager.cs index 5722a41..2be28cc 100644 --- a/src/Model/Manager/Contract/IActivityManager.cs +++ b/src/Model/Manager/Contract/IActivityManager.cs @@ -1,4 +1,3 @@ -using Microsoft.AspNetCore.Http; namespace Model.Manager; public interface IActivityManager diff --git a/src/Model/Model.csproj b/src/Model/Model.csproj index a957f97..ead9f5a 100644 --- a/src/Model/Model.csproj +++ b/src/Model/Model.csproj @@ -15,10 +15,4 @@ - - - ..\..\..\..\..\.dotnet\shared\Microsoft.AspNetCore.App\8.0.1\Microsoft.AspNetCore.Identity.dll - - - diff --git a/src/Model/Service/EmailSender.cs b/src/Model/Service/EmailSender.cs deleted file mode 100644 index fc9d5e6..0000000 --- a/src/Model/Service/EmailSender.cs +++ /dev/null @@ -1,31 +0,0 @@ - -using Entities; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Identity.UI.Services; - -namespace Model.Service; - -public class EmailSender : IEmailSender -{ - private IEmailSender _emailSenderImplementation; - - public async Task SendEmailAsync(string email, string subject, string htmlMessage) - { - throw new NotImplementedException(); - } - - public async Task SendConfirmationLinkAsync(AthleteEntity user, string email, string confirmationLink) - { - throw new NotImplementedException(); - } - - public async Task SendPasswordResetLinkAsync(AthleteEntity user, string email, string resetLink) - { - throw new NotImplementedException(); - } - - public async Task SendPasswordResetCodeAsync(AthleteEntity user, string email, string resetCode) - { - throw new NotImplementedException(); - } -} \ No newline at end of file From 3994b52ca900df57d62e14ad269e06bbb673b64e Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 09:39:30 +0100 Subject: [PATCH 08/74] almost done need upload file for activity --- src/APIMappers/ActivityMapper.cs | 4 +- src/APIMappers/UserMappeur.cs | 4 +- src/HeartTrackAPI/AppBootstrap.cs | 4 +- .../Controllers/ActivityController.cs | 87 ++++++++-- .../Controllers/UsersController.cs | 151 +++++++++++++++++- src/HeartTrackAPI/Dockerfile | 3 +- src/HeartTrackAPI/FileUploadSummary.cs | 44 +++++ src/HeartTrackAPI/Program.cs | 4 + src/Model/Activity.cs | 3 +- src/Model/Repository/IActivityRepository.cs | 4 +- src/Model/Repository/IUserRepository.cs | 9 +- src/Model2Entities/ActivityRepository.cs | 10 ++ src/Model2Entities/UserRepository.cs | 15 ++ src/Shared/Extension.cs | 4 +- src/StubAPI/ActivityService.cs | 68 ++++++-- src/StubAPI/AthleteService.cs | 28 +++- src/StubAPI/Extensions.cs | 8 +- 17 files changed, 405 insertions(+), 45 deletions(-) create mode 100644 src/HeartTrackAPI/FileUploadSummary.cs diff --git a/src/APIMappers/ActivityMapper.cs b/src/APIMappers/ActivityMapper.cs index a842429..6013e57 100644 --- a/src/APIMappers/ActivityMapper.cs +++ b/src/APIMappers/ActivityMapper.cs @@ -8,7 +8,7 @@ public static class ActivityMapper { private static GenericMapper _mapper = new GenericMapper(); - public static ActivityDto? ToDto(this Activity activity) + public static ActivityDto ToDto(this Activity activity) { return activity.ToU(_mapper, activityDto => new ActivityDto { @@ -29,7 +29,7 @@ public static class ActivityMapper }); } - public static Activity? ToModel(this ActivityDto activityDto) + public static Activity ToModel(this ActivityDto activityDto) { return activityDto.ToT(_mapper, activity => new Activity { diff --git a/src/APIMappers/UserMappeur.cs b/src/APIMappers/UserMappeur.cs index 6d94da6..96d1375 100644 --- a/src/APIMappers/UserMappeur.cs +++ b/src/APIMappers/UserMappeur.cs @@ -8,7 +8,7 @@ public static class UserMappeur { private static GenericMapper _mapper = new GenericMapper(); - public static UserDto? ToDto(this User user) + public static UserDto ToDto(this User user) { return user.ToU(_mapper, userDto => new UserDto { @@ -32,7 +32,7 @@ public static class UserMappeur // corégraphie => microservice TCP - public static User? ToModel(this UserDto userDto) + public static User ToModel(this UserDto userDto) { return userDto.ToT(_mapper, user => new User { diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 61be631..4c5200a 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -11,6 +11,7 @@ using Microsoft.Extensions.Options; using Microsoft.OpenApi.Models; using Model.Manager; using Model2Entities; +using StubAPI; namespace HeartTrackAPI; @@ -68,7 +69,8 @@ public class AppBootstrap(IConfiguration configuration) } private void AddModelService(IServiceCollection services) { - services.AddSingleton(provider => new DbDataManager(provider.GetService())); + //services.AddSingleton(provider => new DbDataManager(provider.GetService())); + services.AddSingleton(); //services.AddTransient(); } diff --git a/src/HeartTrackAPI/Controllers/ActivityController.cs b/src/HeartTrackAPI/Controllers/ActivityController.cs index f5498e3..efb07a9 100644 --- a/src/HeartTrackAPI/Controllers/ActivityController.cs +++ b/src/HeartTrackAPI/Controllers/ActivityController.cs @@ -3,8 +3,8 @@ using Dto; using HeartTrackAPI.Request; using HeartTrackAPI.Responce; using Microsoft.AspNetCore.Mvc; -using Shared; using Model; +using Shared; using Model.Manager; using Model.Repository; @@ -40,7 +40,7 @@ public class ActivityController : Controller var activities = await _activityService.GetActivities(pageRequest.Index, pageRequest.Count, ActivityOrderCriteria.None, pageRequest.Descending ?? false); if(activities == null) { - return BadRequest("No activities found"); + return NotFound("No activities found"); } var pageResponse = new PageResponse(pageRequest.Index, pageRequest.Count, totalCount, activities.Select(a => a.ToDto())); return Ok(pageResponse); @@ -52,22 +52,61 @@ public class ActivityController : Controller } } /* - public async Task PostFitFile([FromForm] IFormFile file) + [HttpPost] + [ProducesResponseType(StatusCodes.Status201Created)] + [ProducesResponseType(StatusCodes.Status415UnsupportedMediaType)] + [MultipartFormData] + [DisableFormValueModelBinding] + public async Task PostFitFile( Stream file, string contentType) // [FromForm] { + if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType)) + { + ModelState.AddModelError("File", + $"The request couldn't be processed (Error 1)."); + // Log error + + return BadRequest(ModelState); + } if (file == null) { return BadRequest("No file was provided"); } - var activity = await _activityManager.AddActivityFromFitFile(file); - à l'intérieur du AddActivityFromFitFile ya un truc comme var result = await _activityRepo.AddActivity(activity); - + //var fileUploadSummary = await _fileService.UploadFileAsync(HttpContext.Request.Body, Request.ContentType); +// var activity = await _activityManager.AddActivityFromFitFile(file); + var activity = new Activity + { + Id = 1, + Type = "Running", + Date = new DateTime(2021, 10, 10), + StartTime = new DateTime(2021, 10, 10, 10, 0, 0), + EndTime = new DateTime(2021, 10, 10, 11, 0, 0), + Effort = 3, + Variability = 0.5f, + Variance = 0.5f, + StandardDeviation = 0.5f, + Average = 5.0f, + Maximum = 10, + Minimum = 0, + AverageTemperature = 20.0f, + HasAutoPause = false, + Users = + { + new User + { + Id = 3, Username = "Athlete3", + ProfilePicture = + "https://plus.unsplash.com/premium_photo-1705091981693-6006f8a20479?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", + FirstName = "First3", LastName = "Last3", + Sexe = "M", Lenght = 190, Weight = 80, DateOfBirth = new DateTime(1994, 3, 3), Email = "ath@ex.fr", + Role = new Athlete() + } + } + }; if (activity == null) { return BadRequest("The file provided is not a valid fit file"); } - return CreatedAtAction(nameof(GetActivity), new { id = result.Id }, result.ToDto()); - - return CreatedAtAction(nameof(GetActivities), activity.ToDto()); + return CreatedAtAction(nameof(GetActivity), new { id = activity.Id }, activity.ToDto()); }*/ [HttpGet("{id}")] @@ -107,4 +146,34 @@ public class ActivityController : Controller } return NoContent(); } + +/* + public async Task UploadFileAsync(Stream fileStream, string contentType) + { + var fileCount = 0; + long totalSizeInBytes = 0; + var boundary = GetBoundary(MediaTypeHeaderValue.Parse(contentType)); + var multipartReader = new MultipartReader(boundary, fileStream); + var section = await multipartReader.ReadNextSectionAsync(); + var filePaths = new List(); + var notUploadedFiles = new List(); + + while (section != null) + { + var fileSection = section.AsFileSection(); + if (fileSection != null) + { + totalSizeInBytes += await SaveFileAsync(fileSection, filePaths, notUploadedFiles); + fileCount++; + } + section = await multipartReader.ReadNextSectionAsync(); + } + return new FileUploadSummary + { + TotalFilesUploaded = fileCount, + TotalSizeUploaded = ConvertSizeToString(totalSizeInBytes), + FilePaths = filePaths, + NotUploadedFiles = notUploadedFiles + }; + }*/ } \ No newline at end of file diff --git a/src/HeartTrackAPI/Controllers/UsersController.cs b/src/HeartTrackAPI/Controllers/UsersController.cs index 5b1486f..e0d571d 100644 --- a/src/HeartTrackAPI/Controllers/UsersController.cs +++ b/src/HeartTrackAPI/Controllers/UsersController.cs @@ -1,11 +1,9 @@ using APIMappers; using Dto; -using Entities; using HeartTrackAPI.Request; using HeartTrackAPI.Responce; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; -using Model; using Model.Manager; using Model.Repository; using Shared; @@ -18,11 +16,13 @@ namespace HeartTrackAPI.Controllers; public class UsersController : Controller { private readonly ILogger _logger; + private readonly IActivityRepository _activityService; private readonly IUserRepository _userService; public UsersController(ILogger logger, IDataManager dataManager) { _logger = logger; _userService = dataManager.UserRepo; + _activityService = dataManager.ActivityRepo; } [HttpGet] @@ -43,7 +43,7 @@ public class UsersController : Controller _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), null); var athletes = await _userService.GetUsers(request.Index, request.Count, Enum.TryParse(request.OrderingPropertyName, out AthleteOrderCriteria result) ? result : AthleteOrderCriteria.None, request.Descending ?? false); - var pageResponse = new PageResponse(request.Index, request.Count, totalCount, athletes.Select(a => a.ToDto())); + var pageResponse = new PageResponse(request.Index, request.Count, totalCount, athletes!.Select(a => a.ToDto())); return Ok(pageResponse); } catch (Exception e) @@ -116,9 +116,8 @@ public class UsersController : Controller { _logger.LogError("Error while updating athlete with id {id}", id); return StatusCode(500); - } + } return Ok(updatedAthlete.ToDto()); - return Ok(); } catch (Exception e) @@ -160,6 +159,39 @@ public class UsersController : Controller } } + [HttpGet("{id}/friends")] + [ProducesResponseType(typeof(PageResponse), 200)] + [ProducesResponseType(404)] + [ProducesResponseType(500)] + public async Task>> GetFriends(int id, [FromQuery] PageRequest request) + { + try + { + _logger.LogInformation("Executing {Action} with parameters: {Parameters} for {Id}", nameof(GetFriends), null,id); + var athlete = await _userService.GetItemById(id); + if (athlete == null) + { + _logger.LogError("Athlete with id {id} not found", id); + return NotFound($"Athlete with id {id} not found"); + } + var totalCount = await _userService.GetNbFriends(athlete); + if (request.Count * request.Index >= totalCount) + { + _logger.LogError("To many object is asked the max is {totalCount} but the request is superior of ", totalCount); + return BadRequest("To many object is asked the max is : " + totalCount); + } + var friends = await _userService.GetFriends(athlete, request.Index, request.Count, Enum.TryParse(request.OrderingPropertyName, out AthleteOrderCriteria result) ? result : AthleteOrderCriteria.None, request.Descending ?? false); + if (friends == null) return NotFound(); + var pageResponse = new PageResponse(request.Index, request.Count, totalCount, friends.Select(a => a.ToDto())); + return Ok(pageResponse); + } + catch (Exception e) + { + _logger.LogError(e, "Error while getting the number of users"); + return StatusCode(500); + } + } + [HttpPost("{id}/friend/{friendId}")] [ProducesResponseType(200)] @@ -197,6 +229,115 @@ public class UsersController : Controller } } + [HttpDelete("{id}/friend/{friendId}")] + [ProducesResponseType(200)] + [ProducesResponseType(404)] + [ProducesResponseType(500)] + public async Task RemoveFriend(int id, int friendId) + { + try + { + _logger.LogInformation("Executing {Action} with parameters: {Parameters} for {Id}", nameof(RemoveFriend), friendId,id); + var athlete = await _userService.GetItemById(id); + if (athlete == null) + { + _logger.LogError("Athlete with id {id} not found", id); + return NotFound($"Athlete with id {id} not found"); + } + var friend = await _userService.GetItemById(friendId); + if (friend == null) + { + _logger.LogError("Athlete with id {id} not found", friendId); + return NotFound($"Athlete with id {friendId} not found"); + } + var isRemoved = await _userService.RemoveFriend(athlete, friend); + if(!isRemoved) + { + _logger.LogError("Error while removing friend with id {friendId} to athlete with id {id}", friendId, id); + return StatusCode(500); + } + return Ok(); + } + catch (Exception e) + { + _logger.LogError(e, "Error while getting the number of users"); + return StatusCode(500); + } + } + + + // ou faire un get qui si le role est coach resend les athletes et si le role est athlete resend les coach + [HttpGet("{coachId}/athletes")] + [ProducesResponseType(typeof(PageResponse), 200)] + [ProducesResponseType(404)] + [ProducesResponseType(500)] + public async Task>> GetAthletes(int coachId, [FromQuery] PageRequest request) + { + try + { + _logger.LogInformation("Executing {Action} with parameters: {Parameters} for {Id}", nameof(GetAthletes), null,coachId); + var coach = await _userService.GetItemById(coachId); + if (coach == null) + { + _logger.LogError("Athlete with id {id} not found", coachId); + return NotFound($"Athlete with id {coachId} not found"); + } + var totalCount = await _userService.GetNbFriends(coach); + if (request.Count * request.Index >= totalCount) + { + _logger.LogError("To many object is asked the max is {totalCount} but the request is superior of ", totalCount); + return BadRequest("To many object is asked the max is : " + totalCount); + } + var athletes = await _userService.GetFriends(coach, request.Index, request.Count, Enum.TryParse(request.OrderingPropertyName, out AthleteOrderCriteria result) ? result : AthleteOrderCriteria.None, request.Descending ?? false); + if (athletes == null) return NotFound(); + var pageResponse = new PageResponse(request.Index, request.Count, totalCount, athletes.Select(a => a.ToDto())); + return Ok(pageResponse); + } + catch (Exception e) + { + _logger.LogError(e, "Error while getting the number of users"); + return StatusCode(500); + } + } + + [HttpGet("{userId}/activities")] + // should be tiny DTOActivity returned with only the necessary information (will be used in the list of activities of a user) + public async Task>> GetActivitiesByUser(int userId, [FromQuery] PageRequest pageRequest) + { + try + { + var totalCount = await _activityService.GetNbActivitiesByUser(userId); + if (pageRequest.Count * pageRequest.Index >= totalCount) + { + _logger.LogError("To many object is asked the max is {totalCount} but the request is superior of ", totalCount); + return BadRequest("To many object is asked the max is : " + totalCount); + } + _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(GetActivitiesByUser), pageRequest); + var activities = await _activityService.GetActivitiesByUser(userId, pageRequest.Index, pageRequest.Count, ActivityOrderCriteria.None, pageRequest.Descending ?? false); + if(activities == null) + { + return NotFound("No activities found"); + } + var pageResponse = new PageResponse(pageRequest.Index, pageRequest.Count, totalCount, activities.Select(a => a.ToDto())); + return Ok(pageResponse); + } + catch (Exception e) + { + _logger.LogError(e, "Error while getting all activities"); + return StatusCode(500); + } + } + /* + + [HttpGet("{userId}/trainings")] + [ProducesResponseType(typeof(PageResponse), 200)] + [ProducesResponseType(404)] + [ProducesResponseType(500)] +public async Task> GetTrainings(int userId, [FromQuery] PageRequest request) + */ + + + [HttpPost("logout")] [ProducesResponseType(200)] [ProducesResponseType(401)] diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index c8f3264..a5ea045 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -12,7 +12,8 @@ COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"] COPY ["Shared/Shared.csproj", "Shared/"] COPY ["Entities/Entities.csproj", "Entities/"] COPY ["Dto/Dto.csproj", "Dto/"] -COPY ["ApiMappeur/ApiMappeur.csproj", "ApiMappeur/"] +COPY ["APIMappers/APIMappers.csproj", "APIMappers/"] +COPY ["EFMappers/EFMappers.csproj", "EFMappers/"] COPY ["DbContextLib/DbContextLib.csproj", "DbContextLib/"] COPY ["Model/Model.csproj", "Model/"] COPY ["Model2Entities/Model2Entities.csproj", "Model2Entities/"] diff --git a/src/HeartTrackAPI/FileUploadSummary.cs b/src/HeartTrackAPI/FileUploadSummary.cs new file mode 100644 index 0000000..1721ae7 --- /dev/null +++ b/src/HeartTrackAPI/FileUploadSummary.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace HeartTrackAPI; + +public class FileUploadSummary +{ + public int TotalFilesUploaded { get; set; } + public string TotalSizeUploaded { get; set; } + public IList FilePaths { get; set; } = new List(); + public IList NotUploadedFiles { get; set; } = new List(); +} +[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] +public class MultipartFormDataAttribute : ActionFilterAttribute +{ + public override void OnActionExecuting(ActionExecutingContext context) + { + var request = context.HttpContext.Request; + + if (request.HasFormContentType + && request.ContentType.StartsWith("multipart/form-data", StringComparison.OrdinalIgnoreCase)) + { + return; + } + + context.Result = new StatusCodeResult(StatusCodes.Status415UnsupportedMediaType); + } +} +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] +public class DisableFormValueModelBindingAttribute : Attribute, IResourceFilter +{ + public void OnResourceExecuting(ResourceExecutingContext context) + { + var factories = context.ValueProviderFactories; + factories.RemoveType(); + factories.RemoveType(); + factories.RemoveType(); + } + + public void OnResourceExecuted(ResourceExecutedContext context) + { + } +} \ No newline at end of file diff --git a/src/HeartTrackAPI/Program.cs b/src/HeartTrackAPI/Program.cs index 9b4e118..04e64af 100644 --- a/src/HeartTrackAPI/Program.cs +++ b/src/HeartTrackAPI/Program.cs @@ -4,6 +4,10 @@ using HeartTrackAPI; var builder = WebApplication.CreateBuilder(args); builder.Logging.AddConsole(); +builder.WebHost.ConfigureKestrel(serverOptions => +{ + serverOptions.Limits.MaxRequestBodySize = long.MaxValue; +}); var init = new AppBootstrap(builder.Configuration); diff --git a/src/Model/Activity.cs b/src/Model/Activity.cs index 06801bf..11457c1 100644 --- a/src/Model/Activity.cs +++ b/src/Model/Activity.cs @@ -31,7 +31,8 @@ public class Activity public int Minimum { get; set; } public float AverageTemperature { get; set; } public bool HasAutoPause { get; set; } - + + public HashSet Users { get; private set; } = new HashSet(); public Activity(int idActivity ,string type, DateTime date, DateTime startTime, DateTime endTime, int effort, float variability, float variance, float standardDeviation, float average, int maximum, int minimum, float averageTemperature, bool hasAutoPause) diff --git a/src/Model/Repository/IActivityRepository.cs b/src/Model/Repository/IActivityRepository.cs index 258bbd9..eab97da 100644 --- a/src/Model/Repository/IActivityRepository.cs +++ b/src/Model/Repository/IActivityRepository.cs @@ -4,10 +4,12 @@ namespace Model.Repository; public interface IActivityRepository { - public Task> GetActivities(int index, int count, ActivityOrderCriteria criteria, bool descending = false); + public Task?> GetActivities(int index, int count, ActivityOrderCriteria criteria, bool descending = false); public Task GetActivityByIdAsync(int id); public Task AddActivity(Activity activity); public Task UpdateActivity(int id, Activity activity); public Task DeleteActivity(int id); public Task GetNbItems(); + public Task?> GetActivitiesByUser(int userId, int index, int count, ActivityOrderCriteria orderCriteria, bool descending= false); + public Task GetNbActivitiesByUser(int userId); } \ No newline at end of file diff --git a/src/Model/Repository/IUserRepository.cs b/src/Model/Repository/IUserRepository.cs index 4c38ba4..6ba01b9 100644 --- a/src/Model/Repository/IUserRepository.cs +++ b/src/Model/Repository/IUserRepository.cs @@ -4,7 +4,14 @@ namespace Model.Repository; public interface IUserRepository : IGenericRepository { - public Task> GetUsers(int index, int count, AthleteOrderCriteria? criteria , bool descending = false); + public Task?> GetUsers(int index, int count, AthleteOrderCriteria? criteria , bool descending = false); public Task AddFriend(User user, User friend); + + public Task RemoveFriend(User user, User friend); + + // should be removed cause i just have to call the GetItem then get the friends + public Task?> GetFriends(User user, int index, int count, AthleteOrderCriteria? criteria, bool descending = false); + + public Task GetNbFriends(User user); } \ No newline at end of file diff --git a/src/Model2Entities/ActivityRepository.cs b/src/Model2Entities/ActivityRepository.cs index 5878da0..845d6bb 100644 --- a/src/Model2Entities/ActivityRepository.cs +++ b/src/Model2Entities/ActivityRepository.cs @@ -121,5 +121,15 @@ public partial class DbDataManager : IDataManager throw; } } + + public Task> GetActivitiesByUser(int userId, int index, int count, ActivityOrderCriteria criteria, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task GetNbActivitiesByUser(int userId) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/src/Model2Entities/UserRepository.cs b/src/Model2Entities/UserRepository.cs index 020dcb6..7791636 100644 --- a/src/Model2Entities/UserRepository.cs +++ b/src/Model2Entities/UserRepository.cs @@ -54,5 +54,20 @@ public partial class DbDataManager { throw new NotImplementedException(); } + + public async Task RemoveFriend(User user, User friend) + { + throw new NotImplementedException(); + } + + public Task?>? GetFriends(User user, int index, int count, AthleteOrderCriteria? criteria, bool descending = false) + { + throw new NotImplementedException(); + } + + public Task GetNbFriends(User user) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/src/Shared/Extension.cs b/src/Shared/Extension.cs index 121352c..6301ad7 100644 --- a/src/Shared/Extension.cs +++ b/src/Shared/Extension.cs @@ -2,7 +2,7 @@ namespace Shared; public static class Extensions { - public static U? ToU(this T t, GenericMapper mapper, Func func) where U :class where T :class + public static U ToU(this T t, GenericMapper mapper, Func func) where U :class where T :class { var u = mapper.GetU(t); if (u != null) { @@ -14,7 +14,7 @@ public static class Extensions return u; } // , Action action - public static T? ToT(this U u, GenericMapper mapper, Func func) where U :class where T :class + public static T ToT(this U u, GenericMapper mapper, Func func) where U :class where T :class { var t = mapper.GetT(u); if (t != null) { diff --git a/src/StubAPI/ActivityService.cs b/src/StubAPI/ActivityService.cs index 0e87004..2b274ae 100644 --- a/src/StubAPI/ActivityService.cs +++ b/src/StubAPI/ActivityService.cs @@ -6,33 +6,73 @@ namespace StubAPI; public class ActivityService: IActivityRepository { - public async Task> GetActivities(int index, int count, ActivityOrderCriteria criteria, bool descending = false) - { - throw new NotImplementedException(); - } + private List _activities = new List( + new Activity[] + { + new Activity + { + Id = 1, + Type = "Running", + Date = new DateTime(2021, 10, 10), + StartTime = new DateTime(2021, 10, 10, 10, 0, 0), + EndTime = new DateTime(2021, 10, 10, 11, 0, 0), + Effort = 3, + Variability = 0.5f, + Variance = 0.5f, + StandardDeviation = 0.5f, + Average = 5.0f, + Maximum = 10, + Minimum = 0, + AverageTemperature = 20.0f, + HasAutoPause = false, + Users = {new User + { + Id = 3, Username = "Athlete3", ProfilePicture = "https://plus.unsplash.com/premium_photo-1705091981693-6006f8a20479?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", FirstName = "First3", LastName = "Last3", + Sexe = "M", Lenght = 190, Weight = 80, DateOfBirth = new DateTime(1994, 3, 3), Email = "ath@ex.fr", + Role = new Athlete() + }} + }, + } + ); + + public async Task?> GetActivities(int index, int count, ActivityOrderCriteria criteria, bool descending = false) + => await Task.FromResult(_activities.GetItemsWithFilterAndOrdering(c=>true,index, count,criteria != ActivityOrderCriteria.None ? criteria: null , descending)); - public async Task GetActivityByIdAsync(int id) + public Task GetActivityByIdAsync(int id) { - throw new NotImplementedException(); + return Task.FromResult(_activities.FirstOrDefault(s => s.Id == id)); } - public async Task AddActivity(Activity activity) + public Task AddActivity(Activity activity) + => _activities.AddItem(activity); + + + public async Task UpdateActivity(int id, Activity activity) { - throw new NotImplementedException(); + var oldActivity = _activities.FirstOrDefault(s => s.Id == id); + if (oldActivity == null) return null; + return await _activities.UpdateItem(oldActivity, activity); } - public async Task UpdateActivity(int id, Activity activity) + public Task DeleteActivity(int id) { - throw new NotImplementedException(); + var activity = _activities.FirstOrDefault(s => s.Id == id); + if (activity == null) return Task.FromResult(false); + return _activities.DeleteItem(activity); } - public async Task DeleteActivity(int id) + public Task GetNbItems() + => Task.FromResult(_activities.Count); + + public async Task?> GetActivitiesByUser(int userId, int index, int count, ActivityOrderCriteria criteria, bool descending = false) { - throw new NotImplementedException(); + var activities = _activities.GetItemsWithFilterAndOrdering(c => c.Users.Any(u => u.Id == userId), index, count, + criteria != ActivityOrderCriteria.None ? criteria : null, descending); + return await Task.FromResult(activities); } - public async Task GetNbItems() + public Task GetNbActivitiesByUser(int userId) { - throw new NotImplementedException(); + return Task.FromResult(_activities.Count(a => a.Users.Any(u => u.Id == userId))); } } \ No newline at end of file diff --git a/src/StubAPI/AthleteService.cs b/src/StubAPI/AthleteService.cs index d666873..7729296 100644 --- a/src/StubAPI/AthleteService.cs +++ b/src/StubAPI/AthleteService.cs @@ -51,14 +51,36 @@ public class UserService : IUserRepository return true; } - public async Task> GetItems(int index, int count, string? orderingProperty = null, - bool descending = false) + public async Task RemoveFriend(User user, User friend) { + if (user == null || friend == null) + { + return false; + } + + if (!user.Users.Contains(friend)) + { + return false; + } - return await this.GetUsers(index, count, this.ToEnum(orderingProperty), descending); + user.Users.Remove(friend); + return true; + } + + public async Task?>? GetFriends(User user, int index, int count, AthleteOrderCriteria? criteria, bool descending = false) + =>await Task.FromResult(athletes.FirstOrDefault(s => s.Id == user.Id)?.Users.GetItemsWithFilterAndOrdering(c=>true,index, count,criteria, descending)); + + public Task GetNbFriends(User user) + { + return Task.FromResult(athletes.FirstOrDefault(s => s.Id == user.Id)?.Users.Count ?? 0); } + public async Task> GetItems(int index, int count, string? orderingProperty = null, + bool descending = false) + =>await GetUsers(index, count, this.ToEnum(orderingProperty), descending); + + public async Task GetItemById(int id) =>await Task.FromResult(athletes.FirstOrDefault(s => s.Id == id)); diff --git a/src/StubAPI/Extensions.cs b/src/StubAPI/Extensions.cs index 9917cac..af6f004 100644 --- a/src/StubAPI/Extensions.cs +++ b/src/StubAPI/Extensions.cs @@ -39,13 +39,15 @@ public static class Extensions public static IEnumerable GetItemsWithFilterAndOrdering(this IEnumerable list, Func filter, int index, int count, Enum? orderCriterium, bool descending = false ) where T : class { - var filteredList = list.Where(filter); + IEnumerable query = list; + + query = query.Where(filter); if(orderCriterium != null) { - filteredList = filteredList.OrderByCriteria(orderCriterium, descending); + query = query.OrderByCriteria(orderCriterium, descending); } - return filteredList + return query .Skip(index * count) .Take(count); } From 6a32c2cbfe1e1fade1806956d06cd09da53a5f26 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 15:19:08 +0100 Subject: [PATCH 09/74] update Ci, add test and add db --- .drone.yml | 127 ++++++++-- src/DbContextLib/DbContextLib.csproj | 1 + src/DbContextLib/HeartTrackContext.cs | 16 ++ src/HeartTrack.sln | 7 - src/HeartTrackAPI/AppBootstrap.cs | 92 +++++-- .../Controllers/ActivityController.cs | 3 +- .../Controllers/UsersController.cs | 145 +++++++++-- src/HeartTrackAPI/HeartTrackAPI.csproj | 2 + src/HeartTrackAPI/Request/PageRequest.cs | 12 +- .../Utils/SwaggerDefaultValues.cs | 53 +++++ src/HeartTrackAPI/Utils/SwaggerOptions.cs | 8 +- src/Model2Entities/DbDataManager.cs | 7 + src/Tests/TestsAPI/TestsXUnit/GlobalUsings.cs | 1 - .../TestsAPI/TestsXUnit/TestsXUnit.csproj | 25 -- src/Tests/TestsAPI/TestsXUnit/UnitTest1.cs | 10 - .../Controllers/UsersControllerTest.cs | 225 ++++++++++++++++++ .../TestsAPI/UnitTestApi/UnitTestApi.csproj | 2 + .../UnitTestApi/UserControllerTest.cs | 124 ---------- 18 files changed, 628 insertions(+), 232 deletions(-) create mode 100644 src/HeartTrackAPI/Utils/SwaggerDefaultValues.cs delete mode 100644 src/Tests/TestsAPI/TestsXUnit/GlobalUsings.cs delete mode 100644 src/Tests/TestsAPI/TestsXUnit/TestsXUnit.csproj delete mode 100644 src/Tests/TestsAPI/TestsXUnit/UnitTest1.cs create mode 100644 src/Tests/TestsAPI/UnitTestApi/Controllers/UsersControllerTest.cs delete mode 100644 src/Tests/TestsAPI/UnitTestApi/UserControllerTest.cs diff --git a/.drone.yml b/.drone.yml index b3304ee..bd1fa7c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,6 +15,14 @@ steps: - dotnet build HeartTrack.sln -c Release --no-restore - dotnet publish HeartTrack.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - name: tests + image: mcr.microsoft.com/dotnet/sdk:8.0 + commands: + - cd src/ + - dotnet restore HeartTrack.sln + - dotnet test HeartTrack.sln --no-restore + depends_on: [build] + - name: code-analysis image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet8 secrets: [ SECRET_SONAR_LOGIN ] @@ -33,8 +41,54 @@ steps: - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - dotnet publish HeartTrack.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release - dotnet sonarscanner end /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - depends_on: [ build ] + depends_on: [ tests ] + - name: swagger + image: mcr.microsoft.com/dotnet/sdk:8.0 + failure: ignore + volumes: + - name: docs + path: /docs + commands: + - cd src/ + - dotnet restore HeartTrack.sln + - cd HeartTrack + - dotnet new tool-manifest + - dotnet tool install -g --version 6.5.0 Swashbuckle.AspNetCore.Cli + - cd ../ + - dotnet build HeartTrack.sln -c Release --no-restore + - dotnet publish HeartTrack.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - export PATH="$PATH:/root/.dotnet/tools" + - swagger tofile --output /docs/swagger.json HeartTrack/bin/Release/net8.0/HeartTrack.dll v1 + - name: generate-and-deploy-docs + image: hub.codefirst.iut.uca.fr/maxime.batista/codefirst-docdeployer + failure: ignore + commands: + - /entrypoint.sh -l docs/doxygen -t doxygen + when: + event: + - push + depends_on: [ build ] + +volumes: +- name: docs + temp: {} + +--- + +kind: pipeline +type: docker +name: HeartTrack-API-CD + +trigger: + event: + - push +steps: + - name: hadolint + image: hadolint/hadolint:latest-alpine + commands: + - cd src/HeartTrackAPI + - hadolint Dockerfile - name: docker-build-and-push image: plugins/docker settings: @@ -47,24 +101,65 @@ steps: password: from_secret: SECRET_REGISTRY_PASSWORD depends_on: [ build ] - - - name: deploy-container + + # database container stub + - name: deploy-container-stub image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: + CODEFIRST_CLIENTDRONE_ENV_TYPE: STUB IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest - CONTAINERNAME: api - CODEFIRST_CLIENTDRONE_ENV_PORT: 8080 - ADMINS: davidd_almeida,kevinmonteiro,antoineperederii,paullevrault,antoinepinagot,nicolas.raymond + CONTAINERNAME: heart_stub COMMAND: create OVERWRITE: true depends_on: [ docker-build-and-push ] - - - name: generate-and-deploy-docs - image: hub.codefirst.iut.uca.fr/maxime.batista/codefirst-docdeployer - failure: ignore - commands: - - /entrypoint.sh -l docs/doxygen -t doxygen - when: - event: - - push - depends_on: [ build ] \ No newline at end of file + + # - name: deploy-container + # image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest + # environment: + # IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest + # CONTAINERNAME: heart_api + # CODEFIRST_CLIENTDRONE_ENV_TYPE: API + # CODEFIRST_CLIENTDRONE_ENV_PORT: 8080 + # ADMINS: davidd_almeida,kevinmonteiro,antoineperederii,paullevrault,antoinepinagot,nicolas.raymond + # COMMAND: create + # OVERWRITE: true + # depends_on: [ docker-build-and-push, deploy-container-stub ] + + + + # database container deployment + - name: deploy-container-mysql + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest + environment: + IMAGENAME: mariadb:10 + CONTAINERNAME: mysql + COMMAND: create + # OVERWRITE: false + PRIVATE: true + CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD: + from_secret: db_root_password + CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE: + from_secret: db_database + CODEFIRST_CLIENTDRONE_ENV_MARIADB_USER: + from_secret: db_user + CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD: + from_secret: db_password + + # database container bdd + - name: deploy-container-bdd + image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest + environment: + CODEFIRST_CLIENTDRONE_ENV_TYPE: BDD + CODEFIRST_CLIENTDRONE_ENV_HOST: dadalmeida-mysql + CODEFIRST_CLIENTDRONE_ENV_PORT: 3306 + CODEFIRST_CLIENTDRONE_ENV_DATABASE: + from_secret: db_database + CODEFIRST_CLIENTDRONE_ENV_USERNAME: + from_secret: db_user + CODEFIRST_CLIENTDRONE_ENV_PASSWORD: + from_secret: db_password + IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest:latest + CONTAINERNAME: heart_api + COMMAND: create + OVERWRITE: true + depends_on: [deploy-container-mysql, docker-build-and-push, deploy-container-stub] \ No newline at end of file diff --git a/src/DbContextLib/DbContextLib.csproj b/src/DbContextLib/DbContextLib.csproj index a2d1b08..cd47dbc 100644 --- a/src/DbContextLib/DbContextLib.csproj +++ b/src/DbContextLib/DbContextLib.csproj @@ -10,6 +10,7 @@ + diff --git a/src/DbContextLib/HeartTrackContext.cs b/src/DbContextLib/HeartTrackContext.cs index 3264346..1ce7564 100644 --- a/src/DbContextLib/HeartTrackContext.cs +++ b/src/DbContextLib/HeartTrackContext.cs @@ -64,6 +64,22 @@ namespace DbContextLib /// The options for the context. public HeartTrackContext(DbContextOptions options) : base(options) { } + + public HeartTrackContext(string dbPlatformPath) + : this(InitPlaformDb(dbPlatformPath)) + { + } + + private static DbContextOptions InitPlaformDb(string dbPlatformPath) + { + var options = new DbContextOptionsBuilder() + .UseMySql($"{dbPlatformPath}", new MySqlServerVersion(new Version(10, 11, 1))) + .Options; + return options; + } + + + /// /// Configures the database options if they are not already configured. diff --git a/src/HeartTrack.sln b/src/HeartTrack.sln index b4faecf..6b62741 100644 --- a/src/HeartTrack.sln +++ b/src/HeartTrack.sln @@ -25,8 +25,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestsAPI", "TestsAPI", "{30 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientTests", "Tests\TestsAPI\ClientTests\ClientTests.csproj", "{9E4D3AC5-E6CA-4753-BD96-BF5EE793931A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestsXUnit", "Tests\TestsAPI\TestsXUnit\TestsXUnit.csproj", "{44C367DC-5FE0-4CF2-9E76-A0282E931853}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{30AB7FAA-6072-40B6-A15E-9188B59144F9}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestApi", "Tests\TestsAPI\UnitTestApi\UnitTestApi.csproj", "{E515C8B6-6282-4D8B-8523-7B3A13E4AF58}" @@ -88,10 +86,6 @@ Global {9E4D3AC5-E6CA-4753-BD96-BF5EE793931A}.Debug|Any CPU.Build.0 = Debug|Any CPU {9E4D3AC5-E6CA-4753-BD96-BF5EE793931A}.Release|Any CPU.ActiveCfg = Release|Any CPU {9E4D3AC5-E6CA-4753-BD96-BF5EE793931A}.Release|Any CPU.Build.0 = Release|Any CPU - {44C367DC-5FE0-4CF2-9E76-A0282E931853}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {44C367DC-5FE0-4CF2-9E76-A0282E931853}.Debug|Any CPU.Build.0 = Debug|Any CPU - {44C367DC-5FE0-4CF2-9E76-A0282E931853}.Release|Any CPU.ActiveCfg = Release|Any CPU - {44C367DC-5FE0-4CF2-9E76-A0282E931853}.Release|Any CPU.Build.0 = Release|Any CPU {30AB7FAA-6072-40B6-A15E-9188B59144F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {30AB7FAA-6072-40B6-A15E-9188B59144F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {30AB7FAA-6072-40B6-A15E-9188B59144F9}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -146,7 +140,6 @@ Global {2D166FAD-4934-474B-96A8-6C0635156EC2} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} {30FC2BE9-7397-445A-84AD-043CE70F4281} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} {9E4D3AC5-E6CA-4753-BD96-BF5EE793931A} = {30FC2BE9-7397-445A-84AD-043CE70F4281} - {44C367DC-5FE0-4CF2-9E76-A0282E931853} = {30FC2BE9-7397-445A-84AD-043CE70F4281} {E515C8B6-6282-4D8B-8523-7B3A13E4AF58} = {30FC2BE9-7397-445A-84AD-043CE70F4281} {31FA8E5E-D642-4C43-A2B2-02B9832B2CEC} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} {73EA27F2-9F0C-443F-A5EE-2960C983A422} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 4c5200a..f8e97b0 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -1,6 +1,8 @@ +using System.Reflection; using DbContextLib; using DbContextLib.Identity; using Entities; +using HeartTrackAPI.Utils; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.AspNetCore.Mvc.ApiExplorer; @@ -12,6 +14,7 @@ using Microsoft.OpenApi.Models; using Model.Manager; using Model2Entities; using StubAPI; +using Swashbuckle.AspNetCore.SwaggerGen; namespace HeartTrackAPI; @@ -23,16 +26,14 @@ public class AppBootstrap(IConfiguration configuration) { services.AddControllers(); services.AddEndpointsApiExplorer(); - //services.AddTransient, ConfigureSwaggerOption>(); + AddSwagger(services); // include Xml comment // addsecurityRequiment // securityDef - services.AddSwaggerGen(); AddHeartTrackContextServices(services); AddModelService(services); AddIdentityServices(services); AddApiVersioning(services); - AddSwagger(services); services.AddHealthChecks(); @@ -40,20 +41,37 @@ public class AppBootstrap(IConfiguration configuration) private void AddHeartTrackContextServices(IServiceCollection services) { - var connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection"); - if (string.IsNullOrWhiteSpace(connectionString)) + string connectionString; + + switch (System.Environment.GetEnvironmentVariable("TYPE")) { - throw new InvalidOperationException("The connection string for the database is not set."); + case "BDD": + var HOST = System.Environment.GetEnvironmentVariable("HOST"); + var PORT = System.Environment.GetEnvironmentVariable("PORT"); + var DATABASE = System.Environment.GetEnvironmentVariable("DATABASE"); + var USERNAME = System.Environment.GetEnvironmentVariable("USERNAME"); + var PASSWORD = System.Environment.GetEnvironmentVariable("PASSWORD"); + + connectionString = $"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"; + services.AddSingleton(provider => new DbDataManager(connectionString)); + + break; + default: + connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection"); + if (string.IsNullOrWhiteSpace(connectionString)) + { + services.AddDbContext(options => options.UseInMemoryDatabase("AuthDb")); + //options => options.UseSqlite(connectionString) + //services.AddDbContext(); + services.AddDbContext(options => + options.UseSqlite(connectionString), ServiceLifetime.Singleton); + } + break; + } - else - { - services.AddDbContext(options => options.UseInMemoryDatabase("AuthDb")); - //options => options.UseSqlite(connectionString) - //services.AddDbContext(); - services.AddDbContext(options => - options.UseSqlite(connectionString), ServiceLifetime.Singleton); + /* - services.AddSingleton>(provider => + services.AddSingleton>(provider => { var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); @@ -64,9 +82,8 @@ public class AppBootstrap(IConfiguration configuration) return options; });*/ - } - } + private void AddModelService(IServiceCollection services) { //services.AddSingleton(provider => new DbDataManager(provider.GetService())); @@ -104,16 +121,57 @@ public class AppBootstrap(IConfiguration configuration) private void AddSwagger(IServiceCollection services) { services.AddSwaggerGen(options => + { + options.OperationFilter(); + + var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; + var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); + options.IncludeXmlComments(xmlPath); + + options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme + { + Description = + "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", + Name = "Authorization", + In = ParameterLocation.Header, + Type = SecuritySchemeType.ApiKey + }); + var scheme = new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "Bearer" + }, + Scheme = "oauth2", + Name = "Bearer", + In = ParameterLocation.Header, + }, + new List() + } + }; + options.AddSecurityRequirement(scheme); + }); + services.AddTransient, SwaggerOptions>(); + services.AddSwaggerGen(options => + { + options.OperationFilter(); + }); + /* services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Title = "HeartTrackAPI", Version = "v1" }); options.SwaggerDoc("v2", new OpenApiInfo { Title = "HeartTrackAPI", Version = "v2" }); - }); + });*/ services.AddVersionedApiExplorer(setup => { setup.GroupNameFormat = "'v'VVV"; setup.SubstituteApiVersionInUrl = true; }); + } public void Configure(WebApplication app, IWebHostEnvironment env) diff --git a/src/HeartTrackAPI/Controllers/ActivityController.cs b/src/HeartTrackAPI/Controllers/ActivityController.cs index efb07a9..d20e167 100644 --- a/src/HeartTrackAPI/Controllers/ActivityController.cs +++ b/src/HeartTrackAPI/Controllers/ActivityController.cs @@ -10,7 +10,8 @@ using Model.Repository; namespace HeartTrackAPI.Controllers; [ApiController] -[Route("api/activities")] +[ApiVersion("1.0")] +[Route("api/v{version:apiVersion}/[controller]")] public class ActivityController : Controller { private readonly IActivityRepository _activityService; diff --git a/src/HeartTrackAPI/Controllers/UsersController.cs b/src/HeartTrackAPI/Controllers/UsersController.cs index e0d571d..69d2bc9 100644 --- a/src/HeartTrackAPI/Controllers/UsersController.cs +++ b/src/HeartTrackAPI/Controllers/UsersController.cs @@ -1,3 +1,4 @@ +using System.ComponentModel.DataAnnotations; using APIMappers; using Dto; using HeartTrackAPI.Request; @@ -9,10 +10,13 @@ using Model.Repository; using Shared; namespace HeartTrackAPI.Controllers; - +/// +/// Contrôle les actions liées aux utilisateurs dans l'application HeartTrack. +/// Gère les opérations CRUD sur les utilisateurs, leurs amis, et leurs activités. +/// [ApiController] [ApiVersion("1.0")] -[Route("api/v{version:apiVersion}/users")] +[Route("api/v{version:apiVersion}/[controller]")] public class UsersController : Controller { private readonly ILogger _logger; @@ -24,7 +28,15 @@ public class UsersController : Controller _userService = dataManager.UserRepo; _activityService = dataManager.ActivityRepo; } - + + /// + /// Récupère une page d'utilisateurs en fonction des critères de pagination et de tri fournis. + /// + /// Les critères de pagination et de tri pour les utilisateurs. + /// Une page de données utilisateur selon les critères spécifiés. + /// Retourne la page demandée d'utilisateurs. + /// La demande de pagination est invalide. + /// Erreur interne du serveur. [HttpGet] [ProducesResponseType(typeof(PageResponse), 200)] [ProducesResponseType(400)] @@ -49,15 +61,23 @@ public class UsersController : Controller catch (Exception e) { _logger.LogError(e, "Error while getting all athletes"); - return StatusCode(500); + return Problem(); } } + /// + /// Récupère un utilisateur spécifique par son identifiant. + /// + /// L'identifiant de l'utilisateur à récupérer. + /// L'utilisateur correspondant à l'identifiant spécifié. + /// Retourne l'utilisateur demandé. + /// Aucun utilisateur trouvé pour l'identifiant spécifié. + /// Erreur interne du serveur. [HttpGet("{id}")] [ProducesResponseType(typeof(UserDto), 200)] [ProducesResponseType(404)] [ProducesResponseType(500)] - public async Task> GetById(int id) + public async Task> GetById([Range(0,int.MaxValue)]int id) { try { @@ -73,11 +93,16 @@ public class UsersController : Controller catch (Exception e) { _logger.LogError(e, "Error while getting athlete by id {id}", id); - return StatusCode(500); + return Problem(); } } - + /// + /// Obtient le nombre total d'utilisateurs. + /// + /// Le nombre total d'utilisateurs. + /// Retourne le nombre total d'utilisateurs. + /// Erreur interne du serveur. [HttpGet("count")] [ProducesResponseType(typeof(int), 200)] [ProducesResponseType(500)] @@ -92,10 +117,19 @@ public class UsersController : Controller catch (Exception e) { _logger.LogError(e, "Error while getting the number of users"); - return StatusCode(500); + return Problem(); } } + /// + /// Met à jour les informations d'un utilisateur spécifique. + /// + /// L'identifiant de l'utilisateur à mettre à jour. + /// Les données de l'utilisateur pour la mise à jour. + /// L'utilisateur mis à jour. + /// Retourne l'utilisateur mis à jour. + /// Utilisateur non trouvé. + /// Erreur interne du serveur. [HttpPut("{id}")] [ProducesResponseType(typeof(UserDto), 200)] [ProducesResponseType(404)] @@ -115,7 +149,7 @@ public class UsersController : Controller if(updatedAthlete == null) { _logger.LogError("Error while updating athlete with id {id}", id); - return StatusCode(500); + return Problem(); } return Ok(updatedAthlete.ToDto()); @@ -123,10 +157,18 @@ public class UsersController : Controller catch (Exception e) { _logger.LogError(e, "Error while getting the number of users"); - return StatusCode(500); + return Problem(); } } + /// + /// Supprime un utilisateur spécifique. + /// + /// L'identifiant de l'utilisateur à supprimer. + /// Action result. + /// Utilisateur supprimé avec succès. + /// Utilisateur non trouvé. + /// Erreur interne du serveur. [HttpDelete("{id}")] [ProducesResponseType(200)] [ProducesResponseType(404)] @@ -148,17 +190,26 @@ public class UsersController : Controller if(!isDeleted) { _logger.LogError("Error while deleting athlete with id {id}", id); - return StatusCode(500); + return Problem(); } return Ok(); } catch (Exception e) { _logger.LogError(e, "Error while getting the number of users"); - return StatusCode(500); + return Problem(); } } + /// + /// Obtient la liste des amis d'un utilisateur spécifique. + /// + /// L'identifiant de l'utilisateur. + /// Les critères de pagination et de tri. + /// La liste paginée des amis. + /// Retourne la liste paginée des amis de l'utilisateur. + /// Utilisateur non trouvé. + /// Erreur interne du serveur. [HttpGet("{id}/friends")] [ProducesResponseType(typeof(PageResponse), 200)] [ProducesResponseType(404)] @@ -188,11 +239,19 @@ public class UsersController : Controller catch (Exception e) { _logger.LogError(e, "Error while getting the number of users"); - return StatusCode(500); + return Problem(); } } - + /// + /// Ajoute un ami à un utilisateur spécifique. + /// + /// L'identifiant de l'utilisateur. + /// L'identifiant de l'ami à ajouter. + /// Action result. + /// Ami ajouté avec succès. + /// Utilisateur ou ami non trouvé. + /// Erreur interne du serveur. [HttpPost("{id}/friend/{friendId}")] [ProducesResponseType(200)] [ProducesResponseType(404)] @@ -218,17 +277,27 @@ public class UsersController : Controller if(!isAdded) { _logger.LogError("Error while adding friend with id {friendId} to athlete with id {id}", friendId, id); - return StatusCode(500); + return Problem(); } return Ok(); } catch (Exception e) { _logger.LogError(e, "Error while getting the number of users"); - return StatusCode(500); + return Problem(); } } + + /// + /// Supprime un ami d'un utilisateur spécifique. + /// + /// L'identifiant de l'utilisateur. + /// L'identifiant de l'ami à supprimer. + /// Action result. + /// Ami supprimé avec succès. + /// Utilisateur ou ami non trouvé. + /// Erreur interne du serveur. [HttpDelete("{id}/friend/{friendId}")] [ProducesResponseType(200)] [ProducesResponseType(404)] @@ -254,19 +323,28 @@ public class UsersController : Controller if(!isRemoved) { _logger.LogError("Error while removing friend with id {friendId} to athlete with id {id}", friendId, id); - return StatusCode(500); + return Problem(); } return Ok(); } catch (Exception e) { _logger.LogError(e, "Error while getting the number of users"); - return StatusCode(500); + return Problem(); } } - // ou faire un get qui si le role est coach resend les athletes et si le role est athlete resend les coach + // #[TODO] [Dave] ou faire un get qui si le role est coach resend les athletes et si le role est athlete resend les coach + /// + /// Obtient la liste des athlètes d'un coach spécifique. + /// + /// L'identifiant du coach. + /// Les critères de pagination et de tri. + /// La liste paginée des athlètes. + /// Retourne la liste paginée des athlètes du coach. + /// Coach non trouvé. + /// Erreur interne du serveur. [HttpGet("{coachId}/athletes")] [ProducesResponseType(typeof(PageResponse), 200)] [ProducesResponseType(404)] @@ -296,10 +374,19 @@ public class UsersController : Controller catch (Exception e) { _logger.LogError(e, "Error while getting the number of users"); - return StatusCode(500); + return Problem(); } } + /// + /// Obtient la liste des activités d'un utilisateur spécifique. + /// + /// L'identifiant de l'utilisateur. + /// Les critères de pagination et de tri. + /// La liste paginée des activités de l'utilisateur. + /// Retourne la liste paginée des activités. + /// Aucune activité trouvée. + /// Erreur interne du serveur. [HttpGet("{userId}/activities")] // should be tiny DTOActivity returned with only the necessary information (will be used in the list of activities of a user) public async Task>> GetActivitiesByUser(int userId, [FromQuery] PageRequest pageRequest) @@ -324,20 +411,26 @@ public class UsersController : Controller catch (Exception e) { _logger.LogError(e, "Error while getting all activities"); - return StatusCode(500); + return Problem(); } } - /* - + /* [TODO] [Dave] [HttpGet("{userId}/trainings")] [ProducesResponseType(typeof(PageResponse), 200)] [ProducesResponseType(404)] [ProducesResponseType(500)] -public async Task> GetTrainings(int userId, [FromQuery] PageRequest request) + public async Task> GetTrainings(int userId, [FromQuery] PageRequest request) */ - - + /// + /// Déconnecte l'utilisateur actuel. + /// + /// Le gestionnaire de connexion. + /// Paramètre vide utilisé pour s'assurer que la requête provient bien d'un client. + /// Action result. + /// Déconnexion réussie. + /// Déconnexion non autorisée. + /// Erreur interne du serveur. [HttpPost("logout")] [ProducesResponseType(200)] [ProducesResponseType(401)] diff --git a/src/HeartTrackAPI/HeartTrackAPI.csproj b/src/HeartTrackAPI/HeartTrackAPI.csproj index 2329d47..d8fac4c 100644 --- a/src/HeartTrackAPI/HeartTrackAPI.csproj +++ b/src/HeartTrackAPI/HeartTrackAPI.csproj @@ -5,6 +5,8 @@ enable enable true + true + $(NoWarn);1591 diff --git a/src/HeartTrackAPI/Request/PageRequest.cs b/src/HeartTrackAPI/Request/PageRequest.cs index 9fad40d..0c93406 100644 --- a/src/HeartTrackAPI/Request/PageRequest.cs +++ b/src/HeartTrackAPI/Request/PageRequest.cs @@ -1,10 +1,16 @@ +using System.ComponentModel.DataAnnotations; +using Microsoft.AspNetCore.Mvc.ModelBinding; + namespace HeartTrackAPI.Request; public class PageRequest { - - public string? OrderingPropertyName { get; set; } = null;// need to be map on the dto OrderCriteria + public string? OrderingPropertyName { get; set; } = null; public bool? Descending { get; set; } = false; + + [Range(1, int.MaxValue, ErrorMessage = "Count must be greater than 0")] public int Index { get; set; } = 0; - public int Count { get; set; } = 5; + + [Range(1, int.MaxValue, ErrorMessage = "Count must be greater than 0")] + public int Count { get; set; } = 1; } diff --git a/src/HeartTrackAPI/Utils/SwaggerDefaultValues.cs b/src/HeartTrackAPI/Utils/SwaggerDefaultValues.cs new file mode 100644 index 0000000..dd8671c --- /dev/null +++ b/src/HeartTrackAPI/Utils/SwaggerDefaultValues.cs @@ -0,0 +1,53 @@ +using System.Text.Json; +using Microsoft.AspNetCore.Mvc.ApiExplorer; +using Microsoft.AspNetCore.Mvc.ModelBinding; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace HeartTrackAPI.Utils; + +public class SwaggerDefaultValues : IOperationFilter +{ + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var apiDescription = context.ApiDescription; + operation.Deprecated |= apiDescription.IsDeprecated(); + + foreach (var responseType in context.ApiDescription.SupportedResponseTypes) + { + var responseKey = responseType.IsDefaultResponse ? "default" : responseType.StatusCode.ToString(); + var response = operation.Responses[responseKey]; + + foreach (var contentType in response.Content.Keys) + { + if (responseType.ApiResponseFormats.All(x => x.MediaType != contentType)) + { + response.Content.Remove(contentType); + } + } + } + + if (operation.Parameters == null) + { + return; + } + + foreach (var parameter in operation.Parameters) + { + var description = apiDescription.ParameterDescriptions.First(p => p.Name == parameter.Name); + + parameter.Description ??= description.ModelMetadata?.Description; + + if (parameter.Schema.Default == null && + description.DefaultValue != null && + description.DefaultValue is not DBNull && + description.ModelMetadata is ModelMetadata modelMetadata) + { + var json = JsonSerializer.Serialize(description.DefaultValue, modelMetadata.ModelType); + parameter.Schema.Default = OpenApiAnyFactory.CreateFromJson(json); + } + + parameter.Required |= description.IsRequired; + } + } +} \ No newline at end of file diff --git a/src/HeartTrackAPI/Utils/SwaggerOptions.cs b/src/HeartTrackAPI/Utils/SwaggerOptions.cs index e9aed2c..02c92d8 100644 --- a/src/HeartTrackAPI/Utils/SwaggerOptions.cs +++ b/src/HeartTrackAPI/Utils/SwaggerOptions.cs @@ -50,8 +50,12 @@ public class SwaggerOptions: IConfigureNamedOptions { var info = new OpenApiInfo() { - Title = ".NET Core (.NET 6) Web API For Lol", - Version = desc.ApiVersion.ToString() + Title = "Web API For HeartTrack .NET 8", + Version = desc.ApiVersion.ToString(), + Description = "The HeartTrack project API, aims to provide an Open Source solution for heart rate data analysis.", + Contact = new OpenApiContact { Name = "HeartTrackDev", Email = "toto@toto.fr" }, + License = new OpenApiLicense { Name = "MIT", Url = new Uri("https://opensource.org/licenses/MIT") } + }; if (desc.IsDeprecated) diff --git a/src/Model2Entities/DbDataManager.cs b/src/Model2Entities/DbDataManager.cs index d336fe9..6603fb9 100644 --- a/src/Model2Entities/DbDataManager.cs +++ b/src/Model2Entities/DbDataManager.cs @@ -22,6 +22,13 @@ public partial class DbDataManager: IDataManager ActivityMapper.Reset(); // Faire pour les autres reset() des autres mappers } + + public DbDataManager(string dbPlatformPath) + : this(new HeartTrackContext(dbPlatformPath)) + { + DbContext.Database.EnsureCreated(); + } + public DbDataManager() { diff --git a/src/Tests/TestsAPI/TestsXUnit/GlobalUsings.cs b/src/Tests/TestsAPI/TestsXUnit/GlobalUsings.cs deleted file mode 100644 index 8c927eb..0000000 --- a/src/Tests/TestsAPI/TestsXUnit/GlobalUsings.cs +++ /dev/null @@ -1 +0,0 @@ -global using Xunit; \ No newline at end of file diff --git a/src/Tests/TestsAPI/TestsXUnit/TestsXUnit.csproj b/src/Tests/TestsAPI/TestsXUnit/TestsXUnit.csproj deleted file mode 100644 index 22b0134..0000000 --- a/src/Tests/TestsAPI/TestsXUnit/TestsXUnit.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net8.0 - enable - enable - - false - true - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - diff --git a/src/Tests/TestsAPI/TestsXUnit/UnitTest1.cs b/src/Tests/TestsAPI/TestsXUnit/UnitTest1.cs deleted file mode 100644 index 70d745a..0000000 --- a/src/Tests/TestsAPI/TestsXUnit/UnitTest1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TestsXUnit; - -public class UnitTest1 -{ - [Fact] - public void Test1() - { - - } -} \ No newline at end of file diff --git a/src/Tests/TestsAPI/UnitTestApi/Controllers/UsersControllerTest.cs b/src/Tests/TestsAPI/UnitTestApi/Controllers/UsersControllerTest.cs new file mode 100644 index 0000000..1d1500c --- /dev/null +++ b/src/Tests/TestsAPI/UnitTestApi/Controllers/UsersControllerTest.cs @@ -0,0 +1,225 @@ +using ApiMappeur; +using Dto; +using HeartTrackAPI.Controllers; +using HeartTrackAPI.Request; +using HeartTrackAPI.Responce; +using JetBrains.Annotations; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging.Abstractions; +using Model; +using Model.Manager; +using Model.Repository; +using Moq; +using Shared; +using StubAPI; + +namespace UnitTestApi.Controllers; + +[TestClass] +[TestSubject(typeof(UsersController))] +public class UsersControllerTest +{ + private Mock _dataManagerMock; + private IDataManager _dataManager; + private UsersController _usersController; + + private readonly List _users = + [ + new User + { + Id = 1, Username = "DoeDoe", + ProfilePicture = + "https://images.unsplash.com/photo-1682687982134-2ac563b2228b?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", + FirstName = "John", LastName = "Doe", + Sexe = "M", Lenght = 180, Weight = 70, DateOfBirth = new DateTime(1990, 1, 1), + Email = "john.doe@example.com", Role = new Athlete() + }, + + new User + { + Id = 2, Username = "SmithSmith", + ProfilePicture = + "https://images.unsplash.com/photo-1709507779917-242b560288be?q=80&w=2080&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", + FirstName = "Jane", LastName = "Smith", + Sexe = "F", Lenght = 170, Weight = 60, DateOfBirth = new DateTime(1992, 2, 2), + Email = "athlete2@example.com", Role = new Coach() + }, + + new User + { + Id = 3, Username = "Athlete3", + ProfilePicture = + "https://plus.unsplash.com/premium_photo-1705091981693-6006f8a20479?q=80&w=1974&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", + FirstName = "First3", LastName = "Last3", + Sexe = "M", Lenght = 190, Weight = 80, DateOfBirth = new DateTime(1994, 3, 3), Email = "ath@ex.fr", + Role = new Athlete() + } + ]; + + [TestInitialize] + public void SetUp() + { + _dataManagerMock = new Mock(); + + _dataManagerMock.Setup(dm => dm.UserRepo.GetNbItems()).ReturnsAsync(_users.Count); + _dataManagerMock.Setup(dm => + dm.UserRepo.GetUsers(It.IsAny(), It.IsAny(), It.IsAny(), + It.IsAny())).ReturnsAsync( + (int index, int count, AthleteOrderCriteria criteria, bool descending) => + _users.GetItemsWithFilterAndOrdering(c => true, index, count, + criteria != AthleteOrderCriteria.None ? criteria : null, descending) + ); + + + + _usersController = new UsersController(new NullLogger(), _dataManagerMock.Object); + } +/* + [TestInitialize] + public void SetUp() + { + _dataManager = new StubData(); + _usersController = new UsersController(new NullLogger(), _dataManager); + }*/ + + + [TestMethod] + public async Task Get_ReturnsPageResponse_WhenRequestIsValid() + { + // Arrange + var request = new PageRequest + { + Index = 0, + Count = 3, + OrderingPropertyName = "Id", + Descending = false + }; + + // Act + var result = await _usersController.Get(request); + Assert.IsInstanceOfType(result.Result, typeof(OkObjectResult)); + var okResult = result.Result as OkObjectResult; + // Assert + Assert.IsNotNull(okResult); + Assert.IsInstanceOfType(okResult.Value, typeof(PageResponse)); + var pageResponse = okResult.Value as PageResponse; + Assert.IsNotNull(pageResponse); + Assert.AreEqual(3, pageResponse.Items.Count()); + Assert.AreEqual(3, pageResponse.Total); + Assert.AreEqual(0, pageResponse.Index); + Assert.AreEqual(3, pageResponse.Count); + Assert.AreEqual(3, pageResponse.Count); + } + + [DataTestMethod] + [DataRow(0, 2, "Id", false, 2)] + [DataRow(1, 1, "Id", false, 1)] + [DataRow(0, 3, "Id", true, 3)] + public async Task Get_ReturnsCorrectPaginationAndOrdering(int index, int count, string orderingProperty, + bool descending, int expectedItemCount) + { + // Arrange + var request = new PageRequest + { + Index = index, + Count = count, + OrderingPropertyName = orderingProperty, + Descending = descending + }; + // Act + var result = await _usersController.Get(request); + Assert.IsInstanceOfType(result.Result, typeof(OkObjectResult)); + var okResult = result.Result as OkObjectResult; + // Assert + Assert.IsNotNull(okResult); + Assert.IsInstanceOfType(okResult.Value, typeof(PageResponse)); + var pageResponse = okResult.Value as PageResponse; + Assert.IsNotNull(pageResponse); + Assert.AreEqual(expectedItemCount, pageResponse.Items.Count()); + } + + [TestMethod] + public async Task Get_ReturnsInternalServerError_OnException() + { + _dataManagerMock.Setup(dm => + dm.UserRepo.GetUsers(It.IsAny(), It.IsAny(), It.IsAny(), + It.IsAny())) + .ThrowsAsync(new Exception("Simulated database failure.")); + + var request = new PageRequest { Index = 0, Count = 3 }; + + var result = await _usersController.Get(request); + + Assert.IsInstanceOfType(result.Result, typeof(ObjectResult)); + var objectResult = result.Result as ObjectResult; + Assert.AreEqual(500, objectResult.StatusCode); + } + + + + [TestMethod] + public async Task GetById_ReturnsUserDto_WhenRequestIsValid() + { + // Arrange + var id = 1; + _dataManagerMock.Setup(dm => dm.UserRepo.GetItemById(id)).ReturnsAsync(_users.First(x => x.Id == id)); + + // Act + var result = await _usersController.GetById(id) ; + Assert.IsInstanceOfType(result.Result, typeof(OkObjectResult)); + var okResult = result.Result as OkObjectResult; + + // Assert + Assert.IsNotNull(okResult); + var resultObject = result.Result as OkObjectResult; + Assert.IsNotNull(resultObject); + Assert.IsInstanceOfType(resultObject.Value, typeof(UserDto)); + var user = resultObject.Value as UserDto; + Assert.IsNotNull(user); + var tmp = _users.First(x => x.Id == id).ToDto(); + Assert.AreEqual(tmp.Id, user.Id); + } + + [TestMethod] + public async Task GetById_ReturnsUserDto_WhenRequestUserDoesNotExist() + { + // Arrange + var id = 0; + _dataManagerMock.Setup(dm => dm.UserRepo.GetItemById(id)).ReturnsAsync((User)null!); + + // Act + var result = await _usersController.GetById(id) ; + + // Assert + Assert.IsInstanceOfType(result.Result, typeof(NotFoundObjectResult)); + } + + + [TestMethod] + public async Task GetById_Returns404_WhenIdIsInvalid() + { + // Arrange + var id = -2; + + // Act + var result = await _usersController.GetById(id); + + // Assert + Assert.IsInstanceOfType(result.Result, typeof(NotFoundObjectResult)); + } + + + [TestMethod] + public async Task Count_ReturnsInt_WhenRequestIsValid() + { + // Act + var result = await _usersController.Count(); + Assert.IsNotNull(result); + result = result.Result as OkObjectResult; + + // Assert + Assert.IsNotNull(result); + Assert.IsInstanceOfType(result.Value, typeof(int)); + } + +} \ No newline at end of file diff --git a/src/Tests/TestsAPI/UnitTestApi/UnitTestApi.csproj b/src/Tests/TestsAPI/UnitTestApi/UnitTestApi.csproj index 45b5c8f..9931d8b 100644 --- a/src/Tests/TestsAPI/UnitTestApi/UnitTestApi.csproj +++ b/src/Tests/TestsAPI/UnitTestApi/UnitTestApi.csproj @@ -10,7 +10,9 @@ + + diff --git a/src/Tests/TestsAPI/UnitTestApi/UserControllerTest.cs b/src/Tests/TestsAPI/UnitTestApi/UserControllerTest.cs deleted file mode 100644 index dd511e7..0000000 --- a/src/Tests/TestsAPI/UnitTestApi/UserControllerTest.cs +++ /dev/null @@ -1,124 +0,0 @@ -using Dto; -using HeartTrackAPI.Controllers; -using HeartTrackAPI.Request; -using HeartTrackAPI.Responce; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Logging.Abstractions; -using Model.Manager; -using Model.Repository; -using StubAPI; - -namespace UnitTestApi; - -[TestClass] -public class UserControllerTest -{ - private readonly IDataManager StubDataManager; - private readonly UsersController _usersController; - - public UserControllerTest() - { - StubDataManager = new StubData(); - _usersController = new UsersController(new NullLogger(), StubDataManager); - - } - - [TestMethod] - public void Get_ReturnsPageResponse_WhenRequestIsValid() - { - // Arrange - var request = new PageRequest - { - Index = 0, - Count = 10, - OrderingPropertyName = "Id", - Descending = false - }; - - // Act - //var result = _usersController.Get(request).Result as OkObjectResult; - - // Assert - // Assert.IsNotNull(result); - //Assert.IsInstanceOfType(result.Value, typeof(PageResponse)); - } - /* - [TestMethod] - public void GetById_ReturnsUserDto_WhenRequestIsValid() - { - // Arrange - var id = 1; - - // Act - var result = _usersController.GetById(id).Result as OkObjectResult; - - // Assert - Assert.IsNotNull(result); - Assert.IsInstanceOfType(result.Value, typeof(UserDto)); - } - - [TestMethod] - public void GetById_Returns404_WhenIdIsInvalid() - { - // Arrange - var id = 0; - - // Act - var result = _usersController.GetById(id).Result as NotFoundResult; - - // Assert - Assert.IsNotNull(result); - } - - [TestMethod] - public void GetById_Returns500_WheExceptionIsThrown() - { - // Arrange - var id = 0; - - // Act - var result = _usersController.GetById(id).Result as StatusCodeResult; - - // Assert - Assert.IsNotNull(result); - Assert.AreEqual(500, result.StatusCode); - } - - [TestMethod] - public void Count_ReturnsInt_WhenRequestIsValid() - { - // Act - var result = _usersController.Count().Result as OkObjectResult; - - // Assert - Assert.IsNotNull(result); - Assert.IsInstanceOfType(result.Value, typeof(int)); - } - - [TestMethod] - public void Count_Returns500_WheExceptionIsThrown() - { - // Act - var result = _usersController.Count().Result as StatusCodeResult; - - // Assert - Assert.IsNotNull(result); - Assert.AreEqual(500, result.StatusCode); - } - - [TestMethod] - public void Update_ReturnsUserDto_WhenRequestIsValid() - { - // Arrange - var id = 1; - var user = new UserDto - { - Id = 1, - FirstName = "John", - LastName = "Doe", - Email = "toto@eoeo.fr", - }; - - }*/ - -} \ No newline at end of file From cde21f87057fa397ee3670c0aa5480941108a6f1 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 15:21:54 +0100 Subject: [PATCH 10/74] fix path drone file --- .drone.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index bd1fa7c..a8c033c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -51,15 +51,16 @@ steps: path: /docs commands: - cd src/ - - dotnet restore HeartTrack.sln - - cd HeartTrack + - dotnet restore HeartTrackAPI.sln + - cd HeartTrackAPI - dotnet new tool-manifest - dotnet tool install -g --version 6.5.0 Swashbuckle.AspNetCore.Cli - cd ../ - - dotnet build HeartTrack.sln -c Release --no-restore - - dotnet publish HeartTrack.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - dotnet build HeartTrackAPI.sln -c Release --no-restore + - dotnet publish HeartTrackAPI.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - export PATH="$PATH:/root/.dotnet/tools" - - swagger tofile --output /docs/swagger.json HeartTrack/bin/Release/net8.0/HeartTrack.dll v1 + - swagger tofile --output /docs/swagger.json HeartTrackAPI/bin/Release/net8.0/HeartTrackAPI.dll v1 + - name: generate-and-deploy-docs image: hub.codefirst.iut.uca.fr/maxime.batista/codefirst-docdeployer failure: ignore From 86fd7270a1c7f5fe5cd657c4f1b64b9d517d872a Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 15:22:52 +0100 Subject: [PATCH 11/74] fix .drone.yml --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index a8c033c..04f1a01 100644 --- a/.drone.yml +++ b/.drone.yml @@ -60,7 +60,7 @@ steps: - dotnet publish HeartTrackAPI.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - export PATH="$PATH:/root/.dotnet/tools" - swagger tofile --output /docs/swagger.json HeartTrackAPI/bin/Release/net8.0/HeartTrackAPI.dll v1 - + depends_on: [build,tests] - name: generate-and-deploy-docs image: hub.codefirst.iut.uca.fr/maxime.batista/codefirst-docdeployer failure: ignore From 31cfa5f0dcdee23dd9cefb55dfcbe3220fdb2294 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 15:24:06 +0100 Subject: [PATCH 12/74] fix CI --- .drone.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 04f1a01..b31986d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -90,6 +90,7 @@ steps: commands: - cd src/HeartTrackAPI - hadolint Dockerfile + - name: docker-build-and-push image: plugins/docker settings: @@ -101,7 +102,7 @@ steps: from_secret: SECRET_REGISTRY_USERNAME password: from_secret: SECRET_REGISTRY_PASSWORD - depends_on: [ build ] + depends_on: [ hadolint ] # database container stub - name: deploy-container-stub From 7ebafa874ec14c0510ef1e05e2afd5cbebbd630a Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 15:28:04 +0100 Subject: [PATCH 13/74] fix CI --- .drone.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index b31986d..640fea2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -51,16 +51,17 @@ steps: path: /docs commands: - cd src/ - - dotnet restore HeartTrackAPI.sln + - dotnet restore HeartTrack.sln - cd HeartTrackAPI - dotnet new tool-manifest - dotnet tool install -g --version 6.5.0 Swashbuckle.AspNetCore.Cli - cd ../ - - dotnet build HeartTrackAPI.sln -c Release --no-restore - - dotnet publish HeartTrackAPI.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release + - dotnet build HeartTrack.sln -c Release --no-restore + - dotnet publish HeartTrack.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - export PATH="$PATH:/root/.dotnet/tools" - swagger tofile --output /docs/swagger.json HeartTrackAPI/bin/Release/net8.0/HeartTrackAPI.dll v1 depends_on: [build,tests] + - name: generate-and-deploy-docs image: hub.codefirst.iut.uca.fr/maxime.batista/codefirst-docdeployer failure: ignore From 1c7bf04dfa58eedfaec989dc448eb7b10450fdd8 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 15:33:14 +0100 Subject: [PATCH 14/74] fix CI --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index 640fea2..cd76a4d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -59,6 +59,8 @@ steps: - dotnet build HeartTrack.sln -c Release --no-restore - dotnet publish HeartTrack.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - export PATH="$PATH:/root/.dotnet/tools" + - ls + - HeartTrackAPI/bin/Release/ - swagger tofile --output /docs/swagger.json HeartTrackAPI/bin/Release/net8.0/HeartTrackAPI.dll v1 depends_on: [build,tests] From 93d671916ff820af2f418ded2277b9d4d7c6c613 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 15:35:40 +0100 Subject: [PATCH 15/74] CIIIIIIIIIIIIIIIIIIIIII --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index cd76a4d..d1b3d8c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -60,7 +60,7 @@ steps: - dotnet publish HeartTrack.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - export PATH="$PATH:/root/.dotnet/tools" - ls - - HeartTrackAPI/bin/Release/ + - ls HeartTrackAPI/bin/Release/ - swagger tofile --output /docs/swagger.json HeartTrackAPI/bin/Release/net8.0/HeartTrackAPI.dll v1 depends_on: [build,tests] From e3bff0cc220f57a6e902b5a852c3deb5792f3e3a Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 15:51:32 +0100 Subject: [PATCH 16/74] Fix CI --- .drone.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.drone.yml b/.drone.yml index d1b3d8c..5c0323e 100644 --- a/.drone.yml +++ b/.drone.yml @@ -49,6 +49,9 @@ steps: volumes: - name: docs path: /docs + environment: + CODEFIRST_CLIENTDRONE_ENV_DOTNET_ROLL_FORWARD: LatestMajor + CODEFIRST_CLIENTDRONE_ENV_DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 commands: - cd src/ - dotnet restore HeartTrack.sln @@ -87,12 +90,7 @@ name: HeartTrack-API-CD trigger: event: - push -steps: - - name: hadolint - image: hadolint/hadolint:latest-alpine - commands: - - cd src/HeartTrackAPI - - hadolint Dockerfile +steps: - name: docker-build-and-push image: plugins/docker @@ -105,7 +103,6 @@ steps: from_secret: SECRET_REGISTRY_USERNAME password: from_secret: SECRET_REGISTRY_PASSWORD - depends_on: [ hadolint ] # database container stub - name: deploy-container-stub From 5793f2403c92daf565286c9698c77d6eb68dd785 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 15:57:58 +0100 Subject: [PATCH 17/74] CIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII --- .drone.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 5c0323e..9744c7f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -62,8 +62,6 @@ steps: - dotnet build HeartTrack.sln -c Release --no-restore - dotnet publish HeartTrack.sln -c Release --no-restore -o CI_PROJECT_DIR/build/release - export PATH="$PATH:/root/.dotnet/tools" - - ls - - ls HeartTrackAPI/bin/Release/ - swagger tofile --output /docs/swagger.json HeartTrackAPI/bin/Release/net8.0/HeartTrackAPI.dll v1 depends_on: [build,tests] @@ -161,7 +159,7 @@ steps: CODEFIRST_CLIENTDRONE_ENV_PASSWORD: from_secret: db_password IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest:latest - CONTAINERNAME: heart_api + CONTAINERNAME: heartapi COMMAND: create OVERWRITE: true depends_on: [deploy-container-mysql, docker-build-and-push, deploy-container-stub] \ No newline at end of file From 7d659fbc8de4b7be0e0e7cbf1f74882db8619f2c Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:00:33 +0100 Subject: [PATCH 18/74] FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 9744c7f..f437269 100644 --- a/.drone.yml +++ b/.drone.yml @@ -159,7 +159,7 @@ steps: CODEFIRST_CLIENTDRONE_ENV_PASSWORD: from_secret: db_password IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest:latest - CONTAINERNAME: heartapi + CONTAINERNAME: api COMMAND: create OVERWRITE: true depends_on: [deploy-container-mysql, docker-build-and-push, deploy-container-stub] \ No newline at end of file From d4703b1bb80bba2e0540485eef70e56a97e234c8 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:01:31 +0100 Subject: [PATCH 19/74] SHOULD WORK --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index f437269..4ab63d3 100644 --- a/.drone.yml +++ b/.drone.yml @@ -158,8 +158,8 @@ steps: from_secret: db_user CODEFIRST_CLIENTDRONE_ENV_PASSWORD: from_secret: db_password - IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest:latest - CONTAINERNAME: api + IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest + CONTAINERNAME: heart_ api COMMAND: create OVERWRITE: true depends_on: [deploy-container-mysql, docker-build-and-push, deploy-container-stub] \ No newline at end of file From 69605367f7fd7c98ba34437616737a6e1df5c178 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:05:20 +0100 Subject: [PATCH 20/74] ok --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 4ab63d3..00b6491 100644 --- a/.drone.yml +++ b/.drone.yml @@ -159,7 +159,7 @@ steps: CODEFIRST_CLIENTDRONE_ENV_PASSWORD: from_secret: db_password IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest - CONTAINERNAME: heart_ api + CONTAINERNAME: heart_api COMMAND: create OVERWRITE: true depends_on: [deploy-container-mysql, docker-build-and-push, deploy-container-stub] \ No newline at end of file From 861b2acf18b539b3ad64541a32fe42bfbb2e136e Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:15:53 +0100 Subject: [PATCH 21/74] oik --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 00b6491..3d0eb99 100644 --- a/.drone.yml +++ b/.drone.yml @@ -159,7 +159,7 @@ steps: CODEFIRST_CLIENTDRONE_ENV_PASSWORD: from_secret: db_password IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest - CONTAINERNAME: heart_api + CONTAINERNAME: api COMMAND: create OVERWRITE: true depends_on: [deploy-container-mysql, docker-build-and-push, deploy-container-stub] \ No newline at end of file From 807ba8d2c68dc8c8f7d648e0aa27b8016691bf61 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:22:24 +0100 Subject: [PATCH 22/74] FUCK --- .drone.yml | 5 ++++- src/HeartTrackAPI/AppBootstrap.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 3d0eb99..a161976 100644 --- a/.drone.yml +++ b/.drone.yml @@ -151,7 +151,8 @@ steps: environment: CODEFIRST_CLIENTDRONE_ENV_TYPE: BDD CODEFIRST_CLIENTDRONE_ENV_HOST: dadalmeida-mysql - CODEFIRST_CLIENTDRONE_ENV_PORT: 3306 + CODEFIRST_CLIENTDRONE_ENV_PORTDB: 3306 + CODEFIRST_CLIENTDRONE_ENV_DATABASE: from_secret: db_database CODEFIRST_CLIENTDRONE_ENV_USERNAME: @@ -160,6 +161,8 @@ steps: from_secret: db_password IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest CONTAINERNAME: api + CODEFIRST_CLIENTDRONE_ENV_PORT: 8080 + ADMINS: davidd_almeida,kevinmonteiro,antoineperederii,paullevrault,antoinepinagot,nicolas.raymond COMMAND: create OVERWRITE: true depends_on: [deploy-container-mysql, docker-build-and-push, deploy-container-stub] \ No newline at end of file diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index f8e97b0..caf76fe 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -47,7 +47,7 @@ public class AppBootstrap(IConfiguration configuration) { case "BDD": var HOST = System.Environment.GetEnvironmentVariable("HOST"); - var PORT = System.Environment.GetEnvironmentVariable("PORT"); + var PORT = System.Environment.GetEnvironmentVariable("PORTDB"); var DATABASE = System.Environment.GetEnvironmentVariable("DATABASE"); var USERNAME = System.Environment.GetEnvironmentVariable("USERNAME"); var PASSWORD = System.Environment.GetEnvironmentVariable("PASSWORD"); From 1a68c99be9a76cd03574f75cd566658311328086 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:33:43 +0100 Subject: [PATCH 23/74] ok --- .drone.yml | 1 - src/HeartTrackAPI/AppBootstrap.cs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index a161976..9367339 100644 --- a/.drone.yml +++ b/.drone.yml @@ -152,7 +152,6 @@ steps: CODEFIRST_CLIENTDRONE_ENV_TYPE: BDD CODEFIRST_CLIENTDRONE_ENV_HOST: dadalmeida-mysql CODEFIRST_CLIENTDRONE_ENV_PORTDB: 3306 - CODEFIRST_CLIENTDRONE_ENV_DATABASE: from_secret: db_database CODEFIRST_CLIENTDRONE_ENV_USERNAME: diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index caf76fe..e245715 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -43,7 +43,7 @@ public class AppBootstrap(IConfiguration configuration) { string connectionString; - switch (System.Environment.GetEnvironmentVariable("TYPE")) + switch (Environment.GetEnvironmentVariable("TYPE")) { case "BDD": var HOST = System.Environment.GetEnvironmentVariable("HOST"); @@ -53,6 +53,7 @@ public class AppBootstrap(IConfiguration configuration) var PASSWORD = System.Environment.GetEnvironmentVariable("PASSWORD"); connectionString = $"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"; + Console.WriteLine(connectionString); services.AddSingleton(provider => new DbDataManager(connectionString)); break; From 0d3f4c55690847c12ed4a8af3a28c1e2e8952704 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:34:03 +0100 Subject: [PATCH 24/74] ok --- src/HeartTrackAPI/AppBootstrap.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index e245715..1fa565a 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -54,6 +54,9 @@ public class AppBootstrap(IConfiguration configuration) connectionString = $"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"; Console.WriteLine(connectionString); + Console.WriteLine(=======================); + Console.WriteLine(connectionString); + services.AddSingleton(provider => new DbDataManager(connectionString)); break; From a0ffaba566ba1d5dbbe0601eaaae680968e86287 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:35:42 +0100 Subject: [PATCH 25/74] ok --- src/HeartTrackAPI/AppBootstrap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 1fa565a..c910166 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -54,7 +54,7 @@ public class AppBootstrap(IConfiguration configuration) connectionString = $"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"; Console.WriteLine(connectionString); - Console.WriteLine(=======================); + Console.WriteLine("======================"); Console.WriteLine(connectionString); services.AddSingleton(provider => new DbDataManager(connectionString)); From de4614ddd7691062190e48f09c1f8d9fe4ce79bc Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:46:37 +0100 Subject: [PATCH 26/74] add dsb to ci --- src/HeartTrackAPI/Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index a5ea045..560ddd2 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -30,6 +30,12 @@ FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +# Add the migrations +RUN dotnet ef migrations add MyMigrations --project StubbedContextLib/ --context TrainingStubbedContext + +# Update the database +RUN dotnet ef database update --project StubbedContextLib/ --context TrainingStubbedContext --startup-project HeartTrackAPI/ + FROM base AS final WORKDIR /app COPY --from=publish /app/publish . From d67025d49730bf17c9e83f81f102506ca02d3b24 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:48:24 +0100 Subject: [PATCH 27/74] add --- src/HeartTrackAPI/Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 560ddd2..a198123 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -22,6 +22,12 @@ COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"] RUN dotnet restore "HeartTrackAPI/HeartTrackAPI.csproj" COPY . . +# Add the migrations +RUN dotnet ef migrations add MyMigrations --project StubbedContextLib/ --context TrainingStubbedContext + +# Update the database +RUN dotnet ef database update --project StubbedContextLib/ --context TrainingStubbedContext --startup-project HeartTrackAPI/ + WORKDIR "/src/HeartTrackAPI" RUN ls RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build @@ -30,12 +36,6 @@ FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false -# Add the migrations -RUN dotnet ef migrations add MyMigrations --project StubbedContextLib/ --context TrainingStubbedContext - -# Update the database -RUN dotnet ef database update --project StubbedContextLib/ --context TrainingStubbedContext --startup-project HeartTrackAPI/ - FROM base AS final WORKDIR /app COPY --from=publish /app/publish . From 5f0c28a6b578541f1bde5231991382241ed466b2 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:49:30 +0100 Subject: [PATCH 28/74] test --- src/HeartTrackAPI/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index a198123..ca1c4ec 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -19,9 +19,10 @@ COPY ["Model/Model.csproj", "Model/"] COPY ["Model2Entities/Model2Entities.csproj", "Model2Entities/"] COPY ["StubAPI/StubAPI.csproj", "StubAPI/"] COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"] - RUN dotnet restore "HeartTrackAPI/HeartTrackAPI.csproj" COPY . . +RUN ls + # Add the migrations RUN dotnet ef migrations add MyMigrations --project StubbedContextLib/ --context TrainingStubbedContext From beb6256fc20f5a9e856764e0f6572f19e87293d9 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:55:26 +0100 Subject: [PATCH 29/74] ok adapt and add dotnet migration --- src/HeartTrackAPI/Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index ca1c4ec..6514b7e 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -24,10 +24,9 @@ COPY . . RUN ls # Add the migrations -RUN dotnet ef migrations add MyMigrations --project StubbedContextLib/ --context TrainingStubbedContext - +RUN dotnet ef migrations add --project StubbedContextLib/ --startup-project HeartTrackAPI/ --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial --output-dir Migrations # Update the database -RUN dotnet ef database update --project StubbedContextLib/ --context TrainingStubbedContext --startup-project HeartTrackAPI/ +RUN dotnet ef database update --project StubbedContextLib/ --startup-project HeartTrackAPI/ --context StubbedContextLib.TrainingStubbedContext --configuration Debug WORKDIR "/src/HeartTrackAPI" RUN ls From ea0a88bccef3b359cf429a7129fc5c791cc24ad2 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 16:58:16 +0100 Subject: [PATCH 30/74] add dotnet tool install --global dotnet-ef --- src/HeartTrackAPI/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 6514b7e..9b2ca7a 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -22,7 +22,7 @@ COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"] RUN dotnet restore "HeartTrackAPI/HeartTrackAPI.csproj" COPY . . RUN ls - +RUN dotnet tool install --global dotnet-ef # Add the migrations RUN dotnet ef migrations add --project StubbedContextLib/ --startup-project HeartTrackAPI/ --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial --output-dir Migrations # Update the database From 7a8824d077a9c4e347413c2a9fa1bf2b5b18a828 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 17:02:19 +0100 Subject: [PATCH 31/74] test --- src/HeartTrackAPI/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 9b2ca7a..c04e47c 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -21,6 +21,9 @@ COPY ["StubAPI/StubAPI.csproj", "StubAPI/"] COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"] RUN dotnet restore "HeartTrackAPI/HeartTrackAPI.csproj" COPY . . +RUN echo $DOTNET_ROOT +RUN echo SHOULDDOTNET_ROOT + RUN ls RUN dotnet tool install --global dotnet-ef # Add the migrations From 98873543e965984ca2642269dbb5901893c4ebe9 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 17:05:35 +0100 Subject: [PATCH 32/74] ps --- src/HeartTrackAPI/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index c04e47c..88c9d79 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -25,7 +25,9 @@ RUN echo $DOTNET_ROOT RUN echo SHOULDDOTNET_ROOT RUN ls -RUN dotnet tool install --global dotnet-ef +RUN dotnet tool install --global dotnet-ef --version 8.0 + +ENV PATH="${PATH}:/root/.dotnet/tools" # Add the migrations RUN dotnet ef migrations add --project StubbedContextLib/ --startup-project HeartTrackAPI/ --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial --output-dir Migrations # Update the database From f150438fb061a5ea0316d5bfd1683dea14b2cf65 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 17:19:15 +0100 Subject: [PATCH 33/74] keep --- src/HeartTrackAPI/AppBootstrap.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index c910166..f3a6f8d 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -16,6 +16,7 @@ using Model2Entities; using StubAPI; using Swashbuckle.AspNetCore.SwaggerGen; + namespace HeartTrackAPI; public class AppBootstrap(IConfiguration configuration) From 653cd0bc6feeea3eaa30f73b179968741ff82bab Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 17:41:07 +0100 Subject: [PATCH 34/74] fuckkk --- .drone.yml | 2 +- src/HeartTrackAPI/AppBootstrap.cs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9367339..a4620ca 100644 --- a/.drone.yml +++ b/.drone.yml @@ -150,7 +150,7 @@ steps: image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: CODEFIRST_CLIENTDRONE_ENV_TYPE: BDD - CODEFIRST_CLIENTDRONE_ENV_HOST: dadalmeida-mysql + CODEFIRST_CLIENTDRONE_ENV_HOST: davidalmeida-mysql CODEFIRST_CLIENTDRONE_ENV_PORTDB: 3306 CODEFIRST_CLIENTDRONE_ENV_DATABASE: from_secret: db_database diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index f3a6f8d..77c557d 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -56,9 +56,10 @@ public class AppBootstrap(IConfiguration configuration) connectionString = $"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"; Console.WriteLine(connectionString); Console.WriteLine("======================"); + Console.WriteLine($"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"); Console.WriteLine(connectionString); - services.AddSingleton(provider => new DbDataManager(connectionString)); + services.AddSingleton( new DbDataManager(connectionString)); break; default: From 1e8fa2624208e39b71238b6653b0adf88a4569aa Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 17:49:28 +0100 Subject: [PATCH 35/74] change HOST to org --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index a4620ca..e97904f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -150,7 +150,7 @@ steps: image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: CODEFIRST_CLIENTDRONE_ENV_TYPE: BDD - CODEFIRST_CLIENTDRONE_ENV_HOST: davidalmeida-mysql + CODEFIRST_CLIENTDRONE_ENV_HOST: heartDev-mysql CODEFIRST_CLIENTDRONE_ENV_PORTDB: 3306 CODEFIRST_CLIENTDRONE_ENV_DATABASE: from_secret: db_database From 77dfb39d9a595eec3e6377cd52967f73fe6732ac Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 17:52:09 +0100 Subject: [PATCH 36/74] again --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index e97904f..d18818a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -150,7 +150,7 @@ steps: image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: CODEFIRST_CLIENTDRONE_ENV_TYPE: BDD - CODEFIRST_CLIENTDRONE_ENV_HOST: heartDev-mysql + CODEFIRST_CLIENTDRONE_ENV_HOST: HeartDev-mysql CODEFIRST_CLIENTDRONE_ENV_PORTDB: 3306 CODEFIRST_CLIENTDRONE_ENV_DATABASE: from_secret: db_database From b66fd1534a3c723122d65431f84c7c69582ab33a Mon Sep 17 00:00:00 2001 From: David D'ALMEIDA Date: Thu, 14 Mar 2024 17:54:28 +0100 Subject: [PATCH 37/74] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'.drone.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index d18818a..affea0a 100644 --- a/.drone.yml +++ b/.drone.yml @@ -134,8 +134,8 @@ steps: IMAGENAME: mariadb:10 CONTAINERNAME: mysql COMMAND: create - # OVERWRITE: false - PRIVATE: true + OVERWRITE: true + PRIVATE: false CODEFIRST_CLIENTDRONE_ENV_MARIADB_ROOT_PASSWORD: from_secret: db_root_password CODEFIRST_CLIENTDRONE_ENV_MARIADB_DATABASE: From fae56579ecfe37d16c466f2ff97fff5b663206f4 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:01:14 +0100 Subject: [PATCH 38/74] fuckkkkkkkkkkkkkkkk --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index d18818a..a4620ca 100644 --- a/.drone.yml +++ b/.drone.yml @@ -150,7 +150,7 @@ steps: image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: CODEFIRST_CLIENTDRONE_ENV_TYPE: BDD - CODEFIRST_CLIENTDRONE_ENV_HOST: HeartDev-mysql + CODEFIRST_CLIENTDRONE_ENV_HOST: davidalmeida-mysql CODEFIRST_CLIENTDRONE_ENV_PORTDB: 3306 CODEFIRST_CLIENTDRONE_ENV_DATABASE: from_secret: db_database From 52bc363dec2747f6cd5f7c677ac5ad66c4a3d7c4 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:15:12 +0100 Subject: [PATCH 39/74] hj --- .drone.yml | 2 +- src/HeartTrackAPI/AppBootstrap.cs | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6bd9fff..fd92d48 100644 --- a/.drone.yml +++ b/.drone.yml @@ -150,7 +150,7 @@ steps: image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: CODEFIRST_CLIENTDRONE_ENV_TYPE: BDD - CODEFIRST_CLIENTDRONE_ENV_HOST: davidalmeida-mysql + CODEFIRST_CLIENTDRONE_ENV_HOST: daviddalmeida-mysql CODEFIRST_CLIENTDRONE_ENV_PORTDB: 3306 CODEFIRST_CLIENTDRONE_ENV_DATABASE: from_secret: db_database diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 77c557d..1b6ccf7 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -44,9 +44,6 @@ public class AppBootstrap(IConfiguration configuration) { string connectionString; - switch (Environment.GetEnvironmentVariable("TYPE")) - { - case "BDD": var HOST = System.Environment.GetEnvironmentVariable("HOST"); var PORT = System.Environment.GetEnvironmentVariable("PORTDB"); var DATABASE = System.Environment.GetEnvironmentVariable("DATABASE"); @@ -61,20 +58,6 @@ public class AppBootstrap(IConfiguration configuration) services.AddSingleton( new DbDataManager(connectionString)); - break; - default: - connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection"); - if (string.IsNullOrWhiteSpace(connectionString)) - { - services.AddDbContext(options => options.UseInMemoryDatabase("AuthDb")); - //options => options.UseSqlite(connectionString) - //services.AddDbContext(); - services.AddDbContext(options => - options.UseSqlite(connectionString), ServiceLifetime.Singleton); - } - break; - - } /* services.AddSingleton>(provider => From e6c5a9e6d30410680c6060ae44cb13c91c3ea2be Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:18:56 +0100 Subject: [PATCH 40/74] j --- .drone.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index fd92d48..643d17f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -110,6 +110,7 @@ steps: IMAGENAME: hub.codefirst.iut.uca.fr/david.d_almeida/api:latest CONTAINERNAME: heart_stub COMMAND: create + ADMINS: davidd_almeida,kevinmonteiro,antoineperederii,paullevrault,antoinepinagot,nicolas.raymond OVERWRITE: true depends_on: [ docker-build-and-push ] @@ -144,13 +145,15 @@ steps: from_secret: db_user CODEFIRST_CLIENTDRONE_ENV_MARIADB_PASSWORD: from_secret: db_password + ADMINS: davidd_almeida,kevinmonteiro,antoineperederii,paullevrault,antoinepinagot,nicolas.raymond + # database container bdd - name: deploy-container-bdd image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest environment: CODEFIRST_CLIENTDRONE_ENV_TYPE: BDD - CODEFIRST_CLIENTDRONE_ENV_HOST: daviddalmeida-mysql + CODEFIRST_CLIENTDRONE_ENV_HOST: HeartDev-mysql CODEFIRST_CLIENTDRONE_ENV_PORTDB: 3306 CODEFIRST_CLIENTDRONE_ENV_DATABASE: from_secret: db_database From 7ddefa1e747204ebf951ee2a5884045a2e0d94b9 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:22:56 +0100 Subject: [PATCH 41/74] stub --- src/HeartTrackAPI/AppBootstrap.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 1b6ccf7..77c557d 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -44,6 +44,9 @@ public class AppBootstrap(IConfiguration configuration) { string connectionString; + switch (Environment.GetEnvironmentVariable("TYPE")) + { + case "BDD": var HOST = System.Environment.GetEnvironmentVariable("HOST"); var PORT = System.Environment.GetEnvironmentVariable("PORTDB"); var DATABASE = System.Environment.GetEnvironmentVariable("DATABASE"); @@ -58,6 +61,20 @@ public class AppBootstrap(IConfiguration configuration) services.AddSingleton( new DbDataManager(connectionString)); + break; + default: + connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection"); + if (string.IsNullOrWhiteSpace(connectionString)) + { + services.AddDbContext(options => options.UseInMemoryDatabase("AuthDb")); + //options => options.UseSqlite(connectionString) + //services.AddDbContext(); + services.AddDbContext(options => + options.UseSqlite(connectionString), ServiceLifetime.Singleton); + } + break; + + } /* services.AddSingleton>(provider => From 51d37a06dff591e770999b76976979cd542d37b8 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:33:25 +0100 Subject: [PATCH 42/74] ok --- src/HeartTrackAPI/Dockerfile | 9 +++------ src/Model2Entities/DbDataManager.cs | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 88c9d79..b0d1478 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -21,17 +21,14 @@ COPY ["StubAPI/StubAPI.csproj", "StubAPI/"] COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"] RUN dotnet restore "HeartTrackAPI/HeartTrackAPI.csproj" COPY . . -RUN echo $DOTNET_ROOT -RUN echo SHOULDDOTNET_ROOT - -RUN ls RUN dotnet tool install --global dotnet-ef --version 8.0 ENV PATH="${PATH}:/root/.dotnet/tools" # Add the migrations -RUN dotnet ef migrations add --project StubbedContextLib/ --startup-project HeartTrackAPI/ --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial --output-dir Migrations +#RUN dotnet ef migrations add --project StubbedContextLib/ --startup-project HeartTrackAPI/ --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial --output-dir Migrations +RUN dotnet ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial # Update the database -RUN dotnet ef database update --project StubbedContextLib/ --startup-project HeartTrackAPI/ --context StubbedContextLib.TrainingStubbedContext --configuration Debug +RUN dotnet ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug WORKDIR "/src/HeartTrackAPI" RUN ls diff --git a/src/Model2Entities/DbDataManager.cs b/src/Model2Entities/DbDataManager.cs index 6603fb9..0b12032 100644 --- a/src/Model2Entities/DbDataManager.cs +++ b/src/Model2Entities/DbDataManager.cs @@ -27,7 +27,7 @@ public partial class DbDataManager: IDataManager : this(new HeartTrackContext(dbPlatformPath)) { DbContext.Database.EnsureCreated(); - } + Console.WriteLine($"Database created: {DbContext.Database.EnsureCreated()}"); } public DbDataManager() From 953ff0653aaee3e6c5c92f20c7f39339ff454f3f Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:38:01 +0100 Subject: [PATCH 43/74] stub add --- src/HeartTrackAPI/AppBootstrap.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 77c557d..2faf1bf 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -72,6 +72,8 @@ public class AppBootstrap(IConfiguration configuration) services.AddDbContext(options => options.UseSqlite(connectionString), ServiceLifetime.Singleton); } + services.AddSingleton(provider => new DbDataManager(provider.GetService())); + break; } From 596e23bfc9f260eaafa69fcd7038b7f1ee27c1cd Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:39:37 +0100 Subject: [PATCH 44/74] log --- src/Model2Entities/DbDataManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Model2Entities/DbDataManager.cs b/src/Model2Entities/DbDataManager.cs index 0b12032..42f274b 100644 --- a/src/Model2Entities/DbDataManager.cs +++ b/src/Model2Entities/DbDataManager.cs @@ -16,6 +16,8 @@ public partial class DbDataManager: IDataManager public DbDataManager(HeartTrackContext dbContext) { DbContext = dbContext; + DbContext.Database.EnsureCreated(); + Console.WriteLine($"Database created Context: {DbContext.Database.EnsureCreated()}"); ActivityRepo = new ActivityRepository(this); UserRepo = new UserRepository(this); DbContext.Database.EnsureCreated(); @@ -27,12 +29,14 @@ public partial class DbDataManager: IDataManager : this(new HeartTrackContext(dbPlatformPath)) { DbContext.Database.EnsureCreated(); - Console.WriteLine($"Database created: {DbContext.Database.EnsureCreated()}"); } + Console.WriteLine($"Database created String: {DbContext.Database.EnsureCreated()}"); } public DbDataManager() { DbContext = new HeartTrackContext(); + DbContext.Database.EnsureCreated(); + Console.WriteLine($"Database created None: {DbContext.Database.EnsureCreated()}"); ActivityRepo = new ActivityRepository(this); UserRepo= new UserRepository(this); } From b9e2ef992589d158fe545c06a069ae538385fec2 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:43:58 +0100 Subject: [PATCH 45/74] test --- src/Model2Entities/DbDataManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Model2Entities/DbDataManager.cs b/src/Model2Entities/DbDataManager.cs index 42f274b..fd7661e 100644 --- a/src/Model2Entities/DbDataManager.cs +++ b/src/Model2Entities/DbDataManager.cs @@ -16,6 +16,8 @@ public partial class DbDataManager: IDataManager public DbDataManager(HeartTrackContext dbContext) { DbContext = dbContext; + Console.WriteLine("Contexttttttttt"); + Console.WriteLine($"Database created Context: {DbContext.Database.EnsureCreated()}"); DbContext.Database.EnsureCreated(); Console.WriteLine($"Database created Context: {DbContext.Database.EnsureCreated()}"); ActivityRepo = new ActivityRepository(this); From ce65d3927b2dc4e572539e6d5978ad18bf45569a Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:53:35 +0100 Subject: [PATCH 46/74] test --- src/APIMappers/UserMappeur.cs | 3 --- src/Dto/ActivityDto.cs | 2 +- src/Dto/ActivityFitFileDto.cs | 7 +++++++ src/Entities/ActivityEntity.cs | 2 +- src/HeartTrackAPI/AppBootstrap.cs | 6 ++++++ src/Model/Activity.cs | 4 ++-- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/APIMappers/UserMappeur.cs b/src/APIMappers/UserMappeur.cs index 96d1375..48a8cda 100644 --- a/src/APIMappers/UserMappeur.cs +++ b/src/APIMappers/UserMappeur.cs @@ -25,11 +25,8 @@ public static class UserMappeur DateOfBirth = user.DateOfBirth, IsCoach = user.Role is Coach }); - // ), (activity, entity) => activity.Id = entity.IdActivity); } - // ochestrateur => api gateway - // corégraphie => microservice TCP public static User ToModel(this UserDto userDto) diff --git a/src/Dto/ActivityDto.cs b/src/Dto/ActivityDto.cs index b2a0a91..fcb108c 100644 --- a/src/Dto/ActivityDto.cs +++ b/src/Dto/ActivityDto.cs @@ -3,7 +3,7 @@ namespace Dto; public class ActivityDto { public int Id { get; set; } - public string Type { get; set; } + public string? Type { get; set; } public DateTime Date { get; set; } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } diff --git a/src/Dto/ActivityFitFileDto.cs b/src/Dto/ActivityFitFileDto.cs index eb8fec0..f68fbd1 100644 --- a/src/Dto/ActivityFitFileDto.cs +++ b/src/Dto/ActivityFitFileDto.cs @@ -2,6 +2,13 @@ namespace Dto; public class ActivityFitFileDto { + public ActivityFitFileDto(string activityName, string activityType, int effortFeel) + { + ActivityName = activityName; + ActivityType = activityType; + EffortFeel = effortFeel; + } + public string ActivityName { get; set; } public string ActivityType { get; set; } public int EffortFeel { get; set; } diff --git a/src/Entities/ActivityEntity.cs b/src/Entities/ActivityEntity.cs index ab26369..5dc7761 100644 --- a/src/Entities/ActivityEntity.cs +++ b/src/Entities/ActivityEntity.cs @@ -29,7 +29,7 @@ namespace Entities /// [Required] [MaxLength(100)] - public string Type { get; set; } = null!; + public string? Type { get; set; } = null!; /// /// Gets or sets the date of the activity. diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 2faf1bf..927750c 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -67,6 +67,12 @@ public class AppBootstrap(IConfiguration configuration) if (string.IsNullOrWhiteSpace(connectionString)) { services.AddDbContext(options => options.UseInMemoryDatabase("AuthDb")); + Console.WriteLine("InMemoryDatabase"); + Console.WriteLine("InMemoryDatabase"); + Console.WriteLine("InMemoryDatabase"); + Console.WriteLine("InMemoryDatabase"); + Console.WriteLine("InMemoryDatabase"); + //options => options.UseSqlite(connectionString) //services.AddDbContext(); services.AddDbContext(options => diff --git a/src/Model/Activity.cs b/src/Model/Activity.cs index 11457c1..cef25b7 100644 --- a/src/Model/Activity.cs +++ b/src/Model/Activity.cs @@ -4,7 +4,7 @@ namespace Model; public class Activity { public int Id { get; set; } - public string Type { get; set; } + public string? Type { get; set; } public DateTime Date { get; set; } public DateTime StartTime { get; set; } public DateTime EndTime { get; set; } @@ -33,7 +33,7 @@ public class Activity public bool HasAutoPause { get; set; } public HashSet Users { get; private set; } = new HashSet(); - public Activity(int idActivity ,string type, DateTime date, DateTime startTime, DateTime endTime, + public Activity(int idActivity ,string? type, DateTime date, DateTime startTime, DateTime endTime, int effort, float variability, float variance, float standardDeviation, float average, int maximum, int minimum, float averageTemperature, bool hasAutoPause) { From c41f02cb269a22e41030aeb041fc39bac671e194 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 18:57:19 +0100 Subject: [PATCH 47/74] break test --- src/HeartTrackAPI/AppBootstrap.cs | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 927750c..b373a6d 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -44,25 +44,7 @@ public class AppBootstrap(IConfiguration configuration) { string connectionString; - switch (Environment.GetEnvironmentVariable("TYPE")) - { - case "BDD": - var HOST = System.Environment.GetEnvironmentVariable("HOST"); - var PORT = System.Environment.GetEnvironmentVariable("PORTDB"); - var DATABASE = System.Environment.GetEnvironmentVariable("DATABASE"); - var USERNAME = System.Environment.GetEnvironmentVariable("USERNAME"); - var PASSWORD = System.Environment.GetEnvironmentVariable("PASSWORD"); - - connectionString = $"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"; - Console.WriteLine(connectionString); - Console.WriteLine("======================"); - Console.WriteLine($"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"); - Console.WriteLine(connectionString); - - services.AddSingleton( new DbDataManager(connectionString)); - - break; - default: + connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection"); if (string.IsNullOrWhiteSpace(connectionString)) { @@ -80,10 +62,6 @@ public class AppBootstrap(IConfiguration configuration) } services.AddSingleton(provider => new DbDataManager(provider.GetService())); - break; - - } - /* services.AddSingleton>(provider => { From bc3a8b7889e0ebb17e4fd406e20f6ad8ee4b8f61 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 19:00:30 +0100 Subject: [PATCH 48/74] wrost test --- src/HeartTrackAPI/AppBootstrap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index b373a6d..c37632d 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -58,7 +58,7 @@ public class AppBootstrap(IConfiguration configuration) //options => options.UseSqlite(connectionString) //services.AddDbContext(); services.AddDbContext(options => - options.UseSqlite(connectionString), ServiceLifetime.Singleton); + options.UseSqlite("Data Source=uca.HeartTrack.db"), ServiceLifetime.Singleton); } services.AddSingleton(provider => new DbDataManager(provider.GetService())); From 779a0cdd902437452ad0a69ff2278981f43cb8f1 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 20:47:05 +0100 Subject: [PATCH 49/74] try --- src/HeartTrackAPI/AppBootstrap.cs | 43 +++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index c37632d..ab8952e 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -44,24 +44,45 @@ public class AppBootstrap(IConfiguration configuration) { string connectionString; - + switch (Environment.GetEnvironmentVariable("TYPE")) + { + case "BDD": + var HOST = System.Environment.GetEnvironmentVariable("HOST"); + var PORT = System.Environment.GetEnvironmentVariable("PORTDB"); + var DATABASE = System.Environment.GetEnvironmentVariable("DATABASE"); + var USERNAME = System.Environment.GetEnvironmentVariable("USERNAME"); + var PASSWORD = System.Environment.GetEnvironmentVariable("PASSWORD"); + + connectionString = $"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"; + Console.WriteLine(connectionString); + Console.WriteLine("======================"); + Console.WriteLine($"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"); + Console.WriteLine(connectionString); + + services.AddSingleton( new DbDataManager(connectionString)); + + break; + default: connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection"); - if (string.IsNullOrWhiteSpace(connectionString)) + if (!string.IsNullOrWhiteSpace(connectionString)) { services.AddDbContext(options => options.UseInMemoryDatabase("AuthDb")); - Console.WriteLine("InMemoryDatabase"); - Console.WriteLine("InMemoryDatabase"); - Console.WriteLine("InMemoryDatabase"); - Console.WriteLine("InMemoryDatabase"); - Console.WriteLine("InMemoryDatabase"); - + Console.WriteLine(connectionString); + Console.WriteLine("======================"); //options => options.UseSqlite(connectionString) //services.AddDbContext(); services.AddDbContext(options => - options.UseSqlite("Data Source=uca.HeartTrack.db"), ServiceLifetime.Singleton); + options.UseSqlite(connectionString), ServiceLifetime.Singleton); } - services.AddSingleton(provider => new DbDataManager(provider.GetService())); - + else + { + services.AddDbContext(options => options.UseInMemoryDatabase("AuthDb")); + services.AddDbContext(options => options.UseInMemoryDatabase("HeartTrackDb")); + } + break; + + } + /* services.AddSingleton>(provider => { From 23161b5a2c5bcd7034d2f7008aab585c4ac45a57 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 20:55:35 +0100 Subject: [PATCH 50/74] ok --- src/HeartTrackAPI/AppBootstrap.cs | 5 +++-- src/Model2Entities/DbDataManager.cs | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index ab8952e..2f75fb0 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -58,8 +58,9 @@ public class AppBootstrap(IConfiguration configuration) Console.WriteLine("======================"); Console.WriteLine($"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"); Console.WriteLine(connectionString); - - services.AddSingleton( new DbDataManager(connectionString)); + services.AddDbContext(options => + options.UseSqlite(connectionString), ServiceLifetime.Singleton); + services.AddSingleton(provider => new DbDataManager(provider.GetRequiredService())); break; default: diff --git a/src/Model2Entities/DbDataManager.cs b/src/Model2Entities/DbDataManager.cs index fd7661e..6384b43 100644 --- a/src/Model2Entities/DbDataManager.cs +++ b/src/Model2Entities/DbDataManager.cs @@ -18,11 +18,8 @@ public partial class DbDataManager: IDataManager DbContext = dbContext; Console.WriteLine("Contexttttttttt"); Console.WriteLine($"Database created Context: {DbContext.Database.EnsureCreated()}"); - DbContext.Database.EnsureCreated(); - Console.WriteLine($"Database created Context: {DbContext.Database.EnsureCreated()}"); ActivityRepo = new ActivityRepository(this); UserRepo = new UserRepository(this); - DbContext.Database.EnsureCreated(); ActivityMapper.Reset(); // Faire pour les autres reset() des autres mappers } @@ -30,14 +27,12 @@ public partial class DbDataManager: IDataManager public DbDataManager(string dbPlatformPath) : this(new HeartTrackContext(dbPlatformPath)) { - DbContext.Database.EnsureCreated(); Console.WriteLine($"Database created String: {DbContext.Database.EnsureCreated()}"); } public DbDataManager() { DbContext = new HeartTrackContext(); - DbContext.Database.EnsureCreated(); Console.WriteLine($"Database created None: {DbContext.Database.EnsureCreated()}"); ActivityRepo = new ActivityRepository(this); UserRepo= new UserRepository(this); From 5a572fbbc59d76ef23817a6d457bbc1bad809bb3 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 20:57:00 +0100 Subject: [PATCH 51/74] ok --- src/HeartTrackAPI/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index b0d1478..aec4188 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -41,5 +41,5 @@ RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publis FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -RUN ls +RUN ls -R ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From 11eaff4a6459a980ca53a99e629eb4eac7d75c82 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 21:45:31 +0100 Subject: [PATCH 52/74] poo --- src/HeartTrackAPI/Dockerfile | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index aec4188..394502c 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -25,21 +25,24 @@ RUN dotnet tool install --global dotnet-ef --version 8.0 ENV PATH="${PATH}:/root/.dotnet/tools" # Add the migrations -#RUN dotnet ef migrations add --project StubbedContextLib/ --startup-project HeartTrackAPI/ --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial --output-dir Migrations -RUN dotnet ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial +RUN dotnet-ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial # Update the database -RUN dotnet ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug - +RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug +RUN ls HeartTrackAPI/ WORKDIR "/src/HeartTrackAPI" RUN ls +RUN ls HeartTrackAPI/ RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false - +RUN ls FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -RUN ls -R +COPY --from=build /src/uca.HeartTrack.db . +RUN ls + +RUN chmod 777 uca.HeartTrack.db ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From 3b13510c35a25adc9cb1eb3d85f9fadeb7d81660 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 21:49:07 +0100 Subject: [PATCH 53/74] o --- src/HeartTrackAPI/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 394502c..1da70f4 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -31,7 +31,6 @@ RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.cspr RUN ls HeartTrackAPI/ WORKDIR "/src/HeartTrackAPI" RUN ls -RUN ls HeartTrackAPI/ RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish From d8623ee27cd1202d40cbb77496407cd8d2561690 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 21:56:49 +0100 Subject: [PATCH 54/74] k --- src/HeartTrackAPI/Dockerfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 1da70f4..36af602 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -36,11 +36,13 @@ RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false -RUN ls +RUN ls +RUN ls / + FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -COPY --from=build /src/uca.HeartTrack.db . +COPY --from=publish ./uca.HeartTrack.db . RUN ls RUN chmod 777 uca.HeartTrack.db From 07a0cbe752b758a0f783ba59d72bb7d647b8fc45 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 21:59:23 +0100 Subject: [PATCH 55/74] okkkkkkkkkkkk --- src/HeartTrackAPI/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 36af602..72407cb 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -42,7 +42,7 @@ RUN ls / FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -COPY --from=publish ./uca.HeartTrack.db . +COPY --from=publish ~/uca.HeartTrack.db . RUN ls RUN chmod 777 uca.HeartTrack.db From e9c2536c15455372e85c2adedc58354adcf52f69 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:02:56 +0100 Subject: [PATCH 56/74] let's --- src/HeartTrackAPI/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 72407cb..a558543 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -38,7 +38,7 @@ ARG BUILD_CONFIGURATION=Release RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false RUN ls RUN ls / - +RUN ls /home/ FROM base AS final WORKDIR /app COPY --from=publish /app/publish . From dce46eb46a2a79a96478b25cd989bc785180bbb6 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:06:19 +0100 Subject: [PATCH 57/74] davee --- src/HeartTrackAPI/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index a558543..0b7b625 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -38,7 +38,7 @@ ARG BUILD_CONFIGURATION=Release RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false RUN ls RUN ls / -RUN ls /home/ +RUN ls /src FROM base AS final WORKDIR /app COPY --from=publish /app/publish . From f6ca717dd2cbaba565b4de3566dcc62518c92a1d Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:09:02 +0100 Subject: [PATCH 58/74] please --- src/HeartTrackAPI/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 0b7b625..1c7659f 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -42,7 +42,7 @@ RUN ls /src FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -COPY --from=publish ~/uca.HeartTrack.db . +COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . RUN ls RUN chmod 777 uca.HeartTrack.db From c65ffe80c125ba16aaeb58180d669e9250f764c5 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:12:24 +0100 Subject: [PATCH 59/74] just test --- src/HeartTrackAPI/Dockerfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 1c7659f..fac2085 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -28,7 +28,6 @@ ENV PATH="${PATH}:/root/.dotnet/tools" RUN dotnet-ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial # Update the database RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug -RUN ls HeartTrackAPI/ WORKDIR "/src/HeartTrackAPI" RUN ls RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build @@ -36,14 +35,9 @@ RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false -RUN ls -RUN ls / -RUN ls /src FROM base AS final WORKDIR /app COPY --from=publish /app/publish . COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . -RUN ls - -RUN chmod 777 uca.HeartTrack.db +RUN chown $APP_UID:$APP_UID uca.HeartTrack.db ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From 123de329fa31a34f5c6e79b5aaacba254fbddb90 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:15:53 +0100 Subject: [PATCH 60/74] :rotating_light: beleck sa passe --- src/HeartTrackAPI/Dockerfile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index fac2085..8656c8e 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -21,15 +21,9 @@ COPY ["StubAPI/StubAPI.csproj", "StubAPI/"] COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"] RUN dotnet restore "HeartTrackAPI/HeartTrackAPI.csproj" COPY . . -RUN dotnet tool install --global dotnet-ef --version 8.0 -ENV PATH="${PATH}:/root/.dotnet/tools" -# Add the migrations -RUN dotnet-ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial -# Update the database -RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug WORKDIR "/src/HeartTrackAPI" -RUN ls + RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish @@ -38,6 +32,13 @@ RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publis FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . -RUN chown $APP_UID:$APP_UID uca.HeartTrack.db +RUN dotnet tool install --global dotnet-ef --version 8.0 + +ENV PATH="${PATH}:/root/.dotnet/tools" +# Add the migrations +RUN dotnet-ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial +# Update the database +RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug + +# COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From 3ca3f2e9ff523decd59f462aea034a3f6263d3cf Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:18:59 +0100 Subject: [PATCH 61/74] :arrow_up: again boy --- src/HeartTrackAPI/Dockerfile | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 8656c8e..7bc5a42 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -21,9 +21,15 @@ COPY ["StubAPI/StubAPI.csproj", "StubAPI/"] COPY ["StubbedContextLib/StubbedContextLib.csproj", "StubbedContextLib/"] RUN dotnet restore "HeartTrackAPI/HeartTrackAPI.csproj" COPY . . +RUN dotnet tool install --global dotnet-ef --version 8.0 -WORKDIR "/src/HeartTrackAPI" +ENV PATH="${PATH}:/root/.dotnet/tools" +# Add the migrations +RUN dotnet-ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial +# Update the database +RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug +WORKDIR "/src/HeartTrackAPI" RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish @@ -32,13 +38,5 @@ RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publis FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -RUN dotnet tool install --global dotnet-ef --version 8.0 - -ENV PATH="${PATH}:/root/.dotnet/tools" -# Add the migrations -RUN dotnet-ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial -# Update the database -RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug - -# COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . +COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From 84e597062f22094359a3dfb28708367123601c75 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:27:46 +0100 Subject: [PATCH 62/74] :recycle: here we go again --- src/HeartTrackAPI/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 7bc5a42..e38cf65 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -28,6 +28,7 @@ ENV PATH="${PATH}:/root/.dotnet/tools" RUN dotnet-ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial # Update the database RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug +RUN chmod 777 HeartTrackAPI/uca.HeartTrack.db WORKDIR "/src/HeartTrackAPI" RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build @@ -39,4 +40,6 @@ FROM base AS final WORKDIR /app COPY --from=publish /app/publish . COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . +RUN chmod 664 uca.HeartTrack.db + ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From 631844d6a4fcdc17d22e95b4d85c7059c5a5eafc Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:29:32 +0100 Subject: [PATCH 63/74] goooooo --- src/HeartTrackAPI/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index e38cf65..140f1ed 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -28,7 +28,6 @@ ENV PATH="${PATH}:/root/.dotnet/tools" RUN dotnet-ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial # Update the database RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug -RUN chmod 777 HeartTrackAPI/uca.HeartTrack.db WORKDIR "/src/HeartTrackAPI" RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build @@ -40,6 +39,7 @@ FROM base AS final WORKDIR /app COPY --from=publish /app/publish . COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . +RUN ls -R / RUN chmod 664 uca.HeartTrack.db ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From 542c35662a9c41ac1df4aaaf1dbdb99f9f8c8a08 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:32:36 +0100 Subject: [PATCH 64/74] hey --- src/HeartTrackAPI/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 140f1ed..8f8da7e 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -28,6 +28,7 @@ ENV PATH="${PATH}:/root/.dotnet/tools" RUN dotnet-ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial # Update the database RUN dotnet-ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug +RUN chmod 777 HeartTrackAPI/uca.HeartTrack.db WORKDIR "/src/HeartTrackAPI" RUN dotnet build "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build @@ -40,6 +41,6 @@ WORKDIR /app COPY --from=publish /app/publish . COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . RUN ls -R / -RUN chmod 664 uca.HeartTrack.db +ls -l uca.HeartTrack.db ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From 078b2b7e61cde96d186472130657ad2cb4feddcd Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:36:46 +0100 Subject: [PATCH 65/74] fix docker parse error --- src/HeartTrackAPI/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 8f8da7e..4bac471 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -40,7 +40,7 @@ FROM base AS final WORKDIR /app COPY --from=publish /app/publish . COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . -RUN ls -R / +RUN ls -R / \ ls -l uca.HeartTrack.db ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From 80bacc3f336aa4017b3af643e87c44aea14872bd Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:43:34 +0100 Subject: [PATCH 66/74] rhlasss :pushpin: --- src/HeartTrackAPI/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 4bac471..a00c03b 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -40,7 +40,6 @@ FROM base AS final WORKDIR /app COPY --from=publish /app/publish . COPY --from=publish /src/HeartTrackAPI/uca.HeartTrack.db . -RUN ls -R / \ -ls -l uca.HeartTrack.db +RUN ls -l uca.HeartTrack.db ENTRYPOINT ["dotnet", "HeartTrackAPI.dll"] \ No newline at end of file From c43841d4faf306e834ad148dd7f447d946208858 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:50:20 +0100 Subject: [PATCH 67/74] fu --- src/HeartTrackAPI/AppBootstrap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 2f75fb0..41a428b 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -53,7 +53,7 @@ public class AppBootstrap(IConfiguration configuration) var USERNAME = System.Environment.GetEnvironmentVariable("USERNAME"); var PASSWORD = System.Environment.GetEnvironmentVariable("PASSWORD"); - connectionString = $"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"; + connectionString = $"Server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"; Console.WriteLine(connectionString); Console.WriteLine("======================"); Console.WriteLine($"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"); From 9ef2b99a9711fb00a6a6110644dd5a5855c6d501 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 22:57:31 +0100 Subject: [PATCH 68/74] tot --- src/HeartTrackAPI/AppBootstrap.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 41a428b..c8e3603 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -59,7 +59,8 @@ public class AppBootstrap(IConfiguration configuration) Console.WriteLine($"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"); Console.WriteLine(connectionString); services.AddDbContext(options => - options.UseSqlite(connectionString), ServiceLifetime.Singleton); + options.UseMySql($"{connectionString}", new MySqlServerVersion(new Version(10, 11, 1))) + , ServiceLifetime.Singleton); services.AddSingleton(provider => new DbDataManager(provider.GetRequiredService())); break; From 8bed8f9272d68558407c1d475ba07b06e19802e3 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 23:01:44 +0100 Subject: [PATCH 69/74] ITSSSSSSSSS WORKIINGG:chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend::chart_with_upwards_trend: --- src/HeartTrackAPI/Request/PageRequest.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HeartTrackAPI/Request/PageRequest.cs b/src/HeartTrackAPI/Request/PageRequest.cs index 0c93406..a4399f4 100644 --- a/src/HeartTrackAPI/Request/PageRequest.cs +++ b/src/HeartTrackAPI/Request/PageRequest.cs @@ -8,9 +8,9 @@ public class PageRequest public string? OrderingPropertyName { get; set; } = null; public bool? Descending { get; set; } = false; - [Range(1, int.MaxValue, ErrorMessage = "Count must be greater than 0")] +// [Range(0, int.MaxValue, ErrorMessage = "Count must be greater than 0")] public int Index { get; set; } = 0; - [Range(1, int.MaxValue, ErrorMessage = "Count must be greater than 0")] +// [Range(0, int.MaxValue, ErrorMessage = "Count must be greater than 0")] public int Count { get; set; } = 1; } From d70ca44c54ac48d456cf2734428b566c533bca39 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 14 Mar 2024 23:06:59 +0100 Subject: [PATCH 70/74] :tada: :tada: Fuck tout ceux qui croyais pas en moi :tada::tada: --- src/HeartTrackAPI/AppBootstrap.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index c8e3603..fdbe6a0 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -61,8 +61,6 @@ public class AppBootstrap(IConfiguration configuration) services.AddDbContext(options => options.UseMySql($"{connectionString}", new MySqlServerVersion(new Version(10, 11, 1))) , ServiceLifetime.Singleton); - services.AddSingleton(provider => new DbDataManager(provider.GetRequiredService())); - break; default: connectionString = Configuration.GetConnectionString("HeartTrackAuthConnection"); @@ -102,7 +100,9 @@ public class AppBootstrap(IConfiguration configuration) private void AddModelService(IServiceCollection services) { //services.AddSingleton(provider => new DbDataManager(provider.GetService())); - services.AddSingleton(); + //services.AddSingleton(); + services.AddSingleton(provider => new DbDataManager(provider.GetRequiredService())); + //services.AddTransient(); } From a3d86c625bc6724d0fb30569dc46b852bd60ee39 Mon Sep 17 00:00:00 2001 From: David D'ALMEIDA Date: Thu, 14 Mar 2024 23:45:35 +0100 Subject: [PATCH 71/74] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'README.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e00e2f0..97126b3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ # EF_WebAPI -This repository make a meeting of EF and WebAPI parts. \ No newline at end of file +This repository make a meeting of EF and WebAPI parts. + +FROM /src dir + +do + +```bash +dotnet ef migrations add --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug Initial --output-dir Migrations +``` +then + +```bash +dotnet ef database update --project StubbedContextLib/StubbedContextLib.csproj --startup-project HeartTrackAPI/HeartTrackAPI.csproj --context StubbedContextLib.TrainingStubbedContext --configuration Debug +``` From 205fb3882ae814835c524869ef84b95c134885b7 Mon Sep 17 00:00:00 2001 From: "kevin.monteiro" Date: Fri, 15 Mar 2024 00:53:23 +0100 Subject: [PATCH 72/74] Tests --- .../StubbedContextLib.csproj | 4 + .../UnitTestsEntities/ActivityEntityTests.cs | 149 ++++++++++++++++++ src/Tests/UnitTestsEntities/UnitTest1.cs | 10 -- .../UnitTestsEntities.csproj | 5 + src/UnitTestsEntities2/UnitTest1.cs | 11 ++ .../UnitTestsEntities2.csproj | 23 +++ 6 files changed, 192 insertions(+), 10 deletions(-) create mode 100644 src/Tests/UnitTestsEntities/ActivityEntityTests.cs delete mode 100644 src/Tests/UnitTestsEntities/UnitTest1.cs create mode 100644 src/UnitTestsEntities2/UnitTest1.cs create mode 100644 src/UnitTestsEntities2/UnitTestsEntities2.csproj diff --git a/src/StubbedContextLib/StubbedContextLib.csproj b/src/StubbedContextLib/StubbedContextLib.csproj index bdd147f..0c5f479 100644 --- a/src/StubbedContextLib/StubbedContextLib.csproj +++ b/src/StubbedContextLib/StubbedContextLib.csproj @@ -13,6 +13,10 @@ + + + + net8.0 enable diff --git a/src/Tests/UnitTestsEntities/ActivityEntityTests.cs b/src/Tests/UnitTestsEntities/ActivityEntityTests.cs new file mode 100644 index 0000000..bc8e091 --- /dev/null +++ b/src/Tests/UnitTestsEntities/ActivityEntityTests.cs @@ -0,0 +1,149 @@ +namespace UnitTestsEntities; +using Xunit; +using System.Linq; +using Entities; +using Microsoft.EntityFrameworkCore; + +public class ActivityEntityTests +{ + /*[Fact] + public void Add_Activity_Success() + { + + + var activity = new ActivityEntity + { + Type = "Running", + Date = new DateOnly(2024, 3, 15), + StartTime = new TimeOnly(9, 0), + EndTime = new TimeOnly(10, 0), + EffortFelt = 7, + Variability = 0.5f, + Variance = 0.2f, + StandardDeviation = 0.3f, + Average = 0.4f, + Maximum = 200, + Minimum = 100, + AverageTemperature = 25.5f, + HasAutoPause = true, + DataSourceId = 1, + AthleteId = 1 + }; + + // Act + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Activities.Add(activity); + context.SaveChanges(); + } + + // Assert + using (var context = new StubbedContext(options)) + { + var savedActivity = context.Activities.First(a => a.Type == "Running"); + Assert.NotNull(savedActivity); + } + } + + [Fact] + public void Update_Activity_Success() + { + // Arrange + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(databaseName: "Update_Activity_Success") + .Options; + + var activity = new ActivityEntity + { + Type = "Running", + Date = new DateOnly(2024, 3, 15), + StartTime = new TimeOnly(9, 0), + EndTime = new TimeOnly(10, 0), + EffortFelt = 7, + Variability = 0.5f, + Variance = 0.2f, + StandardDeviation = 0.3f, + Average = 0.4f, + Maximum = 200, + Minimum = 100, + AverageTemperature = 25.5f, + HasAutoPause = true, + DataSourceId = 1, + AthleteId = 1 + }; + + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Activities.Add(activity); + context.SaveChanges(); + } + + // Act + using (var context = new StubbedContext(options)) + { + var savedActivity = context.Activities.First(a => a.Type == "Running"); + savedActivity.Type = "Walking"; + context.SaveChanges(); + } + + // Assert + using (var context = new StubbedContext(options)) + { + var updatedActivity = context.Activities.First(a => a.Type == "Walking"); + Assert.NotNull(updatedActivity); + } + } + + [Fact] + public void Delete_Activity_Success() + { + // Arrange + var options = new DbContextOptionsBuilder() + .UseInMemoryDatabase(databaseName: "Delete_Activity_Success") + .Options; + + var activity = new ActivityEntity + { + Type = "Running", + Date = new DateOnly(2024, 3, 15), + StartTime = new TimeOnly(9, 0), + EndTime = new TimeOnly(10, 0), + EffortFelt = 7, + Variability = 0.5f, + Variance = 0.2f, + StandardDeviation = 0.3f, + Average = 0.4f, + Maximum = 200, + Minimum = 100, + AverageTemperature = 25.5f, + HasAutoPause = true, + DataSourceId = 1, + AthleteId = 1 + }; + + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Activities.Add(activity); + context.SaveChanges(); + } + + // Act + using (var context = new StubbedContext(options)) + { + var savedActivity = context.Activities.First(a => a.Type == "Running"); + context.Activities.Remove(savedActivity); + context.SaveChanges(); + } + + // Assert + using (var context = new StubbedContext(options)) + { + var deletedActivity = context.Activities.FirstOrDefault(a => a.Type == "Running"); + Assert.Null(deletedActivity); + } + }*/ +} + diff --git a/src/Tests/UnitTestsEntities/UnitTest1.cs b/src/Tests/UnitTestsEntities/UnitTest1.cs deleted file mode 100644 index 4494897..0000000 --- a/src/Tests/UnitTestsEntities/UnitTest1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace UnitTestsEntities; - -public class UnitTest1 -{ - [Fact] - public void Test1() - { - - } -} \ No newline at end of file diff --git a/src/Tests/UnitTestsEntities/UnitTestsEntities.csproj b/src/Tests/UnitTestsEntities/UnitTestsEntities.csproj index 22b0134..e372137 100644 --- a/src/Tests/UnitTestsEntities/UnitTestsEntities.csproj +++ b/src/Tests/UnitTestsEntities/UnitTestsEntities.csproj @@ -10,6 +10,7 @@ + @@ -22,4 +23,8 @@ + + + + diff --git a/src/UnitTestsEntities2/UnitTest1.cs b/src/UnitTestsEntities2/UnitTest1.cs new file mode 100644 index 0000000..8b121a7 --- /dev/null +++ b/src/UnitTestsEntities2/UnitTest1.cs @@ -0,0 +1,11 @@ +namespace UnitTestsEntities2 +{ + public class UnitTest1 + { + [Fact] + public void Test1() + { + + } + } +} \ No newline at end of file diff --git a/src/UnitTestsEntities2/UnitTestsEntities2.csproj b/src/UnitTestsEntities2/UnitTestsEntities2.csproj new file mode 100644 index 0000000..9c5b30a --- /dev/null +++ b/src/UnitTestsEntities2/UnitTestsEntities2.csproj @@ -0,0 +1,23 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + + + + + + + + From 06351b05f00b2f76e0eb57f97514d54414483b36 Mon Sep 17 00:00:00 2001 From: "kevin.monteiro" Date: Fri, 15 Mar 2024 00:54:18 +0100 Subject: [PATCH 73/74] .. --- src/HeartTrack.sln | 66 +++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/src/HeartTrack.sln b/src/HeartTrack.sln index 6b62741..2427430 100644 --- a/src/HeartTrack.sln +++ b/src/HeartTrack.sln @@ -3,52 +3,51 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbContextLib", "DbContextLib\DbContextLib.csproj", "{330A5DA0-0B4E-48D4-9AF3-6DCB39EE9622}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DbContextLib", "DbContextLib\DbContextLib.csproj", "{330A5DA0-0B4E-48D4-9AF3-6DCB39EE9622}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Entities", "Entities\Entities.csproj", "{A07F86B3-555B-4B35-8BB1-25E844825A38}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entities.csproj", "{A07F86B3-555B-4B35-8BB1-25E844825A38}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{2F44DE6E-EFFC-42FE-AFF6-79CDC762E6D8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubbedContextLib", "StubbedContextLib\StubbedContextLib.csproj", "{2F44DE6E-EFFC-42FE-AFF6-79CDC762E6D8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{2B227C67-3BEC-4A83-BDA0-F3918FBC0D18}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTestEntities", "Tests\ConsoleTestEntities\ConsoleTestEntities.csproj", "{477D2129-A6C9-4FF8-8BE9-5E9E8E5282F8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTestEntities", "Tests\ConsoleTestEntities\ConsoleTestEntities.csproj", "{477D2129-A6C9-4FF8-8BE9-5E9E8E5282F8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTestRelationships", "Tests\ConsoleTestRelationships\ConsoleTestRelationships.csproj", "{2D166FAD-4934-474B-96A8-6C0635156EC2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTestRelationships", "Tests\ConsoleTestRelationships\ConsoleTestRelationships.csproj", "{2D166FAD-4934-474B-96A8-6C0635156EC2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dto", "Dto\Dto.csproj", "{562019BC-0F61-41B0-9BAE-259B92C6BFBA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dto", "Dto\Dto.csproj", "{562019BC-0F61-41B0-9BAE-259B92C6BFBA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeartTrackAPI", "HeartTrackAPI\HeartTrackAPI.csproj", "{C1C2EAC3-3347-466B-BFB6-2A9F11A3AE12}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HeartTrackAPI", "HeartTrackAPI\HeartTrackAPI.csproj", "{C1C2EAC3-3347-466B-BFB6-2A9F11A3AE12}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{F80C60E1-1E06-46C2-96DE-42B1C7DE65BC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "Shared\Shared.csproj", "{F80C60E1-1E06-46C2-96DE-42B1C7DE65BC}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestsAPI", "TestsAPI", "{30FC2BE9-7397-445A-84AD-043CE70F4281}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientTests", "Tests\TestsAPI\ClientTests\ClientTests.csproj", "{9E4D3AC5-E6CA-4753-BD96-BF5EE793931A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientTests", "Tests\TestsAPI\ClientTests\ClientTests.csproj", "{9E4D3AC5-E6CA-4753-BD96-BF5EE793931A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{30AB7FAA-6072-40B6-A15E-9188B59144F9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{30AB7FAA-6072-40B6-A15E-9188B59144F9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestApi", "Tests\TestsAPI\UnitTestApi\UnitTestApi.csproj", "{E515C8B6-6282-4D8B-8523-7B3A13E4AF58}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTestApi", "Tests\TestsAPI\UnitTestApi\UnitTestApi.csproj", "{E515C8B6-6282-4D8B-8523-7B3A13E4AF58}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestsEntities", "Tests\UnitTestsEntities\UnitTestsEntities.csproj", "{31FA8E5E-D642-4C43-A2B2-02B9832B2CEC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTestsEntities", "Tests\UnitTestsEntities\UnitTestsEntities.csproj", "{31FA8E5E-D642-4C43-A2B2-02B9832B2CEC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model2Entities", "Model2Entities\Model2Entities.csproj", "{FA329DEF-4756-4A8B-84E9-5A625FF94CBF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model2Entities", "Model2Entities\Model2Entities.csproj", "{FA329DEF-4756-4A8B-84E9-5A625FF94CBF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubAPI", "StubAPI\StubAPI.csproj", "{C9BD0310-DC18-4356-B8A7-2B6959AF7813}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StubAPI", "StubAPI\StubAPI.csproj", "{C9BD0310-DC18-4356-B8A7-2B6959AF7813}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleTestEFMapper", "Tests\ConsoleTestEFMapper\ConsoleTestEFMapper.csproj", "{73EA27F2-9F0C-443F-A5EE-2960C983A422}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTestEFMapper", "Tests\ConsoleTestEFMapper\ConsoleTestEFMapper.csproj", "{73EA27F2-9F0C-443F-A5EE-2960C983A422}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EFMappers", "EFMappers\EFMappers.csproj", "{9397795D-F482-44C4-8443-A20AC26671AA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFMappers", "EFMappers\EFMappers.csproj", "{9397795D-F482-44C4-8443-A20AC26671AA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "APIMappers", "APIMappers\APIMappers.csproj", "{41D18203-1688-43BD-A3AC-FD0C2BD81909}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APIMappers", "APIMappers\APIMappers.csproj", "{41D18203-1688-43BD-A3AC-FD0C2BD81909}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestsEntities2", "UnitTestsEntities2\UnitTestsEntities2.csproj", "{43757AC2-2924-46CF-BCCD-80F1C1265B6A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {330A5DA0-0B4E-48D4-9AF3-6DCB39EE9622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {330A5DA0-0B4E-48D4-9AF3-6DCB39EE9622}.Debug|Any CPU.Build.0 = Debug|Any CPU @@ -90,14 +89,6 @@ Global {30AB7FAA-6072-40B6-A15E-9188B59144F9}.Debug|Any CPU.Build.0 = Debug|Any CPU {30AB7FAA-6072-40B6-A15E-9188B59144F9}.Release|Any CPU.ActiveCfg = Release|Any CPU {30AB7FAA-6072-40B6-A15E-9188B59144F9}.Release|Any CPU.Build.0 = Release|Any CPU - {CB142F6B-0FF1-45B3-AB46-6F8DCD096C20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CB142F6B-0FF1-45B3-AB46-6F8DCD096C20}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CB142F6B-0FF1-45B3-AB46-6F8DCD096C20}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CB142F6B-0FF1-45B3-AB46-6F8DCD096C20}.Release|Any CPU.Build.0 = Release|Any CPU - {B9679DCA-F4C8-45BE-A849-44E2BA814083}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B9679DCA-F4C8-45BE-A849-44E2BA814083}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B9679DCA-F4C8-45BE-A849-44E2BA814083}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B9679DCA-F4C8-45BE-A849-44E2BA814083}.Release|Any CPU.Build.0 = Release|Any CPU {E515C8B6-6282-4D8B-8523-7B3A13E4AF58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E515C8B6-6282-4D8B-8523-7B3A13E4AF58}.Debug|Any CPU.Build.0 = Debug|Any CPU {E515C8B6-6282-4D8B-8523-7B3A13E4AF58}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -114,18 +105,10 @@ Global {C9BD0310-DC18-4356-B8A7-2B6959AF7813}.Debug|Any CPU.Build.0 = Debug|Any CPU {C9BD0310-DC18-4356-B8A7-2B6959AF7813}.Release|Any CPU.ActiveCfg = Release|Any CPU {C9BD0310-DC18-4356-B8A7-2B6959AF7813}.Release|Any CPU.Build.0 = Release|Any CPU - {06DBE9E4-6AA5-4D09-8544-D3ED91E2D980}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {06DBE9E4-6AA5-4D09-8544-D3ED91E2D980}.Debug|Any CPU.Build.0 = Debug|Any CPU - {06DBE9E4-6AA5-4D09-8544-D3ED91E2D980}.Release|Any CPU.ActiveCfg = Release|Any CPU - {06DBE9E4-6AA5-4D09-8544-D3ED91E2D980}.Release|Any CPU.Build.0 = Release|Any CPU {73EA27F2-9F0C-443F-A5EE-2960C983A422}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {73EA27F2-9F0C-443F-A5EE-2960C983A422}.Debug|Any CPU.Build.0 = Debug|Any CPU {73EA27F2-9F0C-443F-A5EE-2960C983A422}.Release|Any CPU.ActiveCfg = Release|Any CPU {73EA27F2-9F0C-443F-A5EE-2960C983A422}.Release|Any CPU.Build.0 = Release|Any CPU - {C9C9F2A5-9132-4067-B240-B299D2FCF4E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C9C9F2A5-9132-4067-B240-B299D2FCF4E9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C9C9F2A5-9132-4067-B240-B299D2FCF4E9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C9C9F2A5-9132-4067-B240-B299D2FCF4E9}.Release|Any CPU.Build.0 = Release|Any CPU {9397795D-F482-44C4-8443-A20AC26671AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9397795D-F482-44C4-8443-A20AC26671AA}.Debug|Any CPU.Build.0 = Debug|Any CPU {9397795D-F482-44C4-8443-A20AC26671AA}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -134,6 +117,13 @@ Global {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Debug|Any CPU.Build.0 = Debug|Any CPU {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Release|Any CPU.ActiveCfg = Release|Any CPU {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Release|Any CPU.Build.0 = Release|Any CPU + {43757AC2-2924-46CF-BCCD-80F1C1265B6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43757AC2-2924-46CF-BCCD-80F1C1265B6A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43757AC2-2924-46CF-BCCD-80F1C1265B6A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43757AC2-2924-46CF-BCCD-80F1C1265B6A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {477D2129-A6C9-4FF8-8BE9-5E9E8E5282F8} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} @@ -143,5 +133,9 @@ Global {E515C8B6-6282-4D8B-8523-7B3A13E4AF58} = {30FC2BE9-7397-445A-84AD-043CE70F4281} {31FA8E5E-D642-4C43-A2B2-02B9832B2CEC} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} {73EA27F2-9F0C-443F-A5EE-2960C983A422} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} + {43757AC2-2924-46CF-BCCD-80F1C1265B6A} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0F3487F4-66CA-4034-AC66-1BC899C9B523} EndGlobalSection EndGlobal From 55364ee99937cfb37e71eca28c892506e6c69574 Mon Sep 17 00:00:00 2001 From: "kevin.monteiro" Date: Fri, 15 Mar 2024 01:30:13 +0100 Subject: [PATCH 74/74] =?UTF-8?q?:boom:=20:construction:=20D=C3=A9but=20de?= =?UTF-8?q?s=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/HeartTrack.sln | 7 - .../UnitTestsEntities/ActivityEntityTests.cs | 33 +-- .../UnitTestsEntities/AthleteEntityTests.cs | 122 +++++++++++ .../DataSourceEntityTests.cs | 102 +++++++++ .../FriendshipEntityTests.cs | 206 ++++++++++++++++++ .../UnitTestsEntities/HeartRateEntityTests.cs | 172 +++++++++++++++ .../NotificationEntityTests.cs | 151 +++++++++++++ .../UnitTestsEntities/StatisticEntityTests.cs | 155 +++++++++++++ .../UnitTestsEntities/TrainingEntityTests.cs | 202 +++++++++++++++++ 9 files changed, 1122 insertions(+), 28 deletions(-) create mode 100644 src/Tests/UnitTestsEntities/AthleteEntityTests.cs create mode 100644 src/Tests/UnitTestsEntities/DataSourceEntityTests.cs create mode 100644 src/Tests/UnitTestsEntities/FriendshipEntityTests.cs create mode 100644 src/Tests/UnitTestsEntities/HeartRateEntityTests.cs create mode 100644 src/Tests/UnitTestsEntities/NotificationEntityTests.cs create mode 100644 src/Tests/UnitTestsEntities/StatisticEntityTests.cs create mode 100644 src/Tests/UnitTestsEntities/TrainingEntityTests.cs diff --git a/src/HeartTrack.sln b/src/HeartTrack.sln index 2427430..8947e4c 100644 --- a/src/HeartTrack.sln +++ b/src/HeartTrack.sln @@ -41,8 +41,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EFMappers", "EFMappers\EFMa EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "APIMappers", "APIMappers\APIMappers.csproj", "{41D18203-1688-43BD-A3AC-FD0C2BD81909}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestsEntities2", "UnitTestsEntities2\UnitTestsEntities2.csproj", "{43757AC2-2924-46CF-BCCD-80F1C1265B6A}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -117,10 +115,6 @@ Global {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Debug|Any CPU.Build.0 = Debug|Any CPU {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Release|Any CPU.ActiveCfg = Release|Any CPU {41D18203-1688-43BD-A3AC-FD0C2BD81909}.Release|Any CPU.Build.0 = Release|Any CPU - {43757AC2-2924-46CF-BCCD-80F1C1265B6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {43757AC2-2924-46CF-BCCD-80F1C1265B6A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {43757AC2-2924-46CF-BCCD-80F1C1265B6A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {43757AC2-2924-46CF-BCCD-80F1C1265B6A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -133,7 +127,6 @@ Global {E515C8B6-6282-4D8B-8523-7B3A13E4AF58} = {30FC2BE9-7397-445A-84AD-043CE70F4281} {31FA8E5E-D642-4C43-A2B2-02B9832B2CEC} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} {73EA27F2-9F0C-443F-A5EE-2960C983A422} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} - {43757AC2-2924-46CF-BCCD-80F1C1265B6A} = {2B227C67-3BEC-4A83-BDA0-F3918FBC0D18} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0F3487F4-66CA-4034-AC66-1BC899C9B523} diff --git a/src/Tests/UnitTestsEntities/ActivityEntityTests.cs b/src/Tests/UnitTestsEntities/ActivityEntityTests.cs index bc8e091..62caaae 100644 --- a/src/Tests/UnitTestsEntities/ActivityEntityTests.cs +++ b/src/Tests/UnitTestsEntities/ActivityEntityTests.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore; public class ActivityEntityTests { - /*[Fact] + [Fact] public void Add_Activity_Success() { @@ -30,7 +30,7 @@ public class ActivityEntityTests AthleteId = 1 }; - // Act + /* using (var context = new StubbedContext(options)) { context.Database.EnsureCreated(); @@ -38,22 +38,18 @@ public class ActivityEntityTests context.SaveChanges(); } - // Assert using (var context = new StubbedContext(options)) { var savedActivity = context.Activities.First(a => a.Type == "Running"); Assert.NotNull(savedActivity); - } + Assert.Equal("Running", savedActivity.Type ); + + }*/ } [Fact] public void Update_Activity_Success() { - // Arrange - var options = new DbContextOptionsBuilder() - .UseInMemoryDatabase(databaseName: "Update_Activity_Success") - .Options; - var activity = new ActivityEntity { Type = "Running", @@ -73,6 +69,7 @@ public class ActivityEntityTests AthleteId = 1 }; + /* using (var context = new StubbedContext(options)) { context.Database.EnsureCreated(); @@ -80,7 +77,6 @@ public class ActivityEntityTests context.SaveChanges(); } - // Act using (var context = new StubbedContext(options)) { var savedActivity = context.Activities.First(a => a.Type == "Running"); @@ -88,22 +84,18 @@ public class ActivityEntityTests context.SaveChanges(); } - // Assert using (var context = new StubbedContext(options)) { var updatedActivity = context.Activities.First(a => a.Type == "Walking"); Assert.NotNull(updatedActivity); - } + Assert.Equal("Walking", updatedActivity.Type ); + Assert.Equal(7, updatedActivity.EffortFelt ); + }*/ } [Fact] public void Delete_Activity_Success() { - // Arrange - var options = new DbContextOptionsBuilder() - .UseInMemoryDatabase(databaseName: "Delete_Activity_Success") - .Options; - var activity = new ActivityEntity { Type = "Running", @@ -123,6 +115,7 @@ public class ActivityEntityTests AthleteId = 1 }; + /* using (var context = new StubbedContext(options)) { context.Database.EnsureCreated(); @@ -130,7 +123,6 @@ public class ActivityEntityTests context.SaveChanges(); } - // Act using (var context = new StubbedContext(options)) { var savedActivity = context.Activities.First(a => a.Type == "Running"); @@ -138,12 +130,11 @@ public class ActivityEntityTests context.SaveChanges(); } - // Assert using (var context = new StubbedContext(options)) { var deletedActivity = context.Activities.FirstOrDefault(a => a.Type == "Running"); Assert.Null(deletedActivity); - } - }*/ + }*/ + } } diff --git a/src/Tests/UnitTestsEntities/AthleteEntityTests.cs b/src/Tests/UnitTestsEntities/AthleteEntityTests.cs new file mode 100644 index 0000000..878d7d8 --- /dev/null +++ b/src/Tests/UnitTestsEntities/AthleteEntityTests.cs @@ -0,0 +1,122 @@ +namespace UnitTestsEntities; +using Xunit; +using System.Linq; +using Entities; +using Microsoft.EntityFrameworkCore; + +public class AthleteEntityTests +{ + [Fact] + public void Add_Athlete_Success() + { + var athlete = new AthleteEntity + { + Username = "john_doe", + LastName = "Doe", + FirstName = "John", + Email = "john.doe@example.com", + Sexe = "M", + Length = 180.0, + Weight = 75.5f, + Password = "password", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(athlete); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedAthlete = context.Athletes.First(a => a.Username == "john_doe"); + Assert.NotNull(savedAthlete); + Assert.Equal("john_doe", savedAthlete.Username); + }*/ + } + + [Fact] + public void Update_Athlete_Success() + { + var athlete = new AthleteEntity + { + Username = "jane_smith", + LastName = "Smith", + FirstName = "Jane", + Email = "jane.smith@example.com", + Sexe = "F", + Length = 165.0, + Weight = 60.0f, + Password = "password123", + DateOfBirth = new DateOnly(1995, 5, 10), + IsCoach = false + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(athlete); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedAthlete = context.Athletes.First(a => a.Username == "jane_smith"); + savedAthlete.Username = "jane_doe"; + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var updatedAthlete = context.Athletes.First(a => a.Username == "jane_doe"); + Assert.NotNull(updatedAthlete); + Assert.Equal("jane_doe", updatedAthlete.Username); + Assert.Equal("Smith", updatedAthlete.LastName); + }*/ + } + + [Fact] + public void Delete_Athlete_Success() + { + var athlete = new AthleteEntity + { + Username = "test_user", + LastName = "Test", + FirstName = "User", + Email = "test.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "testpassword", + DateOfBirth = new DateOnly(1985, 10, 20), + IsCoach = false + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(athlete); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedAthlete = context.Athletes.First(a => a.Username == "test_user"); + context.Athletes.Remove(savedAthlete); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var deletedAthlete = context.Athletes.FirstOrDefault(a => a.Username == "test_user"); + Assert.Null(deletedAthlete); + }*/ + } +} + diff --git a/src/Tests/UnitTestsEntities/DataSourceEntityTests.cs b/src/Tests/UnitTestsEntities/DataSourceEntityTests.cs new file mode 100644 index 0000000..6f4c1db --- /dev/null +++ b/src/Tests/UnitTestsEntities/DataSourceEntityTests.cs @@ -0,0 +1,102 @@ +namespace UnitTestsEntities; +using Xunit; +using System.Linq; +using Entities; +using Microsoft.EntityFrameworkCore; + + +public class DataSourceEntityTests +{ + [Fact] + public void Add_DataSource_Success() + { + var dataSource = new DataSourceEntity + { + Type = "GPS", + Model = "Garmin Forerunner 945", + Precision = 0.1f + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.DataSources.Add(dataSource); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedDataSource = context.DataSources.First(d => d.Type == "GPS"); + Assert.NotNull(savedDataSource); + Assert.Equal("Garmin Forerunner 945", savedDataSource.Model); + }*/ + } + + [Fact] + public void Update_DataSource_Success() + { + var dataSource = new DataSourceEntity + { + Type = "Heart Rate Monitor", + Model = "Polar H10", + Precision = 0.2f + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.DataSources.Add(dataSource); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedDataSource = context.DataSources.First(d => d.Type == "Heart Rate Monitor"); + savedDataSource.Model = "Polar H9"; + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var updatedDataSource = context.DataSources.First(d => d.Model == "Polar H9"); + Assert.NotNull(updatedDataSource); + Assert.Equal("Heart Rate Monitor", updatedDataSource.Type); + Assert.Equal(0.2f, updatedDataSource.Precision); + }*/ + } + + [Fact] + public void Delete_DataSource_Success() + { + var dataSource = new DataSourceEntity + { + Type = "Smartwatch", + Model = "Apple Watch Series 6", + Precision = 0.05f + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.DataSources.Add(dataSource); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedDataSource = context.DataSources.First(d => d.Type == "Smartwatch"); + context.DataSources.Remove(savedDataSource); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var deletedDataSource = context.DataSources.FirstOrDefault(d => d.Type == "Smartwatch"); + Assert.Null(deletedDataSource); + }*/ + } +} + diff --git a/src/Tests/UnitTestsEntities/FriendshipEntityTests.cs b/src/Tests/UnitTestsEntities/FriendshipEntityTests.cs new file mode 100644 index 0000000..492506c --- /dev/null +++ b/src/Tests/UnitTestsEntities/FriendshipEntityTests.cs @@ -0,0 +1,206 @@ +namespace UnitTestsEntities; +using Xunit; +using System.Linq; +using Entities; +using Microsoft.EntityFrameworkCore; + +public class FriendshipEntityTests +{ + [Fact] + public void Add_Friendship_Success() + { + var follower = new AthleteEntity + { + Username = "follower_user", + LastName = "Follower", + FirstName = "User", + Email = "follower.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "followerpassword", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + var following = new AthleteEntity + { + Username = "following_user", + LastName = "Following", + FirstName = "User", + Email = "following.user@example.com", + Sexe = "F", + Length = 165.0, + Weight = 60.0f, + Password = "followingpassword", + DateOfBirth = new DateOnly(1995, 5, 10), + IsCoach = false + }; + + var friendship = new FriendshipEntity + { + Follower = follower, + Following = following, + StartDate = DateTime.Now + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(follower); + context.Athletes.Add(following); + context.Friendships.Add(friendship); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedFriendship = context.Friendships.FirstOrDefault(); + Assert.NotNull(savedFriendship); + Assert.Equal(follower.IdAthlete, savedFriendship.FollowerId); + Assert.Equal(following.IdAthlete, savedFriendship.FollowingId); + }*/ + } + + [Fact] + public void Update_Friendship_Success() + { + var follower = new AthleteEntity + { + Username = "follower_user", + LastName = "Follower", + FirstName = "User", + Email = "follower.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "followerpassword", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + var following = new AthleteEntity + { + Username = "following_user", + LastName = "Following", + FirstName = "User", + Email = "following.user@example.com", + Sexe = "F", + Length = 165.0, + Weight = 60.0f, + Password = "followingpassword", + DateOfBirth = new DateOnly(1995, 5, 10), + IsCoach = false + }; + + var thirdAthlete = new AthleteEntity + { + Username = "third_user", + LastName = "Third", + FirstName = "User", + Email = "third.user@example.com", + Sexe = "M", + Length = 180.0, + Weight = 75.0f, + Password = "thirdpassword", + DateOfBirth = new DateOnly(1988, 3, 15), + IsCoach = false + }; + + var friendship = new FriendshipEntity + { + Follower = follower, + Following = following, + StartDate = DateTime.Now + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(follower); + context.Athletes.Add(following); + context.Athletes.Add(thirdAthlete); + context.Friendships.Add(friendship); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedFriendship = context.Friendships.FirstOrDefault(); + savedFriendship.Follower = thirdAthlete; // Update the follower + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var updatedFriendship = context.Friendships.FirstOrDefault(); + Assert.NotNull(updatedFriendship); + Assert.Equal(thirdAthlete.IdAthlete, updatedFriendship.FollowerId); + }*/ + } + + [Fact] + public void Delete_Friendship_Success() + { + var follower = new AthleteEntity + { + Username = "follower_user", + LastName = "Follower", + FirstName = "User", + Email = "follower.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "followerpassword", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + var following = new AthleteEntity + { + Username = "following_user", + LastName = "Following", + FirstName = "User", + Email = "following.user@example.com", + Sexe = "F", + Length = 165.0, + Weight = 60.0f, + Password = "followingpassword", + DateOfBirth = new DateOnly(1995, 5, 10), + IsCoach = false + }; + + var friendship = new FriendshipEntity + { + Follower = follower, + Following = following, + StartDate = DateTime.Now + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(follower); + context.Athletes.Add(following); + context.Friendships.Add(friendship); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedFriendship = context.Friendships.FirstOrDefault(); + context.Friendships.Remove(savedFriendship); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var deletedFriendship = context.Friendships.FirstOrDefault(); + Assert.Null(deletedFriendship); + }*/ + } +} + diff --git a/src/Tests/UnitTestsEntities/HeartRateEntityTests.cs b/src/Tests/UnitTestsEntities/HeartRateEntityTests.cs new file mode 100644 index 0000000..c3bc36f --- /dev/null +++ b/src/Tests/UnitTestsEntities/HeartRateEntityTests.cs @@ -0,0 +1,172 @@ +namespace UnitTestsEntities; +using Xunit; +using System.Linq; +using Entities; +using Microsoft.EntityFrameworkCore; + +public class HeartRateEntityTests +{ + [Fact] + public void Add_HeartRate_Success() + { + var activity = new ActivityEntity + { + Type = "Running", + Date = new DateOnly(2024, 3, 15), + StartTime = new TimeOnly(9, 0), + EndTime = new TimeOnly(10, 0), + EffortFelt = 7, + Variability = 0.5f, + Variance = 0.2f, + StandardDeviation = 0.3f, + Average = 0.4f, + Maximum = 200, + Minimum = 100, + AverageTemperature = 25.5f, + HasAutoPause = true, + DataSourceId = 1, + AthleteId = 1 + }; + + var heartRateEntry = new HeartRateEntity + { + Altitude = 100.0, + Time = new TimeOnly(9, 30), + Temperature = 20.0f, + Bpm = 150, + Longitude = 45.12345f, + Latitude = 35.6789f, + Activity = activity + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Activities.Add(activity); + context.HeartRates.Add(heartRateEntry); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedHeartRate = context.HeartRates.First(); + Assert.NotNull(savedHeartRate); + Assert.Equal(150, savedHeartRate.Bpm); + }*/ + } + + [Fact] + public void Update_HeartRate_Success() + { + var activity = new ActivityEntity + { + Type = "Running", + Date = new DateOnly(2024, 3, 15), + StartTime = new TimeOnly(9, 0), + EndTime = new TimeOnly(10, 0), + EffortFelt = 7, + Variability = 0.5f, + Variance = 0.2f, + StandardDeviation = 0.3f, + Average = 0.4f, + Maximum = 200, + Minimum = 100, + AverageTemperature = 25.5f, + HasAutoPause = true, + DataSourceId = 1, + AthleteId = 1 + }; + + var heartRateEntry = new HeartRateEntity + { + Altitude = 100.0, + Time = new TimeOnly(9, 30), + Temperature = 20.0f, + Bpm = 150, + Longitude = 45.12345f, + Latitude = 35.6789f, + Activity = activity + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Activities.Add(activity); + context.HeartRates.Add(heartRateEntry); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedHeartRate = context.HeartRates.First(); + savedHeartRate.Bpm = 160; + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var updatedHeartRate = context.HeartRates.First(); + Assert.NotNull(updatedHeartRate); + Assert.Equal(160, updatedHeartRate.Bpm); + }*/ + } + + [Fact] + public void Delete_HeartRate_Success() + { + var activity = new ActivityEntity + { + Type = "Running", + Date = new DateOnly(2024, 3, 15), + StartTime = new TimeOnly(9, 0), + EndTime = new TimeOnly(10, 0), + EffortFelt = 7, + Variability = 0.5f, + Variance = 0.2f, + StandardDeviation = 0.3f, + Average = 0.4f, + Maximum = 200, + Minimum = 100, + AverageTemperature = 25.5f, + HasAutoPause = true, + DataSourceId = 1, + AthleteId = 1 + }; + + var heartRateEntry = new HeartRateEntity + { + Altitude = 100.0, + Time = new TimeOnly(9, 30), + Temperature = 20.0f, + Bpm = 150, + Longitude = 45.12345f, + Latitude = 35.6789f, + Activity = activity + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Activities.Add(activity); + context.HeartRates.Add(heartRateEntry); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedHeartRate = context.HeartRates.First(); + context.HeartRates.Remove(savedHeartRate); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var deletedHeartRate = context.HeartRates.FirstOrDefault(); + Assert.Null(deletedHeartRate); + }*/ + } +} + diff --git a/src/Tests/UnitTestsEntities/NotificationEntityTests.cs b/src/Tests/UnitTestsEntities/NotificationEntityTests.cs new file mode 100644 index 0000000..6d656a4 --- /dev/null +++ b/src/Tests/UnitTestsEntities/NotificationEntityTests.cs @@ -0,0 +1,151 @@ +namespace UnitTestsEntities; +using Xunit; +using System.Linq; +using Entities; +using Microsoft.EntityFrameworkCore; + +public class NotificationEntityTests +{ + [Fact] + public void Add_Notification_Success() + { + var sender = new AthleteEntity + { + Username = "sender_user", + LastName = "Sender", + FirstName = "User", + Email = "sender.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "senderpassword", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + var notification = new NotificationEntity + { + Message = "Test notification", + Date = DateTime.Now, + Statut = false, + Urgence = "High", + Sender = sender + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(sender); + context.Notifications.Add(notification); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedNotification = context.Notifications.First(); + Assert.NotNull(savedNotification); + Assert.Equal("Test notification", savedNotification.Message); + }*/ + } + + [Fact] + public void Update_Notification_Success() + { + var sender = new AthleteEntity + { + Username = "sender_user", + LastName = "Sender", + FirstName = "User", + Email = "sender.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "senderpassword", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + var notification = new NotificationEntity + { + Message = "Test notification", + Date = DateTime.Now, + Statut = false, + Urgence = "High", + Sender = sender + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(sender); + context.Notifications.Add(notification); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedNotification = context.Notifications.First(); + savedNotification.Message = "Updated message"; + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var updatedNotification = context.Notifications.First(); + Assert.NotNull(updatedNotification); + Assert.Equal("Updated message", updatedNotification.Message); + }*/ + } + + [Fact] + public void Delete_Notification_Success() + { + var sender = new AthleteEntity + { + Username = "sender_user", + LastName = "Sender", + FirstName = "User", + Email = "sender.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "senderpassword", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + var notification = new NotificationEntity + { + Message = "Test notification", + Date = DateTime.Now, + Statut = false, + Urgence = "High", + Sender = sender + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(sender); + context.Notifications.Add(notification); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedNotification = context.Notifications.First(); + context.Notifications.Remove(savedNotification); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var deletedNotification = context.Notifications.FirstOrDefault(); + Assert.Null(deletedNotification); + }*/ + } +} + diff --git a/src/Tests/UnitTestsEntities/StatisticEntityTests.cs b/src/Tests/UnitTestsEntities/StatisticEntityTests.cs new file mode 100644 index 0000000..c91b2ab --- /dev/null +++ b/src/Tests/UnitTestsEntities/StatisticEntityTests.cs @@ -0,0 +1,155 @@ +namespace UnitTestsEntities; +using Xunit; +using System.Linq; +using Entities; +using Microsoft.EntityFrameworkCore; + + +public class StatisticEntityTests +{ + [Fact] + public void Add_Statistic_Success() + { + var athlete = new AthleteEntity + { + Username = "athlete_user", + LastName = "Athlete", + FirstName = "User", + Email = "athlete.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "athletepassword", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + var statistic = new StatisticEntity + { + Weight = 75.0f, + AverageHeartRate = 150.0, + MaximumHeartRate = 180.0, + AverageCaloriesBurned = 500.0, + Date = new DateOnly(2024, 3, 15), + Athlete = athlete + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(athlete); + context.Statistics.Add(statistic); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedStatistic = context.Statistics.First(); + Assert.NotNull(savedStatistic); + Assert.Equal(75.0f, savedStatistic.Weight); + }*/ + } + + [Fact] + public void Update_Statistic_Success() + { + var athlete = new AthleteEntity + { + Username = "athlete_user", + LastName = "Athlete", + FirstName = "User", + Email = "athlete.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "athletepassword", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + var statistic = new StatisticEntity + { + Weight = 75.0f, + AverageHeartRate = 150.0, + MaximumHeartRate = 180.0, + AverageCaloriesBurned = 500.0, + Date = new DateOnly(2024, 3, 15), + Athlete = athlete + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(athlete); + context.Statistics.Add(statistic); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedStatistic = context.Statistics.First(); + savedStatistic.Weight = 80.0f; + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var updatedStatistic = context.Statistics.First(); + Assert.NotNull(updatedStatistic); + Assert.Equal(80.0f, updatedStatistic.Weight); + }*/ + } + + [Fact] + public void Delete_Statistic_Success() + { + var athlete = new AthleteEntity + { + Username = "athlete_user", + LastName = "Athlete", + FirstName = "User", + Email = "athlete.user@example.com", + Sexe = "M", + Length = 170.0, + Weight = 70.0f, + Password = "athletepassword", + DateOfBirth = new DateOnly(1990, 1, 1), + IsCoach = false + }; + + var statistic = new StatisticEntity + { + Weight = 75.0f, + AverageHeartRate = 150.0, + MaximumHeartRate = 180.0, + AverageCaloriesBurned = 500.0, + Date = new DateOnly(2024, 3, 15), + Athlete = athlete + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(athlete); + context.Statistics.Add(statistic); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedStatistic = context.Statistics.First(); + context.Statistics.Remove(savedStatistic); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var deletedStatistic = context.Statistics.FirstOrDefault(); + Assert.Null(deletedStatistic); + }*/ + } +} + diff --git a/src/Tests/UnitTestsEntities/TrainingEntityTests.cs b/src/Tests/UnitTestsEntities/TrainingEntityTests.cs new file mode 100644 index 0000000..84ec46e --- /dev/null +++ b/src/Tests/UnitTestsEntities/TrainingEntityTests.cs @@ -0,0 +1,202 @@ +namespace UnitTestsEntities; +using Xunit; +using System.Linq; +using Entities; +using Microsoft.EntityFrameworkCore; + + +public class TrainingEntityTests +{ + [Fact] + public void Add_Training_Success() + { + var coach = new AthleteEntity + { + Username = "coach_user", + LastName = "Coach", + FirstName = "User", + Email = "coach.user@example.com", + Sexe = "M", + Length = 180.0, + Weight = 75.0f, + Password = "coachpassword", + DateOfBirth = new DateOnly(1985, 5, 15), + IsCoach = true + }; + + var athlete = new AthleteEntity + { + Username = "athlete_user", + LastName = "Athlete", + FirstName = "User", + Email = "athlete.user@example.com", + Sexe = "F", + Length = 165.0, + Weight = 60.0f, + Password = "athletepassword", + DateOfBirth = new DateOnly(1990, 3, 20), + IsCoach = false + }; + + var training = new TrainingEntity + { + Date = new DateOnly(2024, 3, 15), + Description = "Training description", + Latitude = 40.12345f, + Longitude = -74.56789f, + FeedBack = "Training feedback", + Coach = coach, + Athletes = { athlete } + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(coach); + context.Athletes.Add(athlete); + context.Trainings.Add(training); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedTraining = context.Trainings.First(); + Assert.NotNull(savedTraining); + Assert.Equal("Training description", savedTraining.Description); + }*/ + } + + [Fact] + public void Update_Training_Success() + { + var coach = new AthleteEntity + { + Username = "coach_user", + LastName = "Coach", + FirstName = "User", + Email = "coach.user@example.com", + Sexe = "M", + Length = 180.0, + Weight = 75.0f, + Password = "coachpassword", + DateOfBirth = new DateOnly(1985, 5, 15), + IsCoach = true + }; + + var athlete = new AthleteEntity + { + Username = "athlete_user", + LastName = "Athlete", + FirstName = "User", + Email = "athlete.user@example.com", + Sexe = "F", + Length = 165.0, + Weight = 60.0f, + Password = "athletepassword", + DateOfBirth = new DateOnly(1990, 3, 20), + IsCoach = false + }; + + var training = new TrainingEntity + { + Date = new DateOnly(2024, 3, 15), + Description = "Training description", + Latitude = 40.12345f, + Longitude = -74.56789f, + FeedBack = "Training feedback", + Coach = coach, + Athletes = { athlete } + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(coach); + context.Athletes.Add(athlete); + context.Trainings.Add(training); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedTraining = context.Trainings.First(); + savedTraining.Description = "Updated training description"; + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var updatedTraining = context.Trainings.First(); + Assert.NotNull(updatedTraining); + Assert.Equal("Updated training description", updatedTraining.Description); + }*/ + } + + [Fact] + public void Delete_Training_Success() + { + var coach = new AthleteEntity + { + Username = "coach_user", + LastName = "Coach", + FirstName = "User", + Email = "coach.user@example.com", + Sexe = "M", + Length = 180.0, + Weight = 75.0f, + Password = "coachpassword", + DateOfBirth = new DateOnly(1985, 5, 15), + IsCoach = true + }; + + var athlete = new AthleteEntity + { + Username = "athlete_user", + LastName = "Athlete", + FirstName = "User", + Email = "athlete.user@example.com", + Sexe = "F", + Length = 165.0, + Weight = 60.0f, + Password = "athletepassword", + DateOfBirth = new DateOnly(1990, 3, 20), + IsCoach = false + }; + + var training = new TrainingEntity + { + Date = new DateOnly(2024, 3, 15), + Description = "Training description", + Latitude = 40.12345f, + Longitude = -74.56789f, + FeedBack = "Training feedback", + Coach = coach, + Athletes = { athlete } + }; + + /* + using (var context = new StubbedContext(options)) + { + context.Database.EnsureCreated(); + context.Athletes.Add(coach); + context.Athletes.Add(athlete); + context.Trainings.Add(training); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var savedTraining = context.Trainings.First(); + context.Trainings.Remove(savedTraining); + context.SaveChanges(); + } + + using (var context = new StubbedContext(options)) + { + var deletedTraining = context.Trainings.FirstOrDefault(); + Assert.Null(deletedTraining); + }*/ + } +}