parent
e8fe1426dc
commit
2f9975cc2a
@ -0,0 +1,25 @@
|
|||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/.idea
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
@ -0,0 +1,22 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<InvariantGlobalization>true</InvariantGlobalization>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0"/>
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="..\.dockerignore">
|
||||||
|
<Link>.dockerignore</Link>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,6 @@
|
|||||||
|
@API_HostAddress = http://localhost:5254
|
||||||
|
|
||||||
|
GET {{API_HostAddress}}/weatherforecast/
|
||||||
|
Accept: application/json
|
||||||
|
|
||||||
|
###
|
@ -0,0 +1,23 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||||
|
USER $APP_UID
|
||||||
|
WORKDIR /app
|
||||||
|
EXPOSE 8080
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["API/API.csproj", "API/"]
|
||||||
|
RUN dotnet restore "API/API.csproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/API"
|
||||||
|
RUN dotnet build "API.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
ARG BUILD_CONFIGURATION=Release
|
||||||
|
RUN dotnet publish "API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
|
FROM base AS final
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["dotnet", "API.dll"]
|
@ -0,0 +1,21 @@
|
|||||||
|
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();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.MapControllers();
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
app.Run();
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
namespace AppContext.Entities;
|
||||||
|
|
||||||
|
public class MemberEntity
|
||||||
|
{
|
||||||
|
public int TeamId { get; set; }
|
||||||
|
public TeamEntity? Team { get; set; }
|
||||||
|
|
||||||
|
public required int UserId { get; set; }
|
||||||
|
public UserEntity? User { get; set; }
|
||||||
|
|
||||||
|
public required string Role { get; set; }
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using Model;
|
||||||
|
|
||||||
|
namespace AppContext.Entities;
|
||||||
|
|
||||||
|
public class TacticEntity
|
||||||
|
{
|
||||||
|
public int Id { get; init; }
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public required DateTime CreationDate { get; set; }
|
||||||
|
|
||||||
|
public required int OwnerId { get; set; }
|
||||||
|
public UserEntity? Owner { get; set; }
|
||||||
|
|
||||||
|
public CourtType Type { get; set; }
|
||||||
|
public required string JsonContent { get; set; }
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
namespace AppContext.Entities;
|
||||||
|
|
||||||
|
public class TeamEntity
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public required string Name { get; init; }
|
||||||
|
public required string Picture { get; set; }
|
||||||
|
public required string MainColor { get; set; }
|
||||||
|
public required string SecondColor { get; set; }
|
||||||
|
|
||||||
|
public ICollection<MemberEntity> Members { get; set; } = new List<MemberEntity>();
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace AppContext.Entities;
|
||||||
|
|
||||||
|
public class UserEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public required string Name { get; set; }
|
||||||
|
public required string Email { get; set; }
|
||||||
|
public required string ProfilePicture { get; set; }
|
||||||
|
|
||||||
|
public ICollection<TacticEntity> Tactics { get; set; } = new List<TacticEntity>();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace Model;
|
||||||
|
|
||||||
|
public enum CourtType
|
||||||
|
{
|
||||||
|
Plain,
|
||||||
|
Half
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
using AppContext.Entities;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace StubContext;
|
||||||
|
|
||||||
|
using AppContext;
|
||||||
|
|
||||||
|
public class StubAppContext(DbContextOptions<AppContext> options) : AppContext(options)
|
||||||
|
{
|
||||||
|
public StubAppContext() : this(
|
||||||
|
new DbContextOptionsBuilder<AppContext>()
|
||||||
|
.UseSqlite("Data Source=database.db")
|
||||||
|
.Options
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(builder);
|
||||||
|
|
||||||
|
var users = new[] { "maxime", "mael", "yanis", "simon", "vivien" }.ToList();
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
|
builder.Entity<UserEntity>()
|
||||||
|
.HasData(users.ConvertAll(name => new UserEntity
|
||||||
|
{
|
||||||
|
Id = ++i,
|
||||||
|
Email = $"{name}@mail.com",
|
||||||
|
Name = name,
|
||||||
|
ProfilePicture =
|
||||||
|
"https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png",
|
||||||
|
}));
|
||||||
|
|
||||||
|
builder.Entity<MemberEntity>()
|
||||||
|
.HasKey("TeamId", "UserId");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue