mirror of
https://bitbucket.org/myhomie/mycorerepository.git
synced 2025-12-06 17:51:20 +00:00
47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using MyCore.Interfaces.DTO;
|
|
using MyCore.Interfaces.Models;
|
|
using MyCore.Services;
|
|
using MyCore.Services.MyControlPanel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MyCore.Service
|
|
{
|
|
public class EventService
|
|
{
|
|
public static EventDetailDTO CreateOrUpdate(EventDatabaseService _EventDatabaseService, string homeId, EventDetailDTO eventDetailDTO, bool create)
|
|
{
|
|
Event evt;
|
|
if (create)
|
|
{
|
|
evt = new Event();
|
|
evt.Date = DateTime.Now;
|
|
}
|
|
else
|
|
{
|
|
evt = _EventDatabaseService.GetById(eventDetailDTO.Id);
|
|
}
|
|
|
|
evt.HomeId = homeId;
|
|
evt.Type = eventDetailDTO.Type;
|
|
evt.RoomId = eventDetailDTO.RoomId;
|
|
evt.DeviceState = eventDetailDTO.DeviceState;
|
|
evt.AutomationTriggered = eventDetailDTO.AutomationTriggered;
|
|
evt.AlarmTriggered = eventDetailDTO.AlarmTriggered;
|
|
|
|
if (create)
|
|
{
|
|
evt = _EventDatabaseService.Create(evt);
|
|
}
|
|
else
|
|
{
|
|
evt = _EventDatabaseService.Update(evt);
|
|
}
|
|
|
|
return evt.ToDetailDTO();
|
|
}
|
|
}
|
|
}
|