diff --git a/OptifitWebServices.sln b/OptifitWebServices.sln index e0fc7d6..9888887 100644 --- a/OptifitWebServices.sln +++ b/OptifitWebServices.sln @@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CatalogService", "src\Catal EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "src\Shared\Shared.csproj", "{BF49B348-4188-4AC7-9ED4-5837F4B3BCD2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrainingSvc", "src\TrainingSvc\TrainingSvc.csproj", "{F16873D3-6511-48AA-B74E-8B13D5F20F20}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,9 +28,14 @@ Global {BF49B348-4188-4AC7-9ED4-5837F4B3BCD2}.Debug|Any CPU.Build.0 = Debug|Any CPU {BF49B348-4188-4AC7-9ED4-5837F4B3BCD2}.Release|Any CPU.ActiveCfg = Release|Any CPU {BF49B348-4188-4AC7-9ED4-5837F4B3BCD2}.Release|Any CPU.Build.0 = Release|Any CPU + {F16873D3-6511-48AA-B74E-8B13D5F20F20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F16873D3-6511-48AA-B74E-8B13D5F20F20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F16873D3-6511-48AA-B74E-8B13D5F20F20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F16873D3-6511-48AA-B74E-8B13D5F20F20}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {54BE8DE8-08BD-429F-BCCA-3363A879D922} = {2A7200CA-F40B-4715-8726-4ED30C785FA4} {BF49B348-4188-4AC7-9ED4-5837F4B3BCD2} = {2A7200CA-F40B-4715-8726-4ED30C785FA4} + {F16873D3-6511-48AA-B74E-8B13D5F20F20} = {2A7200CA-F40B-4715-8726-4ED30C785FA4} EndGlobalSection EndGlobal diff --git a/src/Shared/Enum/EDifficulty.cs b/src/Shared/Enum/EDifficulty.cs new file mode 100644 index 0000000..c6b3ace --- /dev/null +++ b/src/Shared/Enum/EDifficulty.cs @@ -0,0 +1,10 @@ +namespace Shared.Enum; + +public enum EDifficulty +{ + None, + Beginner, + Intermediate, + Advanced, + Expert +} \ No newline at end of file diff --git a/src/Shared/Enum/EGoal.cs b/src/Shared/Enum/EGoal.cs new file mode 100644 index 0000000..64b558f --- /dev/null +++ b/src/Shared/Enum/EGoal.cs @@ -0,0 +1,10 @@ +namespace Shared.Enum; + +public enum EGoal +{ + None, + MuscleGain, + WeightLoss, + Endurance, + Strength, +} \ No newline at end of file diff --git a/src/TrainingSvc/Data/TrainingDbContext.cs b/src/TrainingSvc/Data/TrainingDbContext.cs new file mode 100644 index 0000000..82d9f9f --- /dev/null +++ b/src/TrainingSvc/Data/TrainingDbContext.cs @@ -0,0 +1,11 @@ +using Microsoft.EntityFrameworkCore; + +namespace TrainingSvc.Data; + +public class TrainingDbContext : DbContext +{ + public TrainingDbContext(DbContextOptions options) : base(options) + { + } + +} \ No newline at end of file diff --git a/src/TrainingSvc/Entities/ExerciceInstance.cs b/src/TrainingSvc/Entities/ExerciceInstance.cs new file mode 100644 index 0000000..e966b07 --- /dev/null +++ b/src/TrainingSvc/Entities/ExerciceInstance.cs @@ -0,0 +1,28 @@ +using System.ComponentModel.DataAnnotations; +using Shared.Entities; + +namespace TrainingSvc.Entities; + +public class ExerciceInstance : EntityBase +{ + public required string Name { get; set; } + + public string? ExerciceId { get; set; } + + public float Duration { get; set; } + + public int NbSets { get; set; } + + public int NbReps { get; set; } + + public float RestingTime { get; set; } + + public float? Weight { get; set; } + + public bool IsDone { get; set; } + + [Required] + public string SessionId { get; set; } + + public Session Session { get; set; } +} \ No newline at end of file diff --git a/src/TrainingSvc/Entities/Session.cs b/src/TrainingSvc/Entities/Session.cs new file mode 100644 index 0000000..5c6806a --- /dev/null +++ b/src/TrainingSvc/Entities/Session.cs @@ -0,0 +1,24 @@ +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using Shared.Entities; +using Shared.Enum; + +namespace TrainingSvc.Entities; + +public class Session : EntityBase +{ + public required string Name { get; set; } + + public string? Description { get; set; } + + [Range(1, 7)] + public int Day { get; set; } + + public ETarget? Target { get; set; } + + [Required] + public string TrainingProgramId { get; set; } + public TrainingProgram TrainingProgram { get; set; } + + public virtual ICollection Exercices { get; set; } = new Collection(); +} \ No newline at end of file diff --git a/src/TrainingSvc/Entities/TrainingProgram.cs b/src/TrainingSvc/Entities/TrainingProgram.cs new file mode 100644 index 0000000..c48c1ed --- /dev/null +++ b/src/TrainingSvc/Entities/TrainingProgram.cs @@ -0,0 +1,26 @@ +using System.Collections.ObjectModel; +using Shared.Entities; +using Shared.Enum; + +namespace TrainingSvc.Entities; + +public class TrainingProgram : EntityBase +{ + public string Lang { get; set; } = "en"; + + public required string Name { get; set; } + + public string? Description { get; set; } + + public int WeekDuration { get; set; } = 4; + + public int NbDays { get; set; } = 3; + + public string OwnerId { get; set; } = ""; + + public EGoal Goal { get; set; } = EGoal.MuscleGain; + + public EDifficulty Difficulty { get; set; } = EDifficulty.Beginner; + + public virtual ICollection Sessions { get; set; } = new Collection(); +} \ No newline at end of file diff --git a/src/TrainingSvc/Program.cs b/src/TrainingSvc/Program.cs new file mode 100644 index 0000000..4cb66c9 --- /dev/null +++ b/src/TrainingSvc/Program.cs @@ -0,0 +1,33 @@ +using TrainingSvc.Data; +using Microsoft.EntityFrameworkCore; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddControllers(); +builder.Services.AddDbContext(opt => +{ + opt.UseNpgsql(builder.Configuration.GetConnectionString("TrainingDb")); + +}); +builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); + + +var app = builder.Build(); + +app.UseAuthorization(); + +app.MapControllers(); + +try +{ + //NOT IMPLEMENTED + app.MapGet("/", () => "Hello World!"); + //DbInitializer.InitDb(app); +} +catch (Exception e) +{ + Console.WriteLine(e); +} + +app.Run(); \ No newline at end of file diff --git a/src/TrainingSvc/Properties/launchSettings.json b/src/TrainingSvc/Properties/launchSettings.json new file mode 100644 index 0000000..a913d38 --- /dev/null +++ b/src/TrainingSvc/Properties/launchSettings.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:7002", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} + diff --git a/src/TrainingSvc/TrainingSvc.csproj b/src/TrainingSvc/TrainingSvc.csproj new file mode 100644 index 0000000..9e84a87 --- /dev/null +++ b/src/TrainingSvc/TrainingSvc.csproj @@ -0,0 +1,22 @@ + + + + net8.0 + enable + enable + true + + + + + + + + + + + + + + + diff --git a/src/TrainingSvc/TrainingSvc.http b/src/TrainingSvc/TrainingSvc.http new file mode 100644 index 0000000..033abd4 --- /dev/null +++ b/src/TrainingSvc/TrainingSvc.http @@ -0,0 +1,6 @@ +@TrainingSvc_HostAddress = http://localhost:5269 + +GET {{TrainingSvc_HostAddress}}/weatherforecast/ +Accept: application/json + +###