コード例 #1
0
        public async Task PostCreateType_CallEffectService()
        {
            var createEffectTypeRequest = new CreateEffectTypeRequest();
            var effectType         = new EffectType();
            var effectTypeResponse = new EffectTypeResponse();

            _effectService.CreateEffectTypeAsync(_executionContext, createEffectTypeRequest)
            .Returns(effectType);
            _mapper.Map <EffectTypeResponse>(effectType)
            .Returns(effectTypeResponse);

            var result = await _effectTypesController.PostCreateTypeAsync(_executionContext, createEffectTypeRequest);

            result.StatusCode.Should().Be(201);
            result.Value.Should().Be(effectTypeResponse);
        }
コード例 #2
0
        public async Task <JsonResult> PostCreateTypeAsync(
            [FromServices] NaheulbookExecutionContext executionContext,
            CreateEffectTypeRequest request
            )
        {
            try
            {
                var effectType = await _effectService.CreateEffectTypeAsync(executionContext, request);

                return(new JsonResult(_mapper.Map <EffectTypeResponse>(effectType))
                {
                    StatusCode = 201
                });
            }
            catch (ForbiddenAccessException ex)
            {
                throw new HttpErrorException(StatusCodes.Status403Forbidden, ex);
            }
        }