Skip to content

Commit

Permalink
rsd
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Decker authored and Christoph Decker committed Oct 27, 2024
1 parent 1f57e23 commit 2312d14
Show file tree
Hide file tree
Showing 17 changed files with 590 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/chdTour.App/Components/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</ImageContent>
<MenuContent>
<NavItem href="" Match="NavLinkMatch.All" IconFAClass="house" Title="Home" />
<NavItem href="tour" Match="NavLinkMatch.All" IconFAClass="book" Title="Touren" />
<NavItem href="person" Match="NavLinkMatch.All" IconFAClass="people" Title="@PageTitleConstants.Persons" />
<NavItem href="tourtype" Match="NavLinkMatch.All" IconFAClass="table-list" Title="@PageTitleConstants.TourTypes" />
<NavItem href="scala" Match="NavLinkMatch.All" IconFAClass="ruler" Title="@PageTitleConstants.Skala" />
Expand Down
2 changes: 1 addition & 1 deletion src/chdTour.App/Components/Pages/PersonPage.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected override async Task OnInitializedAsync()
{
this.Title = PageTitleConstants.Persons;

this._items = await this._repository.Where(x => true).ToListAsync(this._cts.Token);
this._items = await this._repository.Where(x => true).AsSplitQuery().ToListAsync(this._cts.Token);

await base.OnInitializedAsync();
}
Expand Down
13 changes: 3 additions & 10 deletions src/chdTour.App/Components/Pages/Scala/GradeEditForm.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@

<EditFormLayout TRepo="IGradeRepository" T="Grade" @ref="this._layout" Value="this.Value">
<EditFormText TRepo="IGradeRepository" T="Grade" Title="Titel" Property="x => x.Title" Value="this.Value" />
@if (this.Value.GradeScala is not null && (this._scalaLst?.Any() ?? false))
{
<EditFormSearch TRepo="IGradeRepository" T="Grade" TValue="GradeScala" TFavoriteObject="Guid"
Name="x => x?.Title" Property="x => x.GradeScala" Title="Skala" Value="this.Value" Values="this._scalaLst"
OnChange="this.Changed" />
}
else
{
<EditFormLabel Title="Skala" T="GradeScala" TRepo="IGradeScalaRepository" Value="this.Value.GradeScala" Property="x => x.Title" />
}
<EditFormSearch TRepo="IGradeRepository" T="Grade" TValue="GradeScala" TFavoriteObject="Guid"
Name="x => x?.Title" Property="x => x.GradeScala" Title="Skala" Value="this.Value" Values="this._scalaLst"
OnChange="this.Changed" />
</EditFormLayout>


Expand Down
30 changes: 30 additions & 0 deletions src/chdTour.App/Components/Pages/TourPage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@page "/tour"
@using chdTour.App.Components.Base
@using chdTour.App.Components.Pages.Scala
@using chdTour.App.Components.Pages.Tours
@using chdTour.DataAccess.Contracts.Domain

@inherits BaseSearchForm<ITourRepository, Tour>

<EntityTable EntityName="Touren" T="Tour"
TRepo="ITourRepository" Item="this._item" Items="this._items" OnEdit="async x => await this.SetEntity(x)">
<ChildContent>
<TourEdit Token="this._cts.Token" OnBack="this.OnBack" Value="this._item" />
</ChildContent>
<HeaderContent>
<TableHead>Title</TableHead>
<TableHead>Ort</TableHead>
<TableHead>Datum</TableHead>
<TableHead>Type</TableHead>
<TableHead>Grad</TableHead>
<TableHead>Partner</TableHead>
</HeaderContent>
<RowTemplate Context="entity">
<TableData>@entity.Title</TableData>
<TableData>@entity.Location</TableData>
<TableData>@entity.TourDate.ToString("dd.MM.yyyy")</TableData>
<TableData>@entity.TourType.Title</TableData>
<TableData>@entity.Grade.Title</TableData>
<TableData>@(string.Join(",",entity.TourPartners.SelectMany(s => s.PersonObj.FullName)))</TableData>
</RowTemplate>
</EntityTable>
23 changes: 23 additions & 0 deletions src/chdTour.App/Components/Pages/TourPage.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using chd.UI.Base.Components.Base;
using chdTour.App.Components.Base;
using chdTour.Contracts.Constants;
using chdTour.DataAccess.Contracts.Domain;
using chdTour.DataAccess.Contracts.Interfaces.Repositories;
using Microsoft.AspNetCore.Components;
using Microsoft.EntityFrameworkCore;

