@page "/raidedit"
@page "/raidedit/{raidId}"
@using Lieb.Data
@using Lieb.Models.GuildWars2.Raid
@using System.ComponentModel.DataAnnotations
@inject RaidService RaidService
@inject NavigationManager NavigationManager
@inject IJSRuntime JsRuntime
CreateRaid
@{
bool _isEdit = _raid.RaidId != 0;
}
@if(_raid.RaidType == RaidType.Planned)
{
Spots |
Role name |
Description |
@foreach( PlannedRaidRole role in _raid.Roles)
{
bool disableEdit = _raid.SignUps.Where(s => s.PlannedRaidRoleId == role.PlannedRaidRoleId).Any();
|
|
|
@if(!disableEdit)
{
|
}
}
}
@code {
[Parameter]
public string raidId { get; set; }
public Raid _raid;
protected override async Task OnInitializedAsync()
{
if(!string.IsNullOrEmpty(raidId) && int.TryParse(raidId, out int parsedId))
{
_raid = RaidService.GetRaid(parsedId);
}
else
{
_raid = new Raid();
}
}
async Task AddRoleClicked()
{
_raid.Roles.Add(new PlannedRaidRole());
}
async Task DeleteRoleClicked(PlannedRaidRole role)
{
_raid.Roles.Remove(role);
}
async Task DeleteRaidClicked()
{
bool confirmed = await JsRuntime.InvokeAsync("confirm", "Are you sure you want to delete the raid?");
if (confirmed)
{
await RaidService.DeleteRaid(_raid.RaidId);
NavigationManager.NavigateTo("raidoverview");
}
}
private async Task HandleValidSubmit()
{
if(_raid.RaidType != RaidType.Planned && _raid.Roles.Count == 0)
{
_raid.Roles.Add(new PlannedRaidRole()
{
Spots = 10,
Name = "Random",
Description = _raid.RaidType.ToString()
});
}
await RaidService.AddOrEditRaid(_raid);
NavigationManager.NavigateTo("raidoverview");
}
}