add in progress to events, add league to vs event, bug fix

This commit is contained in:
Tomasi - Developing 2024-12-03 11:58:33 +01:00
parent 6c33a2725d
commit 4ac162e8dc
48 changed files with 4239 additions and 17 deletions

View File

@ -0,0 +1,35 @@
using Application.DataTransferObjects.VsDuelLeague;
using Application.Interfaces;
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace Api.Controllers.v1
{
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
[ApiVersion("1.0")]
[Authorize]
public class VsDuelLeaguesController(IVsDuelLeagueRepository vsDuelLeagueRepository, ILogger<VsDuelLeaguesController> logger) : ControllerBase
{
[HttpGet]
public async Task<ActionResult<List<VsDuelLeagueDto>>> GetVsDuelLeagues(CancellationToken cancellationToken)
{
try
{
var vsDuelLeaguesResult = await vsDuelLeagueRepository.GetVsDuelLeaguesAsync(cancellationToken);
if (vsDuelLeaguesResult.IsFailure) return BadRequest(vsDuelLeaguesResult.Error);
return vsDuelLeaguesResult.Value.Count > 0
? Ok(vsDuelLeaguesResult.Value)
: NoContent();
}
catch (Exception e)
{
logger.LogError(e, e.Message);
return StatusCode(StatusCodes.Status500InternalServerError);
}
}
}
}

View File

@ -30,6 +30,7 @@ public static class ApplicationDependencyInjection
services.AddScoped<IDesertStormParticipantRepository, DesertStormParticipantRepository>();
services.AddScoped<IZombieSiegeRepository, ZombieSiegeRepository>();
services.AddScoped<IZombieSiegeParticipantRepository, ZombieSiegeParticipantRepository>();
services.AddScoped<IVsDuelLeagueRepository, VsDuelLeagueRepository>();
services.AddTransient<IJwtService, JwtService>();

View File

@ -23,4 +23,6 @@ public class CreateCustomEventDto
[Required]
public required string EventDateString { get; set; }
public bool IsInProgress { get; set; }
}

View File

@ -22,4 +22,6 @@ public class CustomEventDto
public string? ModifiedBy { get; set; }
public bool IsInProgress { get; set; }
}

View File

@ -24,4 +24,7 @@ public class UpdateCustomEventDto
[Required]
public required string EventDateString { get; set; }
[Required]
public bool IsInProgress { get; set; }
}

View File

@ -22,4 +22,6 @@ public class CreateDesertStormDto
[Required]
[MaxLength(150)]
public required string OpponentName { get; set; }
public bool IsInProgress { get; set; }
}

View File

@ -23,4 +23,6 @@ public class DesertStormDto
public required string CreatedBy { get; set; }
public int Participants { get; set; }
public bool IsInProgress { get; set; }
}

View File

@ -20,4 +20,7 @@ public class UpdateDesertStormDto
[Required]
[MaxLength(150)]
public required string OpponentName { get; set; }
[Required]
public bool IsInProgress { get; set; }
}

View File

@ -7,6 +7,9 @@ public class CreateVsDuelDto
[Required]
public Guid AllianceId { get; set; }
[Required]
public Guid VsDuelLeagueId { get; set; }
[Required]
public required string EventDate { get; set; }
@ -26,4 +29,6 @@ public class CreateVsDuelDto
[Required]
public int OpponentSize { get; set; }
public bool IsInProgress { get; set; }
}

View File

@ -10,6 +10,9 @@ public class UpdateVsDuelDto
[Required]
public Guid AllianceId { get; set; }
[Required]
public Guid VsDuelLeagueId { get; set; }
[Required]
public required string EventDate { get; set; }
@ -28,4 +31,7 @@ public class UpdateVsDuelDto
[Required]
public int OpponentSize { get; set; }
[Required]
public bool IsInProgress { get; set; }
}

View File

@ -12,6 +12,10 @@ public class VsDuelDto
public required string CreatedBy { get; set; }
public Guid VsDuelLeagueId { get; set; }
public required string VsDuelLeague { get; set; }
public bool Won { get; set; }
public required string OpponentName { get; set; }
@ -26,4 +30,6 @@ public class VsDuelDto
public string? ModifiedBy { get; set; }
public bool IsInProgress { get; set; }
}

View File

@ -0,0 +1,10 @@
namespace Application.DataTransferObjects.VsDuelLeague;
public class VsDuelLeagueDto
{
public Guid Id { get; set; }
public required string Name { get; set; }
public int Code { get; set; }
}

View File

@ -0,0 +1,9 @@
using Application.Classes;
using Application.DataTransferObjects.VsDuelLeague;
namespace Application.Interfaces;
public interface IVsDuelLeagueRepository
{
Task<Result<List<VsDuelLeagueDto>>> GetVsDuelLeaguesAsync(CancellationToken cancellationToken);
}

View File