namespace chdTour.App.Components.Pages
{
public partial class TourPage : BaseSearchForm<ITourRepository, Tour>
{
protected override async Task OnInitializedAsync()
{
this.Title = PageTitleConstants.Tours;

this._items = await this._repository.Where(x => true).AsSplitQuery().ToListAsync(this._cts.Token);

await base.OnInitializedAsync();
}

}
}
13 changes: 3 additions & 10 deletions src/chdTour.App/Components/Pages/TourTypes/TourTypeEdit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,9 @@

<EditFormLayout TRepo="ITourTypeRepository" T="TourType" @ref="this._layout" Value="this.Value" OnBack="this.OnBack">
<EditFormText TRepo="ITourTypeRepository" T="TourType" Value="this.Value" Property="x => x.Title" Title="Titel" />
@if (this.Value.GradeScala is null && (this._scalaLst?.Any() ?? false))
{
<EditFormSearch TRepo="ITourTypeRepository" T="TourType" TValue="GradeScala" TFavoriteObject="Guid"
Name="x => x?.Title" Property="x => x.GradeScala" Title="Skala" Value="this.Value" Values="this._scalaLst"
OnChange="this.Changed" />
}
else
{
<EditFormLabel Title="Skala" T="GradeScala" TRepo="IGradeScalaRepository" Value="this.Value.GradeScala" Property="x => x.Title" />
}
<EditFormSearch TRepo="ITourTypeRepository" T="TourType" TValue="GradeScala" TFavoriteObject="Guid"
Name="x => x?.Title" Property="x => x.GradeScala" Title="Skala" Value="this.Value" Values="this._scalaLst"
OnChange="this.Changed" />
</EditFormLayout>


Expand Down
75 changes: 75 additions & 0 deletions src/chdTour.App/Components/Pages/Tours/TourEdit.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@using Microsoft.EntityFrameworkCore
@using chdTour.App.Components.Base
@using chdTour.App.Components.Inputs
@using chdTour.DataAccess.Contracts.Domain
@inject ITourTypeRepository tourTypeRepo
@inject ITourPartnerRepository tourPartnerRepo
@inherits BaseEditForm<ITourRepository,Tour>

<EditFormLayout TRepo="ITourRepository" T="Tour" @ref="this._layout" Value="this.Value" OnBack="this.OnBack">
<EditFormText TRepo="ITourRepository" T="Tour" Value="this.Value" Property="x => x.Title" Title="Titel" />
<EditFormText TRepo="ITourRepository" T="Tour" Value="this.Value" Property="x => x.Location" Title="Ort/Gebiet" />
<EditFormDateTime TRepo="ITourRepository" TValue="DateTime" T="Tour" Value="this.Value" Property="x => x.TourDate" Title="Datum" />
<EditFormNumber TValue="int" TRepo="ITourRepository" T="Tour" Value="this.Value" Property="x => x.Pitches" Title="SL" />

<EditFormSearch TRepo="ITourRepository" T="Tour" TValue="TourType" TFavoriteObject="Guid"
Name="x => x?.Title" Property="x => x.TourType" Title="Typ" Value="this.Value" Values="this._tourTypeLst"
OnChange="this.Changed" />

<EditFormSearch TRepo="ITourRepository" T="Tour" TValue="Grade" TFavoriteObject="Guid"
Name="x => x?.Title" Property="x => x.Grade" Title="Grad" Value="this.Value" Values="_grades"
OnChange="this.Changed" />

<EditMultiAssignment Title="Partner" TRepo="ITourPartnerRepository" TParentRepo="ITourRepository" T="TourPartner" Token="this.Token"
TParent="Tour"
TForm="TourPartnerEdit"
OneAssignedProperty="x => x.TourObj"
OnChange="this.Changed"
ParentEntity="this.Value" CollectionProperty="x => x.TourPartners">
<HeaderContent>
<TableHead>Name</TableHead>
</HeaderContent>
<RowTemplate Context="tourPartner">
<TableData>@tourPartner.PersonObj.FullName</TableData>
</RowTemplate>
</EditMultiAssignment>

<EditFormTextArea TRepo="ITourRepository" T="Tour" Value="this.Value" Property="x => x.Comment" Title="Details" />
<EditFormTextArea TRepo="ITourRepository" T="Tour" Value="this.Value" Property="x => x.Description" Title="weiete Beschreibung" />
</EditFormLayout>



