Sube carpetas API, API.Tests, Application y Domain del Backend
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using Application.Utils.Constants.Validation;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace Application.DTOs.PlayerSanction.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Request DTO for submitting an appeal against a player sanction.
|
||||
/// </summary>
|
||||
public class AppealPlayerSanctionRequest
|
||||
{
|
||||
[Required]
|
||||
[StringLength(SanctionFieldLengths.LongTextMaxLength, MinimumLength = SanctionFieldLengths.LongTextMinLength)]
|
||||
public required string Reason { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using Application.Utils.Constants.Validation;
|
||||
|
||||
using Domain.Enums;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Application.DTOs.PlayerSanction.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to create a Player Sanction.
|
||||
/// </summary>
|
||||
public class CreatePlayerSanctionRequest : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The duration in fixtures, or fechas, of the sanction.
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "The Duration field is required.")]
|
||||
public required int Duration { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "The IssuedDate field is required.")]
|
||||
public required DateTime IssuedDate { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "The Description field is required.")]
|
||||
[MaxLength(SanctionFieldLengths.DescriptionMaxLength)]
|
||||
public required string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The kind of subject the sanction targets; defaults to Player so existing clients keep working.
|
||||
/// </summary>
|
||||
public SanctionSubjectType SubjectType { get; set; } = SanctionSubjectType.Player;
|
||||
|
||||
/// <summary>
|
||||
/// The sanctioned player's identifier; required when SubjectType is Player.
|
||||
/// </summary>
|
||||
public Guid? PlayerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sanctioned team's identifier; required when SubjectType is Team.
|
||||
/// </summary>
|
||||
public Guid? TeamId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sanctioned staff member's name; required when SubjectType is Staff.
|
||||
/// </summary>
|
||||
[MaxLength(SanctionFieldLengths.DescriptionMaxLength)]
|
||||
public string? StaffName { get; set; }
|
||||
|
||||
public required Guid MatchId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ensures the identity that matches the chosen subject type is supplied.
|
||||
/// </summary>
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
switch (SubjectType)
|
||||
{
|
||||
case SanctionSubjectType.Player when !PlayerId.HasValue:
|
||||
yield return new ValidationResult(
|
||||
"The PlayerId field is required for a player sanction.",
|
||||
[nameof(PlayerId)]);
|
||||
break;
|
||||
case SanctionSubjectType.Team when !TeamId.HasValue:
|
||||
yield return new ValidationResult(
|
||||
"The TeamId field is required for a team sanction.",
|
||||
[nameof(TeamId)]);
|
||||
break;
|
||||
case SanctionSubjectType.Staff when string.IsNullOrWhiteSpace(StaffName):
|
||||
yield return new ValidationResult(
|
||||
"The StaffName field is required for a staff sanction.",
|
||||
[nameof(StaffName)]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
using Application.DTOs.Abstract.Request;
|
||||
|
||||
using System;
|
||||
namespace Application.DTOs.PlayerSanction.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to get filtered player sanctions.
|
||||
/// </summary>
|
||||
public class GetPlayerSanctionsFilteredRequest : PaginatedFilterRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Overrides the base PaginatedFilterRequest default to sort newest-issued-first.
|
||||
/// </summary>
|
||||
public GetPlayerSanctionsFilteredRequest()
|
||||
{
|
||||
// String literal, not nameof, because the enclosing namespace Application.DTOs.PlayerSanction shadows the entity type; QueryableExtensions.SortBy resolves this name against the entity by reflection and matches PlayerSanction.IssuedDate.
|
||||
OrderBy = "IssuedDate";
|
||||
Order = SortOrder.Descending;
|
||||
}
|
||||
|
||||
public Guid? PlayerId { get; set; }
|
||||
|
||||
public Guid? MatchId { get; set; }
|
||||
|
||||
public Guid? TournamentId { get; set; }
|
||||
public Guid? DivisionId { get; set; }
|
||||
public Guid? StageId { get; set; }
|
||||
public Guid? TeamId { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public DateTime? IssuedDate { get; set; }
|
||||
|
||||
public int? Duration { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Application.Utils.Constants.Validation;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace Application.DTOs.PlayerSanction.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Request DTO for resolving a player sanction appeal.
|
||||
/// </summary>
|
||||
public class ResolveAppealRequest
|
||||
{
|
||||
[Required]
|
||||
public required bool Accepted { get; set; }
|
||||
|
||||
[Required]
|
||||
[StringLength(SanctionFieldLengths.LongTextMaxLength, MinimumLength = SanctionFieldLengths.LongTextMinLength)]
|
||||
public required string Resolution { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Application.Utils.Constants.Validation;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace Application.DTOs.PlayerSanction.Request;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a request to update a Player Sanction.
|
||||
/// </summary>
|
||||
public class UpdatePlayerSanctionRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The duration in fixtures of the sanction.
|
||||
/// </summary>
|
||||
public int? Duration { get; set; }
|
||||
|
||||
[MaxLength(SanctionFieldLengths.DescriptionMaxLength)]
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using Application.DTOs.Abstract.Response;
|
||||
|
||||
using Domain.Enums;
|
||||
|
||||
using System;
|
||||
namespace Application.DTOs.PlayerSanction.Response;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a response for a Player Sanction.
|
||||
/// </summary>
|
||||
public class PlayerSanctionResponse : BaseEntityResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The duration in fixtures, or fechas, of the sanction.
|
||||
/// </summary>
|
||||
public required int Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of fechas still to be served; zero means fully served, null means it cannot be computed.
|
||||
/// </summary>
|
||||
public int? FechasRemaining { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the sanction is still active, meaning fechas remain to be served.
|
||||
/// </summary>
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public required DateTime IssuedDate { get; set; }
|
||||
|
||||
public required string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unique, URL-friendly identifier used in sanction links.
|
||||
/// </summary>
|
||||
public required string Slug { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The kind of subject the sanction targets: Player, Team, or Staff.
|
||||
/// </summary>
|
||||
public SanctionSubjectType SubjectType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sanctioned player's identifier; null for team or staff sanctions.
|
||||
/// </summary>
|
||||
public Guid? PlayerId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sanctioned player's full name. Null for team or staff sanctions.
|
||||
/// </summary>
|
||||
public string? PlayerFullName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sanctioned team's identifier; null unless this is a team sanction.
|
||||
/// </summary>
|
||||
public Guid? TeamId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sanctioned team's name. Null unless this is a team sanction.
|
||||
/// </summary>
|
||||
public string? TeamName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The sanctioned staff member's name. Null unless this is a staff sanction.
|
||||
/// </summary>
|
||||
public string? StaffName { get; set; }
|
||||
|
||||
public required Guid MatchId { get; set; }
|
||||
|
||||
public SanctionAppealStatus AppealStatus { get; set; }
|
||||
|
||||
public string? AppealReason { get; set; }
|
||||
|
||||
public DateTime? AppealDate { get; set; }
|
||||
|
||||
public string? AppealResolution { get; set; }
|
||||
|
||||
public DateTime? AppealResolvedDate { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user