-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPingAppMappingProfile.cs
More file actions
30 lines (27 loc) · 890 Bytes
/
Copy pathPingAppMappingProfile.cs
File metadata and controls
30 lines (27 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using AutoMapper;
using PingApp.Models;
using System.IO;
using System.Net.NetworkInformation;
using System.Net.Sockets;
namespace PingApp
{
public class PingAppMappingProfile : Profile
{
public PingAppMappingProfile()
{
CreateMap<DeviceDTO, Device>();
CreateMap<Device, DeviceDTO>();
CreateMap<DeviceDTO, DeviceExport>()
.ForMember(dest => dest.LastSuccessfulReplyDt, opt =>
opt.MapFrom(src =>
src.PingResults
.Where(x => x.IpStatus == IPStatus.Success)
.OrderByDescending(x => x.ReplyDt)
.Select(x => x.ReplyDt)
.FirstOrDefault()));
CreateMap<DeviceExport, DeviceDTO>();
CreateMap<PingResultExport, PingResult>();
CreateMap<PingResult, PingResultExport>();
}
}
}