feat: scaffold backend and shared library
This commit is contained in:
9
src/ASTRAIN.Shared/ASTRAIN.Shared.csproj
Normal file
9
src/ASTRAIN.Shared/ASTRAIN.Shared.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
139
src/ASTRAIN.Shared/Class1.cs
Normal file
139
src/ASTRAIN.Shared/Class1.cs
Normal file
@@ -0,0 +1,139 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace ASTRAIN.Shared;
|
||||
|
||||
public class User
|
||||
{
|
||||
[Key]
|
||||
[MaxLength(8)]
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public List<Exercise> Exercises { get; set; } = new();
|
||||
public List<Routine> Routines { get; set; } = new();
|
||||
}
|
||||
|
||||
public class Exercise
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(120)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(8)]
|
||||
public string UserId { get; set; } = string.Empty;
|
||||
|
||||
public User? User { get; set; }
|
||||
|
||||
public List<RoutineExercise> RoutineExercises { get; set; } = new();
|
||||
}
|
||||
|
||||
public class Routine
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(120)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(8)]
|
||||
public string UserId { get; set; } = string.Empty;
|
||||
|
||||
public User? User { get; set; }
|
||||
|
||||
public List<RoutineExercise> Exercises { get; set; } = new();
|
||||
public List<RoutineRun> Runs { get; set; } = new();
|
||||
}
|
||||
|
||||
public class RoutineExercise
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int RoutineId { get; set; }
|
||||
|
||||
public Routine? Routine { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ExerciseId { get; set; }
|
||||
|
||||
public Exercise? Exercise { get; set; }
|
||||
|
||||
public int Order { get; set; }
|
||||
}
|
||||
|
||||
public class RoutineRun
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int RoutineId { get; set; }
|
||||
|
||||
public Routine? Routine { get; set; }
|
||||
|
||||
[Required]
|
||||
[MaxLength(8)]
|
||||
public string UserId { get; set; } = string.Empty;
|
||||
|
||||
public DateTime PerformedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public List<RoutineRunEntry> Entries { get; set; } = new();
|
||||
}
|
||||
|
||||
public class RoutineRunEntry
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int RoutineRunId { get; set; }
|
||||
|
||||
public RoutineRun? RoutineRun { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ExerciseId { get; set; }
|
||||
|
||||
public Exercise? Exercise { get; set; }
|
||||
|
||||
public double Weight { get; set; }
|
||||
|
||||
public bool Completed { get; set; }
|
||||
}
|
||||
|
||||
public record EnsureUserResponse(string UserId);
|
||||
|
||||
public record ExerciseDto(int Id, string Name);
|
||||
|
||||
public record ExerciseUpsertRequest(string Name);
|
||||
|
||||
public record RoutineExerciseDto(int ExerciseId, string Name, int Order);
|
||||
|
||||
public record RoutineDto(int Id, string Name, List<RoutineExerciseDto> Exercises);
|
||||
|
||||
public record RoutineUpsertRequest(string Name, List<int> ExerciseIds);
|
||||
|
||||
public class RoutineRunEntryDto
|
||||
{
|
||||
public int ExerciseId { get; set; }
|
||||
public double Weight { get; set; }
|
||||
public bool Completed { get; set; }
|
||||
|
||||
public RoutineRunEntryDto()
|
||||
{
|
||||
}
|
||||
|
||||
public RoutineRunEntryDto(int exerciseId, double weight, bool completed)
|
||||
{
|
||||
ExerciseId = exerciseId;
|
||||
Weight = weight;
|
||||
Completed = completed;
|
||||
}
|
||||
}
|
||||
|
||||
public record RoutineRunRequest(List<RoutineRunEntryDto> Entries);
|
||||
|
||||
public record RoutineRunSummaryDto(DateTime PerformedAt, List<RoutineRunEntryDto> Entries);
|
||||
Reference in New Issue
Block a user