using System; using System.Threading.Tasks; using FrameworkDAL.CustomCode.EventLog; using FrameworkDAL.DTO.EventLog; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.PubSub; namespace FrameworkBLL.EventLogSubscriber { public class EventLogSubscriberBLL : IEventLogSubscriberBLL { private readonly IEventLogDAL _eventLogDAL; public EventLogSubscriberBLL(IEventLogDAL eventLogDAL) { _eventLogDAL = eventLogDAL; } public async Task SaveEventLogSubscriber(PublishDTO publishDTO, LoginDTO loginDTO) { if (publishDTO == null) throw new ArgumentNullException(nameof(publishDTO)); // Map PublishDTO to EventLogDTO EventLogDTO eventLogDTO = new() { EventLogEventText = publishDTO.EventText, EventLogLink = publishDTO.Link, SourceId = publishDTO.SourceId, UserId = publishDTO.UserId, EventLogTags = publishDTO.Tags, EventLogEventValue = publishDTO.EventValue, EventLogData = publishDTO.Data ?? publishDTO.Payload ?? publishDTO.Request!, EventLogGeo = publishDTO.Geo, EventTypeId = publishDTO.EventTypeId, EventClassId = publishDTO.EventClassId, EventLogLogBookId = publishDTO.LogBookId, EventLogDataId = publishDTO.DataId, EventLogTimeStamp = publishDTO.Timestamp, EventChannelId = publishDTO.EventChannelId, EventLogOUId = publishDTO.OUId, EventLogMachineIp = publishDTO.MachineIP, EventLogModeOfWorking = publishDTO.ModeOfWorking, EventLogLoginEventLogId = publishDTO.LoginEventLogId, EventLogId = publishDTO.EventLogId, Login = loginDTO }; // Save to DB using DAL return await _eventLogDAL.SaveEventLog(eventLogDTO, loginDTO); } } }