public async Task <CreatedActionResult <EffectSubCategoryResponse> > PostCreateEffectSubCategoryAsync( [FromServices] NaheulbookExecutionContext executionContext, CreateEffectSubCategoryRequest request ) { try { var effectSubCategory = await _effectService.CreateEffectSubCategoryAsync(executionContext, request); return(_mapper.Map <EffectSubCategoryResponse>(effectSubCategory)); } catch (ForbiddenAccessException ex) { throw new HttpErrorException(StatusCodes.Status403Forbidden, ex); } }
public Task <EffectSubCategoryResponse> CreateEffectSubCategoryAsync(CreateEffectSubCategoryRequest request, string jwt) { return(_naheulbookHttpClient.PostAndParseJsonResultAsync <EffectSubCategoryResponse>("/api/v2/effectSubCategories", request, jwt)); }
public async Task <EffectSubCategory> CreateEffectSubCategoryAsync(NaheulbookExecutionContext executionContext, CreateEffectSubCategoryRequest request) { await _authorizationUtil.EnsureAdminAccessAsync(executionContext); var effectSubCategory = new EffectSubCategory { Name = request.Name, TypeId = request.TypeId, DiceSize = request.DiceSize, DiceCount = request.DiceCount, Note = request.Note, Effects = new List <Effect>() }; using (var uow = _unitOfWorkFactory.CreateUnitOfWork()) { uow.EffectSubCategories.Add(effectSubCategory); await uow.SaveChangesAsync(); } return(effectSubCategory); }