Example #1
0
        public async Task <IActionResult> CompleteCheckInAsync(ConferenceDialogResult model)
        {
            var context = await ValidateAndReturnContextAsync(model);

            if (context.Result != null)
            {
                return(context.Result);
            }

            await _auditEventLog.AddAsync(new ApplicationCore.Models.AuditEvent
            {
                Time     = DateTime.UtcNow,
                TicketId = model.TicketId,
                Action   = EventManagementConstants.Auditing.Actions.TicketValidated,
                Detail   = $"Check-in war erfolgreich."
            });

            context.Ticket.Validated = true;
            _db.SaveChanges();
            return(Ok());
        }
Example #2
0
        public async Task <IActionResult> SetTermsAcceptedAsync(ConferenceDialogResult model)
        {
            var context = await ValidateAndReturnContextAsync(model);

            if (context.Result != null)
            {
                return(context.Result);
            }

            await _auditEventLog.AddAsync(new ApplicationCore.Models.AuditEvent
            {
                Time     = DateTime.UtcNow,
                TicketId = model.TicketId,
                Action   = EventManagementConstants.Auditing.Actions.TermsAccepted,
                Detail   = "Die Einverständniserklärung der Eltern wurde beim Check-in abgegeben."
            });

            context.Ticket.TermsAccepted = true;
            _db.SaveChanges();
            return(Ok());
        }
Example #3
0
        private async Task <DialogContext> ValidateAndReturnContextAsync(ConferenceDialogResult model)
        {
            var context = new DialogContext
            {
                User = await TryGetAuthenticatedUser()
            };

            // TODO: check if the user has the permission for the event.
            if (!context.User.Identity.IsAuthenticated)
            {
                context.Result = Unauthorized();
                return(context);
            }
            context.Ticket = await _db.Tickets.FindAsync(model.TicketId);

            if (context.Ticket == null)
            {
                ModelState.AddModelError(
                    nameof(model.TicketId), "Ticket not found in database.");
                context.Result = BadRequest();
                return(context);
            }
            return(context);
        }