@ -0,0 +1,13 @@
using Application.DataTransferObjects.VsDuelLeague;
using AutoMapper;
using Database.Entities;
namespace Application.Profiles;
public class VsDuelLeagueProfile : Profile
{
public VsDuelLeagueProfile()
{
CreateMap<VsDuelLeague, VsDuelLeagueDto>();
}
}

View File

@ -8,9 +8,11 @@ public class VsDuelProfile : Profile
{
public VsDuelProfile()
{
CreateMap<VsDuel, VsDuelDto>();
CreateMap<VsDuel, VsDuelDto>()
.ForMember(des => des.VsDuelLeague, opt => opt.MapFrom(src => src.VsDuelLeague.Name));
CreateMap<VsDuel, VsDuelDetailDto>();
CreateMap<VsDuel, VsDuelDetailDto>()
.ForMember(des => des.VsDuelLeague, opt => opt.MapFrom(src => src.VsDuelLeague.Name));
CreateMap<UpdateVsDuelDto, VsDuel>()
.ForMember(des => des.ModifiedOn, opt => opt.MapFrom(src => DateTime.Now))

View File

@ -0,0 +1,23 @@
using Application.Classes;
using Application.DataTransferObjects.VsDuelLeague;
using Application.Interfaces;
using AutoMapper;
using AutoMapper.QueryableExtensions;
using Database;
using Microsoft.EntityFrameworkCore;
namespace Application.Repositories;
public class VsDuelLeagueRepository(ApplicationContext context, IMapper mapper) : IVsDuelLeagueRepository
{
public async Task<Result<List<VsDuelLeagueDto>>> GetVsDuelLeaguesAsync(CancellationToken cancellationToken)
{
var vsDuelLeagues = await context.VsDuelLeagues
.ProjectTo<VsDuelLeagueDto>(mapper.ConfigurationProvider)
.AsNoTracking()
.OrderBy(vsDuelLeague => vsDuelLeague.Code)
.ToListAsync(cancellationToken);
return Result.Success(vsDuelLeagues);
}
}

View File

@ -40,6 +40,8 @@ public class ApplicationContext(DbContextOptions<ApplicationContext> options) :
public DbSet<ZombieSiegeParticipant> ZombieSiegeParticipants { get; set; }
public DbSet<VsDuelLeague> VsDuelLeagues { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);

View File

@ -16,6 +16,7 @@ public class CustomEventConfiguration : IEntityTypeConfiguration<CustomEvent>
builder.Property(customEvent => customEvent.EventDate).IsRequired();
builder.Property(customEvent => customEvent.IsParticipationEvent).IsRequired();
builder.Property(customEvent => customEvent.IsPointsEvent).IsRequired();
builder.Property(customEvent => customEvent.IsInProgress).IsRequired();
builder.Property(customEvent => customEvent.CreatedBy).IsRequired().HasMaxLength(150);
builder.Property(customEvent => customEvent.ModifiedBy).IsRequired(false).HasMaxLength(150);
builder.Property(customEvent => customEvent.ModifiedOn).IsRequired(false);

View File

@ -14,6 +14,7 @@ public class DesertStormConfiguration : IEntityTypeConfiguration<DesertStorm>
builder.Property(desertStorm => desertStorm.EventDate).IsRequired();
builder.Property(desertStorm => desertStorm.OpponentServer).IsRequired();
builder.Property(desertStorm => desertStorm.Won).IsRequired();
builder.Property(desertStorm => desertStorm.IsInProgress).IsRequired();
builder.Property(desertStorm => desertStorm.OpposingParticipants).IsRequired();
builder.Property(desertStorm => desertStorm.CreatedBy).IsRequired().HasMaxLength(150);
builder.Property(desertStorm => desertStorm.OpponentName).IsRequired().HasMaxLength(150);

View File

@ -13,6 +13,7 @@ public class VsDuelConfiguration : IEntityTypeConfiguration<VsDuel>
builder.Property(vsDuel => vsDuel.EventDate).IsRequired();
builder.Property(vsDuel => vsDuel.Won).IsRequired();
builder.Property(vsDuel => vsDuel.IsInProgress).IsRequired();
builder.Property(vsDuel => vsDuel.OpponentName).IsRequired().HasMaxLength(150);
builder.Property(vsDuel => vsDuel.OpponentServer).IsRequired();
builder.Property(vsDuel => vsDuel.OpponentPower).IsRequired();
@ -25,5 +26,10 @@ public class VsDuelConfiguration : IEntityTypeConfiguration<VsDuel>
.WithMany(alliance => alliance.VsDuels)
.HasForeignKey(vsDuel => vsDuel.AllianceId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasOne(vsDuel => vsDuel.VsDuelLeague)
.WithMany(vsDuelLeague => vsDuelLeague.VsDuels)
.HasForeignKey(vsDuel => vsDuel.VsDuelLeagueId)
.OnDelete(DeleteBehavior.Cascade);
}
}

View File

@ -0,0 +1,41 @@
using Database.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Database.Configurations;
public class VsDuelLeagueConfiguration : IEntityTypeConfiguration<VsDuelLeague>
{
public void Configure(EntityTypeBuilder<VsDuelLeague> builder)
{
builder.HasKey(vsDuelLeague => vsDuelLeague.Id);
builder.Property(vsDuelLeague => vsDuelLeague.Id).ValueGeneratedNever();
builder.Property(vsDuelLeague => vsDuelLeague.Name).IsRequired().HasMaxLength(150);
builder.Property(vsDuelLeague => vsDuelLeague.Code).IsRequired();
var vsDuelLeagues = new List<VsDuelLeague>()
{
new()
{
Id = Guid.CreateVersion7(),
Name = "Silver League",
Code = 1
},
new()
{
Id = Guid.CreateVersion7(),
Name = "Gold League",
Code = 2
},
new()
{
Id = Guid.CreateVersion7(),
Name = "Diamond League",
Code = 3
}
};
builder.HasData(vsDuelLeagues);
}
}

View File

@ -14,6 +14,8 @@ public class CustomEvent : BaseEntity
public bool IsParticipationEvent { get; set; }
public bool IsInProgress { get; set; }
public DateTime EventDate { get; set; }
public required string CreatedBy { get; set; }

View File

@ -22,5 +22,7 @@ public class DesertStorm : BaseEntity
public int OpposingParticipants { get; set; }
public bool IsInProgress { get; set; }
public ICollection<DesertStormParticipant> DesertStormParticipants { get; set; } = [];
}

