Updated DTOs

This commit is contained in:
2026-04-21 10:15:09 +02:00
parent 331a48e478
commit 60e0df2b1a
19 changed files with 4 additions and 183 deletions
@@ -3,9 +3,5 @@
public class CreateGroupDto
{
public string? Label { get; set; }
public string? Title { get; set; }
public string? Description { get; set; }
public int Duration { get; set; }
public int? VoteDuration { get; set; }
public List<CreateUserGroupDto>? UserGroups { get; set; }
}
@@ -6,10 +6,6 @@ public class GetGroupDetailsDto
{
public int Id { get; set; }
public string? Label { get; set; }
public bool IsFinished { get; set; }
public string? Title { get; set; }
public string? Description { get; set; }
public int Duration { get; set; }
public DateTime CreationDate { get; set; }
public List<GetMessageDto>? Messages { get; set; }
-1
View File
@@ -4,5 +4,4 @@ public class GetGroupDto
{
public int Id { get; set; }
public string? Label { get; set; }
public bool IsFinished { get; set; }
}
@@ -1,8 +0,0 @@
namespace BeReadyBackend.DTO.Groups;
public class GetGroupRankingDto
{
public int UserId { get; set; }
public string? Username { get; set; }
public int Score { get; set; }
}
-9
View File
@@ -1,9 +0,0 @@
namespace BeReadyBackend.DTO.Groups;
public class GetProofDto
{
public int UserId { get; set; }
public string? Username { get; set; }
public string? Proof { get; set; }
public int Score { get; set; }
}
@@ -5,5 +5,4 @@ public class GetUserGroupDto
public int Id { get; set; }
public string? Username { get; set; }
public string? Grade { get; set; }
public int Score { get; set; }
}
@@ -5,7 +5,6 @@ public class GetRandomChallengeDto
public int Id { get; set; }
public string? Label { get; set; }
public string? Libelle { get; set; }
public int Duration { get; set; }
public bool IsAlreadyPast { get; set; }
public DateTime? GeneratedAt { get; set; }
}
@@ -4,6 +4,5 @@ public class GetUserChallengeDto
{
public string? ChallengeTitle { get; set; }
public string? ChallengeDescription { get; set; }
public int ChallengeDuration { get; set; }
public DateOnly ChallengeStartDate { get; set; }
}
+1 -4
View File
@@ -3,10 +3,7 @@
public class GetUserStatsDto
{
public int Id { get; set; }
public int Score { get; set; }
public int TotalWin { get; set; }
public int TotalLikes { get; set; }
public int TotalChallenge { get; set; }
public int TotalPodium { get; set; }
public int TotalBonusChallenge { get; set; }
public int Series { get; set; }
}
@@ -49,8 +49,7 @@ public class EntityToDtoMappings : Profile
CreateMap<UserGroup, GetUserGroupDto>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.UserId))
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.User!.Username))
.ForMember(dest => dest.Score, opt => opt.MapFrom(src => src.User!.TotalLikes));
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.User!.Username));
CreateMap<UserGroup, GetGroupDto>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.GroupId))
@@ -63,12 +62,6 @@ public class EntityToDtoMappings : Profile
CreateMap<Message, GetMessageDto>()
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.User!.Username));
CreateMap<UserGroup, GetProofDto>()
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.User!.Username));
CreateMap<UserGroup, GetGroupRankingDto>()
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.User!.Username));
CreateMap<RandomChallenge, GetRandomChallengeDto>();
CreateMap<Designation, GetDesignationDto>();
@@ -15,27 +15,5 @@ public class CreateGroupDtoValidator : Validator<CreateGroupDto>
.WithMessage("Label cannot exceed 100 characters")
.MinimumLength(2)
.WithMessage("Label must exceed 2 characters");
RuleFor(x => x.Title)
.NotEmpty()
.WithMessage("Title cannot be empty")
.MaximumLength(50)
.WithMessage("Title cannot exceed 50 characters")
.MinimumLength(2)
.WithMessage("Title must exceed 2 characters");
RuleFor(x => x.Description)
.NotEmpty()
.WithMessage("Description cannot be empty")
.MaximumLength(200)
.WithMessage("Description cannot exceed 200 characters")
.MinimumLength(2)
.WithMessage("Description must exceed 2 characters");
RuleFor(x => x.Duration)
.NotEmpty()
.WithMessage("Duration cannot be empty")
.GreaterThan(0)
.WithMessage("Duration must exceed 1 hour");
}
}
@@ -22,32 +22,6 @@ public class GetGroupDetailsDtoValidator : Validator<GetGroupDetailsDto>
.MinimumLength(2)
.WithMessage("Label must exceed 2 characters");
RuleFor(x => x.IsFinished)
.NotEmpty()
.WithMessage("IsFinished cannot be empty");
RuleFor(x => x.Title)
.NotEmpty()
.WithMessage("Title cannot be empty")
.MaximumLength(50)
.WithMessage("Title cannot exceed 50 characters")
.MinimumLength(2)
.WithMessage("Title must exceed 2 characters");
RuleFor(x => x.Description)
.NotEmpty()
.WithMessage("Description cannot be empty")
.MaximumLength(200)
.WithMessage("Description cannot exceed 50 characters")
.MinimumLength(2)
.WithMessage("Description must exceed 2 characters");
RuleFor(x => x.Duration)
.NotEmpty()
.WithMessage("Duration cannot be empty")
.GreaterThan(0)
.WithMessage("Duration must exceed 1 hour");
RuleFor(x => x.CreationDate)
.NotEmpty()
.WithMessage("CreationDate cannot be empty");
@@ -21,9 +21,5 @@ public class GetGroupDtoValidator : Validator<GetGroupDto>
.WithMessage("Label cannot exceed 100 characters")
.MinimumLength(2)
.WithMessage("Label must exceed 2 characters");
RuleFor(x => x.IsFinished)
.NotEmpty()
.WithMessage("IsFinished cannot be empty");
}
}
@@ -1,29 +0,0 @@
using BeReadyBackend.DTO.Groups;
using FastEndpoints;
using FluentValidation;
namespace BeReadyBackend.Validators.Groups;
public class GetGroupRankingDtoValidator : Validator<GetGroupRankingDto>
{
public GetGroupRankingDtoValidator()
{
RuleFor(x => x.UserId)
.NotEmpty()
.WithMessage("Id cannot be empty")
.GreaterThan(0)
.WithMessage("Id must be greater than 0");
RuleFor(x => x.Username)
.NotEmpty()
.WithMessage("Username cannot be empty")
.MaximumLength(50)
.WithMessage("Username cannot exceed 50 characters")
.MinimumLength(2)
.WithMessage("Username must exceed 2 characters");
RuleFor(x => x.Score)
.NotEmpty()
.WithMessage("Score cannot be empty");
}
}
@@ -1,33 +0,0 @@
using BeReadyBackend.DTO.Groups;
using FastEndpoints;
using FluentValidation;
namespace BeReadyBackend.Validators.Groups;
public class GetProofDtoValidator : Validator<GetProofDto>
{
public GetProofDtoValidator()
{
RuleFor(x => x.UserId)
.NotEmpty()
.WithMessage("Id cannot be empty")
.GreaterThan(0)
.WithMessage("Id must be greater than 0");
RuleFor(x => x.Username)
.NotEmpty()
.WithMessage("Username cannot be empty")
.MaximumLength(50)
.WithMessage("Username cannot exceed 50 characters")
.MinimumLength(2)
.WithMessage("Username must exceed 2 characters");
RuleFor(x => x.Proof)
.NotEmpty()
.WithMessage("Proof cannot be empty");
RuleFor(x => x.Score)
.NotEmpty()
.WithMessage("Score cannot be empty");
}
}
@@ -25,9 +25,5 @@ public class GetUserGroupDtoValidator : Validator<GetUserGroupDto>
RuleFor(x => x.Grade)
.NotEmpty()
.WithMessage("Grade cannot be empty");
RuleFor(x => x.Score)
.NotEmpty()
.WithMessage("Score cannot be empty");
}
}
@@ -24,12 +24,6 @@ public class GetRandomChallengeDtoValidator : Validator<GetRandomChallengeDto>
.MinimumLength(2)
.WithMessage("Libelle must exceed 2 characters");
RuleFor(x => x.Duration)
.NotEmpty()
.WithMessage("Duration cannot be empty")
.GreaterThan(0)
.WithMessage("Duration must exceed 1 hour");
RuleFor(x => x.IsAlreadyPast)
.NotEmpty()
.WithMessage("Isalready past is required");
@@ -19,9 +19,5 @@ public class GetUserChallengeDtoValidator : Validator<GetUserChallengeDto>
.WithMessage("Challenge Description is required")
.MaximumLength(200)
.WithMessage("Challenge Description cannot exceed 200 characters");
RuleFor(x => x.ChallengeDuration)
.NotEmpty()
.WithMessage("Challenge Duration is required");
}
}
@@ -8,26 +8,14 @@ public class GetUserStatsDtoValidator : Validator<GetUserStatsDto>
{
public GetUserStatsDtoValidator()
{
RuleFor(x => x.Score)
RuleFor(x => x.TotalLikes)
.NotEmpty()
.WithMessage("Score is required");
RuleFor(x => x.TotalWin)
.NotEmpty()
.WithMessage("Total win is required");
.WithMessage("TotalLikes is required");
RuleFor(x => x.TotalChallenge)
.NotEmpty()
.WithMessage("Total challenge is required");
RuleFor(x => x.TotalPodium)
.NotEmpty()
.WithMessage("Total podium is required");
RuleFor(x => x.TotalBonusChallenge)
.NotEmpty()
.WithMessage("Total bonus is required");
RuleFor(x => x.Series)
.NotEmpty()
.WithMessage("Series is required");