parent
143ba29d60
commit
2c791baa06
@ -0,0 +1,10 @@
|
|||||||
|
namespace Shared.Enum;
|
||||||
|
|
||||||
|
public enum EDifficulty
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Beginner,
|
||||||
|
Intermediate,
|
||||||
|
Advanced,
|
||||||
|
Expert
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
namespace Shared.Enum;
|
||||||
|
|
||||||
|
public enum EGoal
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
MuscleGain,
|
||||||
|
WeightLoss,
|
||||||
|
Endurance,
|
||||||
|
Strength,
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace TrainingSvc.Data;
|
||||||
|
|
||||||
|
public class TrainingDbContext : DbContext
|
||||||
|
{
|
||||||
|
public TrainingDbContext(DbContextOptions options) : base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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; }
|
||||||
|
}
|
@ -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<ExerciceInstance> Exercices { get; set; } = new Collection<ExerciceInstance>();
|
||||||
|
}
|
@ -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<Session> Sessions { get; set; } = new Collection<Session>();
|
||||||
|
}
|
@ -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<TrainingDbContext>(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();
|
@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.15" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.11" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Shared\Shared.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,6 @@
|
|||||||
|
@TrainingSvc_HostAddress = http://localhost:5269
|
||||||
|
|
||||||
|
GET {{TrainingSvc_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
Loading…
Reference in new issue