@using Koogle.Application.DTOs
@using Koogle.Domain.Enums
@if (IsInverseMode)
{
Inverse Strafe hinzufügen
}
else
{
Strafe hinzufügen
}
@foreach (var expense in AvailableExpenses.OrderBy(e => e.Name))
{
@expense.Name
@if (expense.IsInverse)
{
}
@if (expense.IsVariable)
{
}
@expense.Price.ToString("C")
}
@if (_selectedExpense?.IsInverse == true)
{
Inverse Strafe: Die Strafe wird allen Teilnehmern außer der ausgewählten Person zugewiesen.
}
@foreach (var participant in Participants.OrderBy(p => p.PersonName))
{
@participant.PersonName[0]
@participant.PersonName
@if (participant.PersonStatus == PersonStatus.Guest)
{
Gast
}
}
@if (_selectedExpense?.IsVariable == true)
{
}
else if (_selectedExpense is not null)
{
Preis: @_selectedExpense.Price.ToString("C")
}
Abbrechen
Hinzufügen
@code {
[CascadingParameter]
private IMudDialogInstance? MudDialog { get; set; }
[Parameter]
public IReadOnlyList AvailableExpenses { get; set; } = [];
[Parameter]
public IReadOnlyList Participants { get; set; } = [];
[Parameter]
public Guid DayId { get; set; }
private MudForm? _form;
private bool _isValid;
private ExpenseDto? _selectedExpense;
private DayParticipantDto? _selectedParticipant;
private decimal _customPrice;
private bool IsInverseMode => _selectedExpense?.IsInverse == true;
protected override void OnParametersSet()
{
base.OnParametersSet();
if (_selectedExpense is not null)
{
_customPrice = _selectedExpense.Price;
}
}
private void Cancel() => MudDialog?.Cancel();
private void Submit()
{
if (_selectedExpense is null || _selectedParticipant is null) return;
if (_selectedExpense.IsInverse)
{
var dto = new CreateInversePersonExpenseDto
{
ExcludedPersonId = _selectedParticipant.PersonId,
ExpenseId = _selectedExpense.Id,
DayId = DayId,
GameId = null
};
MudDialog?.Close(DialogResult.Ok(dto));
}
else
{
var dto = new CreatePersonExpenseDto
{
PersonId = _selectedParticipant.PersonId,
ExpenseId = _selectedExpense.Id,
DayId = DayId,
GameId = null,
Price = _selectedExpense.IsVariable ? _customPrice : null
};
MudDialog?.Close(DialogResult.Ok(dto));
}
}
}