Fixed error with designation name
This commit is contained in:
@@ -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");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user