58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using System;
|
|
using Interfaces;
|
|
|
|
namespace SQLiteRepository.Converters
|
|
{
|
|
static class UserConverter
|
|
{
|
|
public static User ConvertToUserDto(UserIdentity user)
|
|
{
|
|
return new User
|
|
{
|
|
UserId = user.Id,
|
|
FirstName = user.FirstName,
|
|
LastName = user.LastName,
|
|
IsContractor = user.IsContractor,
|
|
HoursPerWeek = user.HoursPerWeek,
|
|
};
|
|
}
|
|
|
|
public static UserIdentity ConvertFromUserDto(User user)
|
|
{
|
|
return new UserIdentity
|
|
{
|
|
Id = user.UserId,
|
|
FirstName = user.FirstName,
|
|
LastName = user.LastName,
|
|
HoursPerWeek = user.HoursPerWeek,
|
|
IsContractor = user.IsContractor
|
|
};
|
|
}
|
|
}
|
|
|
|
static class IdentifierConverter
|
|
{
|
|
public static Identifier ConvertToIdentifierDto(CardUniqueId ident)
|
|
{
|
|
return new Identifier
|
|
{
|
|
Id = ident.Id,
|
|
UniqueId = ident.CardUId,
|
|
IsAssociatedToUser = ident.UserId_FK != Constants.UNASSIGNED_CARD_USER_ID,
|
|
LastUsed = ident.LastUsed.DateTime
|
|
};
|
|
}
|
|
|
|
public static CardUniqueId ConvertFromIdentifierDto(Identifier ident, int userId)
|
|
{
|
|
return new CardUniqueId
|
|
{
|
|
CardUId = ident.UniqueId,
|
|
Id = ident.Id,
|
|
UserId_FK = userId,
|
|
LastUsed = ident.LastUsed
|
|
};
|
|
}
|
|
}
|
|
}
|