View File

@ -4,8 +4,12 @@ public class VsDuel : BaseEntity
{
public Guid AllianceId { get; set; }
public Guid? VsDuelLeagueId { get; set; }
public Alliance Alliance { get; set; } = null!;
public VsDuelLeague? VsDuelLeague { get; set; }
public DateTime EventDate { get; set; }
public required string CreatedBy { get; set; }
@ -24,5 +28,7 @@ public class VsDuel : BaseEntity
public int OpponentSize { get; set; }
public bool IsInProgress { get; set; }
public ICollection<VsDuelParticipant> VsDuelParticipants { get; set; } = [];
}

View File

@ -0,0 +1,10 @@
namespace Database.Entities;
public class VsDuelLeague : BaseEntity
{
public required string Name { get; set; }
public int Code { get; set; }
public ICollection<VsDuel> VsDuels { get; set; } = [];
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,87 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Database.Migrations
{
/// <inheritdoc />
public partial class AddVsDuelLeague : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "VsDuelLeagueId",
schema: "dbo",
table: "VsDuels",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.CreateTable(
name: "VsDuelLeagues",
schema: "dbo",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(150)", maxLength: 150, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_VsDuelLeagues", x => x.Id);
});
migrationBuilder.InsertData(
schema: "dbo",
table: "VsDuelLeagues",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ new Guid("01938b4d-6cb9-7813-a409-475c9338f970"), "Gold League" },
{ new Guid("01938b4d-6cb9-7c03-afef-5767a2132543"), "Diamond League" },
{ new Guid("01938b4d-6cb9-7e61-b46b-781659ca5694"), "Silver League" }
});
migrationBuilder.CreateIndex(
name: "IX_VsDuels_VsDuelLeagueId",
schema: "dbo",
table: "VsDuels",
column: "VsDuelLeagueId");
migrationBuilder.AddForeignKey(
name: "FK_VsDuels_VsDuelLeagues_VsDuelLeagueId",
schema: "dbo",
table: "VsDuels",
column: "VsDuelLeagueId",
principalSchema: "dbo",
principalTable: "VsDuelLeagues",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_VsDuels_VsDuelLeagues_VsDuelLeagueId",
schema: "dbo",
table: "VsDuels");
migrationBuilder.DropTable(
name: "VsDuelLeagues",
schema: "dbo");
migrationBuilder.DropIndex(
name: "IX_VsDuels_VsDuelLeagueId",
schema: "dbo",
table: "VsDuels");
migrationBuilder.DropColumn(
name: "VsDuelLeagueId",
schema: "dbo",
table: "VsDuels");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,118 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Database.Migrations
{
/// <inheritdoc />
public partial class addIsInProgressToEvents : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938b4d-6cb9-7813-a409-475c9338f970"));
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938b4d-6cb9-7c03-afef-5767a2132543"));
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938b4d-6cb9-7e61-b46b-781659ca5694"));
migrationBuilder.AddColumn<bool>(
name: "IsInProgress",
schema: "dbo",
table: "VsDuels",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsInProgress",
schema: "dbo",
table: "DesertStorms",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsInProgress",
schema: "dbo",
table: "CustomEvents",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.InsertData(
schema: "dbo",
table: "VsDuelLeagues",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ new Guid("01938b6c-dd30-7182-9fe6-9df201e0586d"), "Silver League" },
{ new Guid("01938b6c-dd30-7a97-9bfc-e4f49c245b7a"), "Gold League" },
{ new Guid("01938b6c-dd30-7b55-8254-12337beebc73"), "Diamond League" }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938b6c-dd30-7182-9fe6-9df201e0586d"));
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938b6c-dd30-7a97-9bfc-e4f49c245b7a"));
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938b6c-dd30-7b55-8254-12337beebc73"));
migrationBuilder.DropColumn(
name: "IsInProgress",
schema: "dbo",
table: "VsDuels");
migrationBuilder.DropColumn(
name: "IsInProgress",
schema: "dbo",
table: "DesertStorms");
migrationBuilder.DropColumn(
name: "IsInProgress",
schema: "dbo",
table: "CustomEvents");
migrationBuilder.InsertData(
schema: "dbo",
table: "VsDuelLeagues",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ new Guid("01938b4d-6cb9-7813-a409-475c9338f970"), "Gold League" },
{ new Guid("01938b4d-6cb9-7c03-afef-5767a2132543"), "Diamond League" },
{ new Guid("01938b4d-6cb9-7e61-b46b-781659ca5694"), "Silver League" }
});
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,92 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Database.Migrations
{
/// <inheritdoc />
public partial class AddCodeToVsDuelLeague : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938b6c-dd30-7182-9fe6-9df201e0586d"));
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938b6c-dd30-7a97-9bfc-e4f49c245b7a"));
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938b6c-dd30-7b55-8254-12337beebc73"));
migrationBuilder.AddColumn<int>(
name: "Code",
schema: "dbo",
table: "VsDuelLeagues",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.InsertData(
schema: "dbo",
table: "VsDuelLeagues",
columns: new[] { "Id", "Code", "Name" },
values: new object[,]
{
{ new Guid("01938bf2-cf1b-742f-b3d6-824dbed7bf25"), 1, "Silver League" },
{ new Guid("01938bf2-cf1b-7a69-8607-87b1987a19b0"), 2, "Gold League" },
{ new Guid("01938bf2-cf1b-7cde-961e-e8cb35890551"), 3, "Diamond League" }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938bf2-cf1b-742f-b3d6-824dbed7bf25"));
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938bf2-cf1b-7a69-8607-87b1987a19b0"));
migrationBuilder.DeleteData(
schema: "dbo",
table: "VsDuelLeagues",
keyColumn: "Id",
keyValue: new Guid("01938bf2-cf1b-7cde-961e-e8cb35890551"));
migrationBuilder.DropColumn(
name: "Code",
schema: "dbo",
table: "VsDuelLeagues");
migrationBuilder.InsertData(
schema: "dbo",
table: "VsDuelLeagues",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ new Guid("01938b6c-dd30-7182-9fe6-9df201e0586d"), "Silver League" },
{ new Guid("01938b6c-dd30-7a97-9bfc-e4f49c245b7a"), "Gold League" },
{ new Guid("01938b6c-dd30-7b55-8254-12337beebc73"), "Diamond League" }
});
}
}
}

