public async Task <CreatedActionResult <MonsterSubCategoryResponse> > PostCreateMonsterSubCategoryAsync( [FromServices] NaheulbookExecutionContext executionContext, [FromRoute] int monsterTypeId, CreateMonsterSubCategoryRequest request ) { try { var monsterSubCategory = await _monsterTypeService.CreateMonsterSubCategoryAsync(executionContext, monsterTypeId, request); return(_mapper.Map <MonsterSubCategoryResponse>(monsterSubCategory)); } catch (ForbiddenAccessException ex) { throw new HttpErrorException(StatusCodes.Status403Forbidden, ex); } }
public async Task <MonsterSubCategory> CreateMonsterSubCategoryAsync( NaheulbookExecutionContext executionContext, int monsterTypeId, CreateMonsterSubCategoryRequest request ) { await _authorizationUtil.EnsureAdminAccessAsync(executionContext); using (var uow = _unitOfWorkFactory.CreateUnitOfWork()) { var monsterSubCategory = new MonsterSubCategory { Name = request.Name, TypeId = monsterTypeId }; uow.MonsterSubCategories.Add(monsterSubCategory); await uow.SaveChangesAsync(); return(monsterSubCategory); } }