/// <inheritdoc/> public async Task RemovePersonFromWorkshop(RemovePersonFromWorkshopCommand 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)) { await _workshopRepository.DecreaseAttendance(workshop.Id); } await _attendanceRepository.RemovePersonFromWorkshop(command.WorkshopId, command.PersonId); }
public async Task <IActionResult> RemovePersonFromWorkshop(RemovePersonFromWorkshopCommand command) { await _attendanceService.RemovePersonFromWorkshop(command); return(NoContent()); }