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); }
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); }
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); }