Fixed error with designation name

This commit is contained in:
2026-03-28 21:04:29 +01:00
parent 147c1ff5df
commit 815cbb0fc2
4 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -6,6 +6,6 @@ public class GetUserDto
public string? FirstName { get; set; }
public string? Name { get; set; }
public string? Username { get; set; }
public int? DesignationId { get; set; }
public string? DesignationName { get; set; }
public GetUserStatsDto? GetUserStatsDto { get; set; }
}
@@ -22,7 +22,8 @@ public class EntityToDtoMappings : Profile
.ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Achievement!.Description));
CreateMap<User, GetUserDto>()
.ForMember(dest => dest.GetUserStatsDto, opt => opt.MapFrom(src => src));
.ForMember(dest => dest.GetUserStatsDto, opt => opt.MapFrom(src => src))
.ForMember(dest => dest.DesignationName, opt => opt.MapFrom(src => src.Designation!.Label));
CreateMap<User, GetUserDetailsDto>()
.ForMember(dest => dest.GetUserStatsDto, opt => opt.MapFrom(src => src));
@@ -8,6 +8,7 @@ public class GetUserByIdSpec : SingleResultSpecification<User>
public GetUserByIdSpec(int userId)
{
Query
.Include(x => x.Designation)
.Where(x => x.Id == userId);
}
}
@@ -38,9 +38,9 @@ public class GetUserDtoValidator : Validator<GetUserDto>
.MinimumLength(2)
.WithMessage("Username must exceed 2 characters");
When(x => x.DesignationId is not null, () =>
When(x => x.DesignationName is not null, () =>
{
RuleFor(x => x.DesignationId)
RuleFor(x => x.DesignationName)
.NotEmpty()
.WithMessage("DesignationId is required");
});