FlexitimeTracker/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/Converters/TimeLogConverter.cs
Chris.Watts90@outlook.com f871c23631 add converters to help convert from/to data transfer objects.
removed conversion code from SQLiteRepository.cs in favour of new converters.
pulled out string queries from SQLiteRepository and moved to SQLiteProcedures.cs.
#95
2018-06-04 11:07:29 +01:00

43 lines
1.3 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
};
}
}
}