UsersMapper.ToGetUsersDto() was not copying LastLogin, BannedAt, or
UpdatedAt from the User entity to the UserInfoDto, causing the client
to always receive null for these fields. Added the missing mappings.
Also added null fallback ('Never') for LastLogin display on the User
page to prevent NullReferenceException when the value has not been set.
30 lines
967 B
C#
30 lines
967 B
C#
using Butter.Dtos.User;
|
|
using Lactose.Models;
|
|
|
|
namespace Lactose.Mapper;
|
|
|
|
/// <summary>
|
|
/// Provides mapping methods for User objects.
|
|
/// </summary>
|
|
public static class UsersMapper {
|
|
/// <summary>
|
|
/// Maps a User object to a UserInfoDto object.
|
|
/// </summary>
|
|
/// <param name="user">The User object to map.</param>
|
|
/// <returns>A UserInfoDto object containing the mapped data.</returns>
|
|
public static UserInfoDto ToGetUsersDto(this User user) {
|
|
return new UserInfoDto {
|
|
Id = user.Id,
|
|
Email = user.Email,
|
|
Username = user.Username,
|
|
CreatedAt = user.CreatedAt,
|
|
IsBanned = user.BannedAt != null,
|
|
BannedAt = user.BannedAt,
|
|
LastLogin = user.LastLogin,
|
|
UpdatedAt = user.UpdatedAt,
|
|
DeletedAt = user.DeletedAt,
|
|
AccessLevel = user.AccessLevel,
|
|
};
|
|
}
|
|
}
|