View File

@ -112,6 +112,9 @@ namespace Database.Migrations
b.Property<DateTime>("EventDate")
.HasColumnType("datetime2");
b.Property<bool>("IsInProgress")
.HasColumnType("bit");
b.Property<bool>("IsParticipationEvent")
.HasColumnType("bit");
@ -179,6 +182,9 @@ namespace Database.Migrations
b.Property<DateTime>("EventDate")
.HasColumnType("datetime2");
b.Property<bool>("IsInProgress")
.HasColumnType("bit");
b.Property<string>("ModifiedBy")
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
@ -511,6 +517,9 @@ namespace Database.Migrations
b.Property<DateTime>("EventDate")
.HasColumnType("datetime2");
b.Property<bool>("IsInProgress")
.HasColumnType("bit");
b.Property<string>("ModifiedBy")
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
@ -532,6 +541,9 @@ namespace Database.Migrations
b.Property<int>("OpponentSize")
.HasColumnType("int");
b.Property<Guid?>("VsDuelLeagueId")
.HasColumnType("uniqueidentifier");
b.Property<bool>("Won")
.HasColumnType("bit");
@ -539,9 +551,49 @@ namespace Database.Migrations
b.HasIndex("AllianceId");
b.HasIndex("VsDuelLeagueId");
b.ToTable("VsDuels", "dbo");
});
modelBuilder.Entity("Database.Entities.VsDuelLeague", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<int>("Code")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.HasKey("Id");
b.ToTable("VsDuelLeagues", "dbo");
b.HasData(
new
{
Id = new Guid("01938bf2-cf1b-742f-b3d6-824dbed7bf25"),
Code = 1,
Name = "Silver League"
},
new
{
Id = new Guid("01938bf2-cf1b-7a69-8607-87b1987a19b0"),
Code = 2,
Name = "Gold League"
},
new
{
Id = new Guid("01938bf2-cf1b-7cde-961e-e8cb35890551"),
Code = 3,
Name = "Diamond League"
});
});
modelBuilder.Entity("Database.Entities.VsDuelParticipant", b =>
{
b.Property<Guid>("Id")
@ -931,7 +983,14 @@ namespace Database.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Database.Entities.VsDuelLeague", "VsDuelLeague")
.WithMany("VsDuels")
.HasForeignKey("VsDuelLeagueId")
.OnDelete(DeleteBehavior.Cascade);
b.Navigation("Alliance");
b.Navigation("VsDuelLeague");
});
modelBuilder.Entity("Database.Entities.VsDuelParticipant", b =>
@ -1093,6 +1152,11 @@ namespace Database.Migrations
b.Navigation("VsDuelParticipants");
});
modelBuilder.Entity("Database.Entities.VsDuelLeague", b =>
{
b.Navigation("VsDuels");
});
modelBuilder.Entity("Database.Entities.ZombieSiege", b =>
{
b.Navigation("ZombieSiegeParticipants");

View File

@ -66,10 +66,36 @@
</div>
}
</div>
<div class="form-floating mb-3 is-invalid">
<select [ngClass]="{
'is-invalid': f['vsDuelLeagueId'].invalid && (f['vsDuelLeagueId'].dirty || f['vsDuelLeagueId'].touched),
'is-valid': f['vsDuelLeagueId'].valid}" class="form-select" id="vsDuelLeagueId" formControlName="vsDuelLeagueId">
@for (vsDuelLeague of vsDuelLeagues; track vsDuelLeague.id) {
<option [ngValue]="vsDuelLeague.id">{{vsDuelLeague.name}}</option>
}
</select>
<label for="vsDuelLeagueId">Vs Duel League</label>
@if (f['vsDuelLeagueId'].invalid && (f['vsDuelLeagueId'].dirty || f['vsDuelLeagueId'].touched)) {
<div class="invalid-feedback">
@if (f['vsDuelLeagueId'].hasError('required')) {
<p>Vs Duel League is required</p>
}
</div>
}
</div>
@if (f['isInProgress'].value === false) {
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" formControlName="won" id="won">
<label class="form-check-label" for="won">
Won
</label>
</div>
}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" formControlName="won" id="won">
<label class="form-check-label" for="won">
Won
<input class="form-check-input" type="checkbox" formControlName="isInProgress" id="isInProgress">
<label class="form-check-label" for="isInProgress">
In Progress
</label>
</div>
</form>