@code {
List<TourType> _tourTypeLst;
List<Grade> _grades = [];

protected async override Task OnInitializedAsync()
{
this._tourTypeLst = (await this.tourTypeRepo.FindAll(this.Token)).ToList();
if (this.Value.TourType?.GradeScala is not null)
{
this._grades = this.Value.TourType.GradeScala.Grades.ToList();
}
await base.OnInitializedAsync();
}

private void Changed(TourType type)
{
this.Value.TourTypeId = type.Id;
if (this.Value.TourType?.GradeScala is not null)
{
this._grades = this.Value.TourType.GradeScala.Grades.ToList();
}
}
private void Changed(Grade grade)
{
this.Value.GradeId = grade.Id;
}

private async Task Changed(TourPartner tourPartner, EntityState state)
{
tourPartner.TourId = this.Value.Id;
}

}
55 changes: 55 additions & 0 deletions src/chdTour.App/Components/Pages/Tours/TourPartnerEdit.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@using chdTour.App.Components.Base
@using chdTour.App.Components.Inputs
@using chdTour.DataAccess.Contracts.Domain
@inject IPersonRepository personRepo
@inject ITourRepository tourRepo
@inherits BaseEditForm<ITourPartnerRepository,TourPartner>

<EditFormLayout TRepo="ITourPartnerRepository" T="TourPartner" @ref="this._layout" Value="this.Value">
@if (this.Value.TourObj is null)
{
<EditFormSearch TRepo="ITourPartnerRepository" T="TourPartner" TValue="Tour" TFavoriteObject="Guid"
Name="x =>x.Title" Property="x => x.TourObj" Title="Tour" Value="this.Value" Values="this._tourLst"
OnChange="this.Changed" />
}
else
{
<EditFormLabel TRepo="ITourPartnerRepository" T="TourPartner" Title="Tour" Value="this.Value" Property="x => x.TourObj.Title" />
}

@if (this.Value.PersonObj is null)
{
<EditFormSearch TRepo="ITourPartnerRepository" T="TourPartner" TValue="Person" TFavoriteObject="Guid"
Name="x =>x.FullName" Property="x => x.PersonObj" Title="Partner" Value="this.Value" Values="this._personLst"
OnChange="this.Changed" />
}
else
{
<EditFormLabel TRepo="ITourPartnerRepository" T="TourPartner" Title="Partner" Value="this.Value" Property=" x => x.PersonObj.FullName" />
}

</EditFormLayout>


@code {
List<Person> _personLst;
List<Tour> _tourLst;

protected async override Task OnInitializedAsync()
{
this._personLst = (await this.personRepo.FindAll(this.Token)).ToList();
this._tourLst = (await this.tourRepo.FindAll(this.Token)).ToList();

await base.OnInitializedAsync();
}

private void Changed(Person person)
{
this.Value.PartnerId = person.Id;
}

private void Changed(Tour tour)
{
this.Value.TourId = tour.Id;
}
}
1 change: 1 addition & 0 deletions src/chdTour.BL/Extensions/DIExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static IServiceCollection AddchdTourBL(this IServiceCollection services,
services.AddScoped<ITourTypeRepository, TourTypeRepository>();
services.AddScoped<IGradeRepository, GradeRepository>();
services.AddScoped<IGradeScalaRepository, GradeScalaRepository>();
services.AddScoped<ITourPartnerRepository, TourPartnerRepository>();

return services;
}
Expand Down
2 changes: 2 additions & 0 deletions src/chdTour.DataAccess.Contracts/Domain/Person.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace chdTour.DataAccess.Contracts.Domain
{
public class Person : BaseEntity<Guid>
{
public string FullName => $"{this.FirstName} {this.LastName}";

public string LastName { get; set; }
public string FirstName { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/chdTour.DataAccess.Contracts/Domain/TourPartner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace chdTour.DataAccess.Contracts.Domain
{
public class TourPartner
public class TourPartner : BaseEntity<Guid>
{
public Guid TourId { get; set; }
public Guid PartnerId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

using chdTour.DataAccess.Contracts.Domain;
using chdTour.DataAccess.Contracts.Interfaces.Repositories.Base;
using System;
using System.Collections.Generic;
using System.Text;

namespace chdTour.DataAccess.Contracts.Interfaces.Repositories
{
public interface ITourPartnerRepository : IBaseRepository<TourPartner>
{
}
}
19 changes: 19 additions & 0 deletions src/chdTour.DataAccess/Repositories/TourPartnerRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using chdTour.DataAccess.Contracts.Domain;
using chdTour.DataAccess.Contracts.Interfaces.Repositories;
using chdTour.DataAccess.Repositories.Base;
using chdTour.Persistence.EF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace chdTour.DataAccess.Repositories
{
public class TourPartnerRepository : BaseRepository<TourPartner>, ITourPartnerRepository
{
public TourPartnerRepository(chdTourContext chdTourContext) : base(chdTourContext)
{
}
}
}
Loading

0 comments on commit 2312d14

Please sign in to comment.