public async Task <IActionResult> AddAttendanceAsync(int eventId, string attendeeId) { var evnt = _eventService.GetEvent(eventId); if (evnt == null) { return(NotFound()); } var authResult = await _authorizationService.AuthorizeAsync(User, evnt, Policy.CanManageAttendance); if (!authResult.Succeeded) { return(Forbid()); } var attendance = _eventService.GetAttendance(eventId, attendeeId); if (attendance != null) { return(BadRequest()); } _eventService.AddAttendance(new Attendance { EventId = eventId, AttendeeId = attendeeId }); _eventService.SaveChanges(); _logger.LogInformation("{user} added attendee {attendee} to event {event}", User.Identity.Name, attendeeId, eventId); return(Ok()); }