View File

@ -4,6 +4,8 @@ import {FormControl, FormGroup, Validators} from "@angular/forms";
import {VsDuelModel} from "../../models/vsDuel.model";
import {VsDuelService} from "../../services/vs-duel.service";
import {ToastrService} from "ngx-toastr";
import {VsDuelLeagueService} from "../../services/vs-duel-league.service";
import {VsDuelLeagueModel} from "../../models/vsDuelLeague.model";
@Component({
selector: 'app-vs-duel-edit-modal',
@ -14,9 +16,11 @@ export class VsDuelCreateModalComponent implements OnInit {
private readonly _vsDuelService: VsDuelService = inject(VsDuelService);
private readonly _toastr: ToastrService = inject(ToastrService);
private readonly _vsDuelLeagueService: VsDuelLeagueService = inject(VsDuelLeagueService);
public activeModal: NgbActiveModal = inject(NgbActiveModal);
public vsDuelForm!: FormGroup;
public vsDuelLeagues: VsDuelLeagueModel[] = [];
@Input({required: true}) isUpdate!: boolean;
@Input({required: true}) vsDuelModel!: VsDuelModel;
@ -26,12 +30,16 @@ export class VsDuelCreateModalComponent implements OnInit {
}
ngOnInit() {
this.getVsDuelLeagues();
const d = new Date(this.vsDuelModel.eventDate);
this.vsDuelForm = new FormGroup({
id: new FormControl<string>(this.vsDuelModel.id),
vsDuelLeagueId: new FormControl<string>(this.vsDuelModel.vsDuelLeagueId, [Validators.required]),
allianceId: new FormControl<string>(this.vsDuelModel.allianceId),
eventDate: new FormControl<string>(new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())).toISOString().substring(0, 10)),
won: new FormControl<boolean>(this.vsDuelModel.won),
isInProgress: new FormControl<boolean>(this.vsDuelModel.isInProgress),
opponentName: new FormControl<string>(this.vsDuelModel.opponentName, [Validators.required]),
opponentServer: new FormControl<number>(this.vsDuelModel.opponentServer, [Validators.required]),
opponentPower: new FormControl<number>(this.vsDuelModel.opponentPower, [Validators.required]),
@ -39,6 +47,20 @@ export class VsDuelCreateModalComponent implements OnInit {
});
}
getVsDuelLeagues() {
this._vsDuelLeagueService.getVsDuelLeagues().subscribe({
next: ((response) => {
if (response) {
this.vsDuelLeagues = response;
}
}),
error: (error) => {
console.log(error);
this._toastr.error('Could not load vsDuelLeagues', 'Load VsDuelLeagues');
}
});
}
onSubmit() {
if (this.vsDuelForm.invalid) {
return;

View File

@ -8,6 +8,7 @@ export interface CustomEventModel {
isPointsEvent?: boolean;
isParticipationEvent?: boolean;
eventDate: Date;
isInProgress: boolean;
}
export interface CustomEventDetailModel extends CustomEventModel {

View File

@ -12,6 +12,7 @@ export interface DesertStormModel {
eventDate: Date;
opponentName: string;
participants: number;
isInProgress: boolean;
}
export interface DesertStormDetailModel extends DesertStormModel {
@ -25,4 +26,5 @@ export interface CreateDesertStormModel {
opponentServer: number;
eventDate: string;
opponentName: string;
isInProgress: boolean;
}

View File

@ -3,6 +3,8 @@ import {VsDuelParticipantModel} from "./vsDuelParticipant.model";
export interface VsDuelModel {
id: string;
allianceId: string;
vsDuelLeagueId: string;
vsDuelLeague: string;
eventDate: Date;
won: boolean;
opponentName: string;
@ -12,6 +14,7 @@ export interface VsDuelModel {
createdBy: string;
modifiedOn?: Date;
modifiedBy?: string;
isInProgress: boolean;
}
export interface VsDuelDetailModel extends VsDuelModel {

View File

@ -0,0 +1,4 @@
export interface VsDuelLeagueModel {
id: string;
name: string;
}

View File

@ -5,10 +5,14 @@
</div>
@if (desertStormDetail) {
<div class="card mt-5" [ngClass]="desertStormDetail.won ? 'border-success' : 'border-danger'">
<div class="card mt-5" [ngClass]="desertStormDetail.isInProgress ? '' : desertStormDetail.won ? 'border-success' : 'border-danger'">
<h5 class="card-header d-flex justify-content-between">
<div>Week {{desertStormDetail.eventDate | week}} / {{desertStormDetail.eventDate | date: 'yyyy'}}</div>
<div [ngClass]="desertStormDetail.won ? 'text-success' : 'text-danger'">{{desertStormDetail.won ? 'VICTORY' : 'DEFEAT'}}</div>
@if (desertStormDetail.isInProgress) {
<div><i class="bi bi-hourglass-split"></i> In Progress</div>
} @else {
<div [ngClass]="desertStormDetail.won ? 'text-success' : 'text-danger'">{{desertStormDetail.won ? 'VICTORY' : 'DEFEAT'}}</div>
}
</h5>
<div class="card-body">
<h5 class="card-title">Opponent: <span class="text-primary">{{desertStormDetail.opponentName}}</span></h5>
@ -37,7 +41,7 @@
@if (player.registered) {
<div class="col-12 col-md-6 mb-4">
<div class="d-flex flex-column align-items-center border p-3"
[ngClass]="player.participated ? 'border-success' : (player.startPlayer && !player.participated) ? 'border-danger' : 'border-warning'">
[ngClass]="desertStormDetail.isInProgress ? '' : player.participated ? 'border-success' : (player.startPlayer && !player.participated) ? 'border-danger' : 'border-warning'">
<h6 class="mb-4 text-color">{{player.playerName}}</h6>
<div class="d-flex flex-wrap justify-content-center">
<div class="form-check mx-2 mb-2">

View File

@ -73,10 +73,20 @@
}
</div>
@if (f['isInProgress'].value === false) {
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" formControlName="won" id="won">
<label class="form-check-label" for="won">
Won
</label>
</div>
}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" formControlName="won" id="won">
<label class="form-check-label" for="won">
Won
<input class="form-check-input" type="checkbox" formControlName="isInProgress" id="isInProgress">
<label class="form-check-label" for="isInProgress">
In Progress
</label>
</div>
@ -125,7 +135,11 @@
<td>{{desertStorm.opposingParticipants}}</td>
<td>{{desertStorm.participants}}</td>
<td>
<i class="bi " [ngClass]="desertStorm.won ? 'bi-check-lg text-success' : 'bi-x-lg text-danger'"></i>
@if (desertStorm.isInProgress) {
<i class="bi bi-hourglass-split"></i> In Progress
} @else {
<i class="bi " [ngClass]="desertStorm.won ? 'bi-check-lg text-success' : 'bi-x-lg text-danger'"></i>
}
</td>
<td>
<div class="d-flex gap-3 justify-content-around">

View File

@ -81,6 +81,7 @@ export class DesertStormComponent implements OnInit {
allianceId: new FormControl<string>(desertStormModel ? desertStormModel.allianceId : this._tokenService.getAllianceId()!, [Validators.required]),
eventDate: new FormControl<string>(new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())).toISOString().substring(0, 10)),
won: new FormControl<boolean>(desertStormModel ? desertStormModel.won : false),
isInProgress: new FormControl(desertStormModel ? desertStormModel.isInProgress : true),
opponentName: new FormControl<string>(desertStormModel ? desertStormModel.opponentName : ''),
opponentServer: new FormControl<number | null>(desertStormModel ? desertStormModel.opponentServer : null),
OpposingParticipants: new FormControl<number | null>(desertStormModel ? desertStormModel.opposingParticipants : null),
@ -163,6 +164,7 @@ export class DesertStormComponent implements OnInit {
}
onCancel() {
this.isUpdate = false;
this.isCreateDessertStorm = false;
this.selectedPlayers = 0;
this.desertStormPlayers = [];

View File

@ -114,6 +114,7 @@ export class MarshalGuardComponent implements OnInit {
}
onCancel() {
this.isUpdate = false;
this.isCreateMarshalGuard = false;
}

View File

@ -5,10 +5,25 @@
</div>
@if (vsDuelDetail) {
<div class="card mt-5" [ngClass]="vsDuelDetail.won ? 'border-success' : 'border-danger'">
<h5 class="card-header d-flex justify-content-between">
<div class="card mt-5" [ngClass]="vsDuelDetail.isInProgress ? '' : vsDuelDetail.won ? 'border-success' : 'border-danger'">
<h5 class="card-header d-flex justify-content-between" [ngClass]="vsDuelDetail.vsDuelLeague === 'Gold League' ? 'bg-warning text-black' : vsDuelDetail.vsDuelLeague === 'Silver League' ? 'bg-white text-black' : 'bg-primary text-white'">
<div>Week {{vsDuelDetail.eventDate | week}} / {{vsDuelDetail.eventDate | date: 'yyyy'}}</div>
<div [ngClass]="vsDuelDetail.won ? 'text-success' : 'text-danger'">{{vsDuelDetail.won ? 'VICTORY' : 'DEFEAT'}}</div>
@switch (vsDuelDetail.vsDuelLeague) {
@case ('Gold League') {
<div><i class="bi bi-trophy-fill text-black"></i> Gold</div>
}
@case ('Diamond League') {
<i class="bi bi-gem text-white"> Diamond</i>
}
@case ('Silver League') {
<i class="bi bi-star text-black"> Silver</i>
}
}
@if (vsDuelDetail.isInProgress) {
<div><i class="bi bi-hourglass-split"></i> In Progress</div>
} @else {
<div>{{vsDuelDetail.won ? 'VICTORY' : 'DEFEAT'}}</div>
}
</h5>
<div class="card-body">
<h5 class="card-title">Opponent: <span class="text-primary">{{vsDuelDetail.opponentName}}</span></h5>

View File

@ -74,12 +74,37 @@
</div>
}
</div>
<div class="form-floating mb-3 is-invalid">
<select [ngClass]="{
'is-invalid': df['vsDuelLeagueId'].invalid && (df['vsDuelLeagueId'].dirty || df['vsDuelLeagueId'].touched),
'is-valid': df['vsDuelLeagueId'].valid}" class="form-control" id="vsDuelLeagueId" formControlName="vsDuelLeagueId">
@for (vsDuelLeague of vsDuelLeagues; track vsDuelLeague.id) {
<option [ngValue]="vsDuelLeague.id">{{vsDuelLeague.name}}</option>
}
</select>
<label for="opponentSize">Opponent size</label>
@if (df['opponentSize'].invalid && (df['opponentSize'].dirty || df['opponentSize'].touched)) {
<div class="invalid-feedback">
@if (df['opponentSize'].hasError('required')) {
<p>Opponent size is required</p>
}
</div>
}
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" formControlName="won" id="won">
<label class="form-check-label" for="won">
Won
</label>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" formControlName="isInProgress" id="isInProgress">
<label class="form-check-label" for="isInProgress">
In Progress
</label>
</div>
</form>
<div class="d-grid gap-2 col-6 mx-auto mt-5">
<button [disabled]="vsDuelForm.invalid || !vsDuelForm.dirty" (click)="onUpdateEvent()" class="btn btn-primary" type="button">Update Event</button>

View File

@ -7,6 +7,8 @@ import {VsDuelParticipantService} from "../../../services/vs-duel-participant.se
import {VsDuelParticipantModel} from "../../../models/vsDuelParticipant.model";
import {forkJoin, Observable} from "rxjs";
import {ToastrService} from "ngx-toastr";
import {VsDuelLeagueService} from "../../../services/vs-duel-league.service";
import {VsDuelLeagueModel} from "../../../models/vsDuelLeague.model";
@Component({
selector: 'app-vs-duel-edit',
@ -18,10 +20,12 @@ export class VsDuelEditComponent implements OnInit {
private readonly _activatedRote: ActivatedRoute = inject(ActivatedRoute);
private readonly _vsDuelService: VsDuelService = inject(VsDuelService);
private readonly _vsDuelParticipantService: VsDuelParticipantService = inject(VsDuelParticipantService);
private readonly _vsDuelLeagueService = inject(VsDuelLeagueService);
private readonly _toastr: ToastrService = inject(ToastrService);
private vsDuelId!: string;
private vsDuelDetail!: VsDuelDetailModel;
public vsDuelLeagues: VsDuelLeagueModel[] = [];
public vsDuelParticipantsForm: FormGroup = new FormGroup({});
public vsDuelForm: FormGroup = new FormGroup({});
@ -38,6 +42,21 @@ export class VsDuelEditComponent implements OnInit {
ngOnInit() {
this.vsDuelId = this._activatedRote.snapshot.params['id'];
this.getVsDuelDetail(this.vsDuelId);
this.getVsDuelLeagues();
}
getVsDuelLeagues() {
this._vsDuelLeagueService.getVsDuelLeagues().subscribe({
next: ((response) => {
if (response) {
this.vsDuelLeagues = response;
}
}),
error: (error) => {
console.log(error);
this._toastr.error('Could not load vs duel leagues', 'Load VS duel leagues');
}
});
}
getVsDuelDetail(vsDuelId: string) {
@ -55,8 +74,10 @@ export class VsDuelEditComponent implements OnInit {
this.vsDuelForm = new FormGroup({
id: new FormControl<string>(vsDuelDetail.id),
allianceId: new FormControl<string>(vsDuelDetail.allianceId),
vsDuelLeagueId: new FormControl<string>(vsDuelDetail.vsDuelLeagueId, [Validators.required]),
eventDate: new FormControl<string>(new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate())).toISOString().substring(0, 10)),
won: new FormControl<boolean>(vsDuelDetail.won),
isInProgress: new FormControl<boolean>(vsDuelDetail.isInProgress),
opponentName: new FormControl<string>(vsDuelDetail.opponentName, [Validators.required, Validators.maxLength(150)]),
opponentServer: new FormControl<number>(vsDuelDetail.opponentServer, [Validators.required]),
opponentPower: new FormControl<number>(vsDuelDetail.opponentPower, [Validators.required]),

View File

@ -31,6 +31,7 @@
<th scope="col">Opponent power</th>
<th scope="col">Opponent size</th>
<th scope="col">Won</th>
<th scope="col">League</th>
<th scope="col">Action</th>
</tr>
</thead>
@ -44,8 +45,23 @@
<td>{{vsDuel.opponentPower}}</td>
<td>{{vsDuel.opponentSize}}</td>
<td>
<i class="bi " [ngClass]="vsDuel.won ? 'bi-check-lg text-success' : 'bi-x-lg text-danger'"></i>
@if (vsDuel.isInProgress) {
<i class="bi bi-hourglass-split"></i> In Progress
} @else {
<i class="bi " [ngClass]="vsDuel.won ? 'bi-check-lg text-success' : 'bi-x-lg text-danger'"></i>
}
</td>
<td>@switch (vsDuel.vsDuelLeague) {
@case ('Silver League') {
<i class="bi bi-star text-white"> Silver</i>
}
@case ('Gold League'){
<i class="bi bi-trophy-fill text-warning"> Gold</i>
}
@case ('Diamond League') {
<i class="bi bi-gem text-primary"> Diamond</i>
}
}</td>
<td>
<div class="d-flex gap-3 justify-content-around">
<i (click)="onGoToVsDuelInformation(vsDuel)" class="bi custom-info-icon bi-info-circle-fill"></i>

View File

@ -41,7 +41,10 @@ export class VsDuelComponent implements OnInit {
opponentPower: 0,
opponentServer: 0,
opponentSize: 0,
createdBy: ''
createdBy: '',
isInProgress: true,
vsDuelLeagueId: '',
vsDuelLeague: ''
};
this.openVsDuelEditModal(vsDuel, false);
}

View File

@ -0,0 +1,18 @@
import {inject, Injectable} from '@angular/core';
import {environment} from "../../environments/environment";
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";
import {VsDuelLeagueModel} from "../models/vsDuelLeague.model";
@Injectable({
providedIn: 'root'
})
export class VsDuelLeagueService {
private readonly _serviceUrl: string = environment.apiBaseUrl + 'VsDuelLeagues/';
private readonly _httpClient: HttpClient = inject(HttpClient);
getVsDuelLeagues(): Observable<VsDuelLeagueModel[]> {
return this._httpClient.get<VsDuelLeagueModel[]>(this._serviceUrl);
}
}