/// <inheritdoc/> public async Task <long> AddPersonToWorkshop(AddPersonToWorkshopCommand command) { var person = _peopleRepository.GetPerson(command.PersonId); var workshop = _workshopRepository.GetWorkshop(command.WorkshopId); if (person == null || workshop == null) { throw new NotFoundException(); } else if ((person.CreatedBy != _userInfo.UserId || workshop.CreatedBy != _userInfo.UserId) && !_userInfo.IsAdmin) { throw new ResourceIsForbiddenException(); } var attendees = GetWorkshopAttendees(new GetWorkshopAttendeesQuery(command.WorkshopId)); if (attendees.Any(a => a.Id == command.PersonId)) { throw new RequestConflictException(); } await _workshopRepository.IncreaseAttendance(workshop.Id); return(await _attendanceRepository.AddPersonToWorkshop(command.WorkshopId, command.PersonId)); }