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); }
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); } }
public Task <EffectTypeResponse> CreateEffectTypeAsync(CreateEffectTypeRequest request, string jwt) { return(_naheulbookHttpClient.PostAndParseJsonResultAsync <EffectTypeResponse>("/api/v2/effectTypes", request, jwt)); }
public async Task <EffectType> CreateEffectTypeAsync(NaheulbookExecutionContext executionContext, CreateEffectTypeRequest request) { await _authorizationUtil.EnsureAdminAccessAsync(executionContext); var effectType = new EffectType { Name = request.Name }; using (var uow = _unitOfWorkFactory.CreateUnitOfWork()) { uow.EffectTypes.Add(effectType); await uow.SaveChangesAsync(); } return(effectType); }