Simple Database + Endpoints
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -75,3 +75,6 @@ yarn-error.log*
|
||||
|
||||
# JetBrains IDEs
|
||||
.idea/
|
||||
|
||||
# Claude Code
|
||||
.claude
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@@ -7,11 +7,29 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Models\Ingoing\Altersgruppen\AltersGruppeIngoing\**" />
|
||||
<Compile Remove="Services\Interfaces\**" />
|
||||
<Content Remove="Models\Ingoing\Altersgruppen\AltersGruppeIngoing\**" />
|
||||
<Content Remove="Services\Interfaces\**" />
|
||||
<EmbeddedResource Remove="Models\Ingoing\Altersgruppen\AltersGruppeIngoing\**" />
|
||||
<EmbeddedResource Remove="Services\Interfaces\**" />
|
||||
<None Remove="Models\Ingoing\Altersgruppen\AltersGruppeIngoing\**" />
|
||||
<None Remove="Services\Interfaces\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.11" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\" />
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
32
API/API.csproj.Backup (1).tmp
Normal file
32
API/API.csproj.Backup (1).tmp
Normal file
@@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Services\Interfaces\**" />
|
||||
<Content Remove="Services\Interfaces\**" />
|
||||
<EmbeddedResource Remove="Services\Interfaces\**" />
|
||||
<None Remove="Services\Interfaces\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.11" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\Ingoing\Altersgruppen\" />
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
25
API/API.csproj.Backup.tmp
Normal file
25
API/API.csproj.Backup.tmp
Normal file
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.11" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\Ingoing\" />
|
||||
<Folder Include="Services\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
73
API/Controllers/AgeGroupController.cs
Normal file
73
API/Controllers/AgeGroupController.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using API.Models.Ingoing.Altersgruppen;
|
||||
using API.Repository.AgeGroup;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/ageGroups/")]
|
||||
public class AgeGroupController : ControllerBase
|
||||
{
|
||||
private IAgeGroupService _ageGroupService;
|
||||
|
||||
public AgeGroupController(IAgeGroupService ageGroupService)
|
||||
{
|
||||
_ageGroupService = ageGroupService;
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public async Task<IActionResult> GetAll()
|
||||
{
|
||||
var allAgeGroups = await _ageGroupService.GetAllAsync();
|
||||
|
||||
return Ok(allAgeGroups);
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> GetOne([FromRoute] int id)
|
||||
{
|
||||
var group = await _ageGroupService.GetAsync(id);
|
||||
|
||||
if (group == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(group);
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public async Task<IActionResult> Create([FromBody] AltersGruppeIngoing groupDto)
|
||||
{
|
||||
var group = await _ageGroupService.CreateAsync(groupDto.ToInternalFromIngoing());
|
||||
|
||||
return CreatedAtAction(nameof(GetOne), new { Id = group.Id }, group);
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> Update([FromRoute] int id, [FromBody] AltersGruppeIngoing groupDto)
|
||||
{
|
||||
var group = await _ageGroupService.UpdateAsync(id, groupDto.ToInternalFromIngoing());
|
||||
|
||||
if(group == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Ok(group);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> Delete([FromRoute] int Id)
|
||||
{
|
||||
var group = await _ageGroupService.DeleteAsync(Id);
|
||||
|
||||
if (group == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
14
API/Database/ApplicationDbContext.cs
Normal file
14
API/Database/ApplicationDbContext.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using API.Models.Internal.Altersgruppen;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Database
|
||||
{
|
||||
public class ApplicationDbContext : DbContext
|
||||
{
|
||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<AltersGruppe> Altersgruppen { get; set; }
|
||||
}
|
||||
}
|
||||
47
API/Migrations/20251206113128_InitialCreate.Designer.cs
generated
Normal file
47
API/Migrations/20251206113128_InitialCreate.Designer.cs
generated
Normal file
@@ -0,0 +1,47 @@
|
||||
// <auto-generated />
|
||||
using API.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20251206113128_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.11");
|
||||
|
||||
modelBuilder.Entity("API.Models.Internal.Altersgruppen.Altergruppe", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("EndingAge")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("StartingAge")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Altersgruppen");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
36
API/Migrations/20251206113128_InitialCreate.cs
Normal file
36
API/Migrations/20251206113128_InitialCreate.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Altersgruppen",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Name = table.Column<string>(type: "TEXT", nullable: false),
|
||||
StartingAge = table.Column<string>(type: "TEXT", nullable: false),
|
||||
EndingAge = table.Column<string>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Altersgruppen", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Altersgruppen");
|
||||
}
|
||||
}
|
||||
}
|
||||
45
API/Migrations/20251206220303_ChangeAgeFieldsToInt.Designer.cs
generated
Normal file
45
API/Migrations/20251206220303_ChangeAgeFieldsToInt.Designer.cs
generated
Normal file
@@ -0,0 +1,45 @@
|
||||
// <auto-generated />
|
||||
using API.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20251206220303_ChangeAgeFieldsToInt")]
|
||||
partial class ChangeAgeFieldsToInt
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.11");
|
||||
|
||||
modelBuilder.Entity("API.Models.Internal.Altersgruppen.AltersGruppe", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("EndingAge")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("StartingAge")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Altersgruppen");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
50
API/Migrations/20251206220303_ChangeAgeFieldsToInt.cs
Normal file
50
API/Migrations/20251206220303_ChangeAgeFieldsToInt.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ChangeAgeFieldsToInt : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "StartingAge",
|
||||
table: "Altersgruppen",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
|
||||
migrationBuilder.AlterColumn<int>(
|
||||
name: "EndingAge",
|
||||
table: "Altersgruppen",
|
||||
type: "INTEGER",
|
||||
nullable: false,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "TEXT");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "StartingAge",
|
||||
table: "Altersgruppen",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "EndingAge",
|
||||
table: "Altersgruppen",
|
||||
type: "TEXT",
|
||||
nullable: false,
|
||||
oldClrType: typeof(int),
|
||||
oldType: "INTEGER");
|
||||
}
|
||||
}
|
||||
}
|
||||
42
API/Migrations/ApplicationDbContextModelSnapshot.cs
Normal file
42
API/Migrations/ApplicationDbContextModelSnapshot.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
// <auto-generated />
|
||||
using API.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace API.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "9.0.11");
|
||||
|
||||
modelBuilder.Entity("API.Models.Internal.Altersgruppen.AltersGruppe", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("EndingAge")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("StartingAge")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Altersgruppen");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
28
API/Models/Ingoing/Altersgruppen/AltersGruppeIngoing.cs
Normal file
28
API/Models/Ingoing/Altersgruppen/AltersGruppeIngoing.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using API.Models.Internal.Altersgruppen;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace API.Models.Ingoing.Altersgruppen
|
||||
{
|
||||
public class AltersGruppeIngoing
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public int StartingAge { get; set; }
|
||||
[Required]
|
||||
public int EndingAge { get; set; }
|
||||
}
|
||||
|
||||
public static class AltersgruppeMapper
|
||||
{
|
||||
public static AltersGruppe ToInternalFromIngoing(this AltersGruppeIngoing group)
|
||||
{
|
||||
return new AltersGruppe
|
||||
{
|
||||
Name = group.Name,
|
||||
StartingAge = group.StartingAge,
|
||||
EndingAge = group.EndingAge,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
12
API/Models/Internal/Altersgruppen/AltersGruppe.cs
Normal file
12
API/Models/Internal/Altersgruppen/AltersGruppe.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace API.Models.Internal.Altersgruppen
|
||||
{
|
||||
public class AltersGruppe
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int StartingAge { get; set; }
|
||||
public int EndingAge { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,29 @@
|
||||
using API.Database;
|
||||
using API.Repository.AgeGroup;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
// Database
|
||||
var postgreConnection = builder.Configuration.GetConnectionString("PostgresConnection");
|
||||
if (!string.IsNullOrEmpty(postgreConnection))
|
||||
{
|
||||
// Nutze PostgresSQL
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(postgreConnection));
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlite("Data Source=app.db"));
|
||||
}
|
||||
|
||||
|
||||
builder.Services.AddScoped<IAgeGroupService, AgeGroupService>();
|
||||
|
||||
// Add Database Services
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
@@ -16,6 +33,12 @@ if (app.Environment.IsDevelopment())
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
using(var scope = app.Services.CreateScope())
|
||||
{
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||
dbContext.Database.Migrate();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
68
API/Repository/AgeGroup/AgeGroupService.cs
Normal file
68
API/Repository/AgeGroup/AgeGroupService.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using API.Database;
|
||||
using API.Models.Internal.Altersgruppen;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Repository.AgeGroup
|
||||
{
|
||||
public class AgeGroupService : IAgeGroupService
|
||||
{
|
||||
private ApplicationDbContext _context;
|
||||
|
||||
public AgeGroupService(ApplicationDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<AltersGruppe> CreateAsync(AltersGruppe altersGruppe)
|
||||
{
|
||||
await _context.Altersgruppen.AddAsync(altersGruppe);
|
||||
await _context.SaveChangesAsync();
|
||||
return altersGruppe;
|
||||
}
|
||||
|
||||
public async Task<AltersGruppe?> DeleteAsync(int id)
|
||||
{
|
||||
var group = await _context.Altersgruppen.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (group == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_context.Altersgruppen.Remove(group);
|
||||
_context.SaveChanges();
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
public async Task<List<AltersGruppe>> GetAllAsync()
|
||||
{
|
||||
var allGroups = await _context.Altersgruppen.ToListAsync();
|
||||
|
||||
return allGroups;
|
||||
}
|
||||
|
||||
public async Task<AltersGruppe?> GetAsync(int id)
|
||||
{
|
||||
return await _context.Altersgruppen.FindAsync(id);
|
||||
}
|
||||
|
||||
public async Task<AltersGruppe?> UpdateAsync(int id, AltersGruppe altersGruppe)
|
||||
{
|
||||
var existingGroup = await _context.Altersgruppen.FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
if (existingGroup == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
existingGroup.Name = altersGruppe.Name;
|
||||
existingGroup.StartingAge = altersGruppe.StartingAge;
|
||||
existingGroup.EndingAge = altersGruppe.EndingAge;
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return existingGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
14
API/Repository/AgeGroup/IAgeGroupService.cs
Normal file
14
API/Repository/AgeGroup/IAgeGroupService.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using API.Models.Internal.Altersgruppen;
|
||||
|
||||
namespace API.Repository.AgeGroup
|
||||
{
|
||||
public interface IAgeGroupService
|
||||
{
|
||||
public Task<List<AltersGruppe>> GetAllAsync();
|
||||
|
||||
public Task<AltersGruppe?> GetAsync(int id);
|
||||
public Task<AltersGruppe> CreateAsync(AltersGruppe altersGruppe);
|
||||
public Task<AltersGruppe?> DeleteAsync(int id);
|
||||
public Task<AltersGruppe?> UpdateAsync(int id, AltersGruppe altersGruppe);
|
||||
}
|
||||
}
|
||||
BIN
API/app.db-shm
Normal file
BIN
API/app.db-shm
Normal file
Binary file not shown.
BIN
API/app.db-wal
Normal file
BIN
API/app.db-wal
Normal file
Binary file not shown.
43
GUI/src/components/ResponsiveTabsOrList.vue
Normal file
43
GUI/src/components/ResponsiveTabsOrList.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useDisplay } from 'vuetify';
|
||||
|
||||
export interface TabItem {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
defineProps<{
|
||||
items: TabItem[];
|
||||
tabColor?: string;
|
||||
}>();
|
||||
|
||||
const display = useDisplay();
|
||||
const tab = ref('1');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Desktop: Tabs mit einzelner Anzeige -->
|
||||
<template v-if="!display.mobile.value">
|
||||
<v-tabs :color="tabColor ?? '#b62b2b'" v-model="tab">
|
||||
<v-tab v-for="item in items" :key="item.value" :value="item.value">
|
||||
{{ item.label }}
|
||||
</v-tab>
|
||||
</v-tabs>
|
||||
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-tabs-window v-model="tab">
|
||||
<v-tabs-window-item v-for="item in items" :key="item.value" :value="item.value">
|
||||
<slot :name="item.value"></slot>
|
||||
</v-tabs-window-item>
|
||||
</v-tabs-window>
|
||||
</template>
|
||||
|
||||
<!-- Mobile: Alle Einträge untereinander -->
|
||||
<template v-else>
|
||||
<template v-for="item in items" :key="item.value">
|
||||
<slot :name="item.value"></slot>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
@@ -2,9 +2,13 @@
|
||||
import CarouselItemWithTitle from '@/components/CarouselItemWithTitle.vue';
|
||||
import HomeEntrie from '@/components/HomeEntrie.vue';
|
||||
import HomeEntrieWithImagePreset from '@/components/HomeEntrieWithImagePreset.vue';
|
||||
import { ref } from 'vue';
|
||||
import ResponsiveTabsOrList from '@/components/ResponsiveTabsOrList.vue';
|
||||
|
||||
const tab = ref("1");
|
||||
const tabItems = [
|
||||
{ value: '1', label: 'Nikolausturnier' },
|
||||
{ value: '2', label: 'Wettkämpfe' },
|
||||
{ value: '3', label: 'Kinoabende' },
|
||||
];
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -90,16 +94,9 @@ const tab = ref("1");
|
||||
</home-entrie>
|
||||
|
||||
<home-entrie title="Und sonst so?"></home-entrie>
|
||||
<v-tabs color="#b62b2b" v-model="tab" :show-arrows="$vuetify.display.mobile">
|
||||
<v-tab value="1">Nikolausturnier</v-tab>
|
||||
<v-tab value="2">Wettkämpfe</v-tab>
|
||||
<v-tab value="3">Kinoabende</v-tab>
|
||||
</v-tabs>
|
||||
|
||||
<v-divider></v-divider>
|
||||
|
||||
<v-tabs-window v-model="tab">
|
||||
<v-tabs-window-item value="1">
|
||||
<responsive-tabs-or-list :items="tabItems">
|
||||
<template #1>
|
||||
<home-entrie-with-image-preset
|
||||
title="Nikolausturnier"
|
||||
image="/static/images/nikolausturnier/total.png"
|
||||
@@ -110,8 +107,9 @@ const tab = ref("1");
|
||||
gemeinsam Spaß zu haben.
|
||||
</template>
|
||||
</home-entrie-with-image-preset>
|
||||
</v-tabs-window-item>
|
||||
<v-tabs-window-item value="2">
|
||||
</template>
|
||||
|
||||
<template #2>
|
||||
<home-entrie-with-image-preset
|
||||
title="Wettkämpfe"
|
||||
image="/static/images/wettkampf/total.jpg"
|
||||
@@ -122,8 +120,9 @@ const tab = ref("1");
|
||||
nationalen Meisterschaften.
|
||||
</template>
|
||||
</home-entrie-with-image-preset>
|
||||
</v-tabs-window-item>
|
||||
<v-tabs-window-item value="3">
|
||||
</template>
|
||||
|
||||
<template #3>
|
||||
<home-entrie-with-image-preset
|
||||
title="Kinoabende"
|
||||
image="/static/images/kinoabend/total.jpg"
|
||||
@@ -134,8 +133,8 @@ const tab = ref("1");
|
||||
entspannen, Snacks teilen und über Filme und Sport plaudern.
|
||||
</template>
|
||||
</home-entrie-with-image-preset>
|
||||
</v-tabs-window-item>
|
||||
</v-tabs-window>
|
||||
</template>
|
||||
</responsive-tabs-or-list>
|
||||
</v-container>
|
||||
</main>
|
||||
</v-container>
|
||||
|
||||
Reference in New Issue
Block a user