BililiveRecorder/BililiveRecorder.Web/Models/Rest/DataMappingProfile.cs

28 lines
1022 B
C#
Raw Normal View History

2022-04-03 13:34:55 +08:00
using AutoMapper;
using BililiveRecorder.Core;
using BililiveRecorder.Core.Config.V2;
2022-04-03 15:34:22 +08:00
namespace BililiveRecorder.Web.Models.Rest
2022-04-03 13:34:55 +08:00
{
public class DataMappingProfile : Profile
{
public DataMappingProfile()
{
this.CreateMap<IRoom, RoomDto>()
.ForMember(x => x.RoomId, x => x.MapFrom(s => s.RoomConfig.RoomId))
2022-04-03 15:34:22 +08:00
.ForMember(x => x.AutoRecord, x => x.MapFrom(s => s.RoomConfig.AutoRecord))
;
2022-04-03 13:34:55 +08:00
2022-04-03 15:34:22 +08:00
this.CreateMap<RecordingStats, RoomStatsDto>()
.ForMember(x => x.SessionDuration, x => x.MapFrom(s => s.SessionDuration.TotalMilliseconds))
.ForMember(x => x.SessionMaxTimestamp, x => x.MapFrom(s => s.SessionMaxTimestamp.TotalMilliseconds))
.ForMember(x => x.FileMaxTimestamp, x => x.MapFrom(s => s.FileMaxTimestamp.TotalMilliseconds))
;
2022-04-03 13:34:55 +08:00
this.CreateMap<RoomConfig, RoomConfigDto>();
this.CreateMap<GlobalConfig, GlobalConfigDto>();
}
}
}