Exemplo n.º 1
0
        public async Task <IActionResult> SetElapsedTimeAsync([FromRoute] int attendeeId, [FromBody] long seconds)
        {
            if (!await IsAttendeeValid(attendeeId))
            {
                return(NotFound());
            }

            await _testConductRepository.SetElapsedTimeAsync(attendeeId, seconds, false);

            return(Ok(attendeeId));
        }
Exemplo n.º 2
0
        public async Task SetElapsedTimeAsyncTest()
        {
            var testAttendee = InitializeTestAttendeeParameters();

            await CreateTestAsync();

            await _testConductRepository.RegisterTestAttendeesAsync(testAttendee);

            var attendeeId = await _trappistDbContext.TestAttendees.OrderBy(x => x.Email).Where(x => x.Email.Equals(testAttendee.Email)).Select(x => x.Id).FirstOrDefaultAsync();

            //New entry to AttendeeAnswer table will be made since no answer is saved
            await _testConductRepository.SetElapsedTimeAsync(attendeeId, 10, false);

            //AttendeeAnswer entry will be updated with elapsed time
            await _testConductRepository.SetElapsedTimeAsync(attendeeId, 12, false);

            var attendeeAnswer = await _trappistDbContext.AttendeeAnswers.FindAsync(attendeeId);

            Assert.NotNull(attendeeAnswer.TimeElapsed);
        }
Exemplo n.º 3
0
        public async override Task OnDisconnectedAsync(Exception exception)
        {
            string connectionId = Context.ConnectionId;

            Attendees.TryGetValue(connectionId, out Attendee attendee);
            if (attendee.IsAttendeeReset)
            {
                var currentDate = DateTime.UtcNow;
                Console.Write(currentDate);
                var totalSeconds = (currentDate - attendee.StartDate).TotalSeconds;
                var sec          = (long)totalSeconds;
                await _testConductRepository.SetElapsedTimeAsync(attendee.AttendeeId, sec, true);
            }

            await base.OnDisconnectedAsync(exception);
        }