Example #1
0
        protected override async Task Handle(NotifyAreaExitCommand request, CancellationToken cancellationToken)
        {
            var now     = DateTime.UtcNow;
            var profile = await repository.GetProfileAsync(request.ProfileId, request.DeviceId, cancellationToken);

            if (profile == null)
            {
                throw new DomainException("Profile not found.");
            }

            if (!profile.ActiveQuarantine(DateTime.UtcNow))
            {
                throw new DomainException("Profile is not in quarantine.");
            }

            var exit = new AreaExit(profile.Id, request.Severity, timeConvertService.UnixTimeStampToDateTime(request.RecordTimestamp));

            profile.AddAreaExit(exit);

            var check = new PresenceCheck(profile.Id, now, now, PresenceCheckStatus.LEFT);

            check.SetSeverity(exit.Severity);
            profile.AddPresenceCheck(check);

            await repository.UnitOfWork.SaveChangesAsync(cancellationToken);
        }
Example #2
0
        protected override async Task Handle(CreatePresenceCheckCommand request, CancellationToken cancellationToken)
        {
            var now      = DateTime.UtcNow;
            var profiles = await repository.GetProfilesByCovidPassAsync(request.CovidPass, cancellationToken);

            if (!profiles.Any())
            {
                throw new DomainException($"No profiles found with {nameof(request.CovidPass)}: '{request.CovidPass}'");
            }

            foreach (var profile in profiles)
            {
                // meeting notes - always create presente check

                //var activeCheck = await context.PresenceChecks.AsNoTracking()
                //    .Where(x => x.ProfileId == profile.Id && now < x.DeadLineCheck
                //        && x.Status != PresenceCheckStatus.OK)
                //    .ToListAsync(cancellationToken);

                if (profile.ActiveQuarantine(now))
                {
                    var check = new PresenceCheck(profile.Id, now, now.Add(request.DeadLineTime), request.Status);
                    profile.AddPresenceCheck(check);
                }
            }

            await context.SaveChangesAsync(cancellationToken);
        }
Example #3
0
        public bool ClientPresenceCheckRequest(string PossibleName)
        {
            Console.WriteLine("Received request to: Check presence of task ");
            User mUser = FindUser(Context.ConnectionId);

            PresenceCheck mPresenceCheck       = new PresenceCheck(mUser, PossibleName);
            bool          mPresenceCheckOutput = mPresenceCheck.Execute();

            Console.WriteLine("Result broadcast to caller." + mPresenceCheckOutput.ToString());
            return(mPresenceCheckOutput);
        }