Пример #1
0
        private async Task UpdateDoorStatus(DoorDto dto, CancellationToken cancellationToken)
        {
            var door = await _context.Doors.FindAsync(new object[] { dto.DoorId });

            door.SetStatus(dto.Status);
            await _context.SaveChangesAsync(cancellationToken);
        }
Пример #2
0
        private async Task AddDoorStatusEntryToHistory(DoorDto d, Status previusStatus)
        {
            var doorStatusHistory = new DoorStatusHistory
            {
                DoorId         = d.DoorId,
                PreviousStatus = previusStatus,
                NewStatus      = d.Status,
                TimeOfChange   = DateTime.UtcNow
            };

            await _context.DoorStatusHistory.AddAsync(doorStatusHistory);
        }
Пример #3
0
        private async Task ProcessDoorStatus(DoorDto d, Status doorStatus, CancellationToken cancellationToken)
        {
            var prevStatus = d.Status;

            d.Status = doorStatus;

            await UpdateDoorStatus(d, cancellationToken);

            await AddDoorStatusEntryToHistory(d, prevStatus);

            await _context.SaveChangesAsync(cancellationToken);
        }