public async Task <ActionResult <List <GroupHistoryEntryResponse> > > PostCreateGroupHistoryLogAsync( [FromServices] NaheulbookExecutionContext executionContext, [FromRoute] int groupId, PostCreateGroupHistoryEntryRequest request ) { try { await _groupService.AddHistoryEntryAsync(executionContext, groupId, request); return(NoContent()); } catch (ForbiddenAccessException ex) { throw new HttpErrorException(StatusCodes.Status403Forbidden, ex); } catch (GroupNotFoundException ex) { throw new HttpErrorException(StatusCodes.Status404NotFound, ex); } }
public async Task AddHistoryEntryAsync(NaheulbookExecutionContext executionContext, int groupId, PostCreateGroupHistoryEntryRequest request) { using (var uow = _unitOfWorkFactory.CreateUnitOfWork()) { var group = await uow.Groups.GetAsync(groupId); if (group == null) { throw new GroupNotFoundException(groupId); } _authorizationUtil.EnsureIsGroupOwner(executionContext, group); group.AddHistoryEntry(_groupHistoryUtil.CreateLogEventRp(group, request.IsGm, request.Info)); await uow.SaveChangesAsync(); } }