123 lines
3.8 KiB
C#
123 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Interfaces;
|
|
|
|
namespace SQLiteRepository.Converters
|
|
{
|
|
static class TimeLogConverter
|
|
{
|
|
public static TimeLog ConvertToTimeLogDto(TimeLogDb log)
|
|
{
|
|
return new TimeLog
|
|
{
|
|
CalendarWeek = log.CalendarWeek,
|
|
Direction = LogDirectionConverter.ConvertToLogDirectionDto(log.Direction),
|
|
EventTime = log.SwipeEventDateTime,
|
|
Id = log.Id,
|
|
IdentifierId = log.IdentifierId,
|
|
UserId = log.UserId_FK,
|
|
Source = LogSourceConverter.ConvertToLogSourceDto(log.Source),
|
|
Year = log.Year
|
|
};
|
|
}
|
|
|
|
public static TimeLogDb ConvertFromTimeLogDto(TimeLog log)
|
|
{
|
|
return new TimeLogDb
|
|
{
|
|
CalendarWeek = log.CalendarWeek,
|
|
Year = log.Year,
|
|
UserId_FK = log.UserId,
|
|
IdentifierId = log.IdentifierId,
|
|
Direction = LogDirectionConverter.ConvertFromLogDirectionDto(log.Direction),
|
|
Id = log.Id,
|
|
Source = LogSourceConverter.ConvertFromLogSourceDto(log.Source),
|
|
SwipeEventDateTime = log.EventTime
|
|
};
|
|
}
|
|
}
|
|
|
|
static class LogSourceConverter
|
|
{
|
|
public static LogSource ConvertToLogSourceDto(LogSourceDb source)
|
|
{
|
|
switch (source)
|
|
{
|
|
case LogSourceDb.IDENTIFIER:
|
|
return LogSource.IDENTIFIER;
|
|
case LogSourceDb.TRAYAPP:
|
|
return LogSource.TRAYAPP;
|
|
case LogSourceDb.UI:
|
|
return LogSource.UI;
|
|
default:
|
|
return LogSource.UNKNOWN;
|
|
}
|
|
}
|
|
|
|
public static LogSourceDb ConvertFromLogSourceDto(LogSource source)
|
|
{
|
|
switch (source)
|
|
{
|
|
case LogSource.IDENTIFIER:
|
|
return LogSourceDb.IDENTIFIER;
|
|
case LogSource.TRAYAPP:
|
|
return LogSourceDb.TRAYAPP;
|
|
case LogSource.UI:
|
|
return LogSourceDb.UI;
|
|
default:
|
|
return LogSourceDb.UNKNOWN;
|
|
}
|
|
}
|
|
}
|
|
|
|
static class LogDirectionConverter
|
|
{
|
|
public static LogDirection ConvertToLogDirectionDto(LogDirectionDb direction)
|
|
{
|
|
switch (direction)
|
|
{
|
|
case LogDirectionDb.IN:
|
|
return LogDirection.IN;
|
|
case LogDirectionDb.OUT:
|
|
return LogDirection.OUT;
|
|
default:
|
|
return LogDirection.UNKNOWN;
|
|
}
|
|
}
|
|
|
|
public static LogDirectionDb ConvertFromLogDirectionDto(LogDirection direction)
|
|
{
|
|
switch (direction)
|
|
{
|
|
case LogDirection.IN:
|
|
return LogDirectionDb.IN;
|
|
case LogDirection.OUT:
|
|
return LogDirectionDb.OUT;
|
|
default:
|
|
return LogDirectionDb.UNKNOWN;
|
|
}
|
|
}
|
|
|
|
public static LogDirectionDb InvertLogDirectionDb(LogDirectionDb direction)
|
|
{
|
|
return (LogDirectionDb)(int)InvertLogDirection((LogDirection)(int)direction);
|
|
}
|
|
|
|
public static LogDirection InvertLogDirection(LogDirection direction)
|
|
{
|
|
switch (direction)
|
|
{
|
|
case LogDirection.IN:
|
|
return LogDirection.OUT;
|
|
case LogDirection.OUT:
|
|
return LogDirection.IN;
|
|
default:
|
|
return LogDirection.UNKNOWN;
|
|
}
|
|
}
|
|
}
|
|
}
|