public async Task PutEditEffect_CallEffectService() { var editEffectRequest = new EditEffectRequest(); var expectedEffectResponse = new EffectResponse(); var effect = new Effect { Id = 42 }; _effectService.EditEffectAsync(_executionContext, 42, editEffectRequest) .Returns(effect); _mapper.Map <EffectResponse>(effect) .Returns(expectedEffectResponse); var result = await _effectsController.PutEditEffectAsync(_executionContext, 42, editEffectRequest); result.Value.Should().Be(expectedEffectResponse); await _effectService.Received(1) .EditEffectAsync(_executionContext, 42, editEffectRequest); }
public async Task <ActionResult <EffectResponse> > PutEditEffectAsync( [FromServices] NaheulbookExecutionContext executionContext, [FromRoute] int effectId, EditEffectRequest request ) { try { var effect = await _effectService.EditEffectAsync(executionContext, effectId, request); var effectResponse = _mapper.Map <EffectResponse>(effect); return(effectResponse); } catch (ForbiddenAccessException ex) { throw new HttpErrorException(StatusCodes.Status403Forbidden, ex); } catch (EffectNotFoundException ex) { throw new HttpErrorException(StatusCodes.Status404NotFound, ex); } }