Beispiel #1
0
        public WorkTime?FindLatestFromSnapshot(User user)
        {
            var found = _repository.FindLatestFromSnapshot(user);

            if (found == null)
            {
                return(null);
            }
            if (found.AggregateId == _moduleService.CurrentWorkTime?.AggregateId)
            {
                return(WorkTime.Combine(found, _moduleService.CurrentWorkTime));
            }

            return(found);
        }
Beispiel #2
0
        public WorkTime?Find(User user, DateTime date)
        {
            var found = _repository.Find(user, date);

            if (found == null)
            {
                return(null);
            }
            if (found.AggregateId == _moduleService.CurrentWorkTime?.AggregateId)
            {
                return(WorkTime.Combine(found, _moduleService.CurrentWorkTime));
            }

            return(found);
        }
Beispiel #3
0
        public WorkTime?FindFromSnapshot(WorkTimeSnapshotCreated snapshotEvent)
        {
            var found = _repository.FindFromSnapshot(snapshotEvent);

            if (found == null)
            {
                return(null);
            }
            if (found.AggregateId == _moduleService.CurrentWorkTime?.AggregateId)
            {
                return(WorkTime.Combine(found, _moduleService.CurrentWorkTime));
            }

            return(found);
        }
Beispiel #4
0
        public List <WorkTime> FindAll(User user, DateTime?startDate, DateTime?endDate)
        {
            var found = _repository.FindAll(user, startDate, endDate);

            if (_moduleService.CurrentWorkTime != null)
            {
                for (int i = 0; i < found.Count; i++)
                {
                    if (found[i].AggregateId == _moduleService.CurrentWorkTime.AggregateId)
                    {
                        found[i] = WorkTime.Combine(found[i], _moduleService.CurrentWorkTime);
                        break;
                    }
                }
            }
            return(found);
        }
Beispiel #5
0
        public void Combine_ads_new_events()
        {
            var workTime = WorkTimeTestUtils.CreateManual(_user);

            workTime.StartManually();
            var snap = workTime.TakeSnapshot();

            var totalEvs = workTime.PendingEvents.Count;

            var fromSnap = WorkTime.CreateFromSnapshot(snap);

            fromSnap.AddRecognitionFailure(DateTime.UtcNow, false, false);

            WorkTime joined = WorkTime.Combine(workTime, fromSnap);

            joined.PendingEvents.Count.Should().Be(totalEvs + 1);
            joined.PendingEvents.Last().Should().BeOfType <FaceRecognitionFailure>();
        }