public ActionResult TransferAllowance(GetTransferAllowanceQuery query) { var response = Task.Run(() => _mediator.SendAsync(query)).GetAwaiter().GetResult(); var model = _mapper.Map <TransferAllowanceViewModel>(response); return(PartialView(model)); }
public async Task Handle(long?accountId) { var query = new GetTransferAllowanceQuery { AccountId = accountId }; var handler = CreateHandler(); try { Response = await handler.Handle(query); } catch (Exception e) { HandlerException = e; } }
public void Arrange() { _configuration = new EmployerFinanceConfiguration { TransferAllowancePercentage = .25m }; _transferAllowance = new TransferAllowance { RemainingTransferAllowance = 123.456m, StartingTransferAllowance = 234.56M, }; _query = new GetTransferAllowanceQuery(); _response = new GetTransferAllowanceResponse { TransferAllowance = _transferAllowance, TransferAllowancePercentage = _configuration.TransferAllowancePercentage }; _mapperConfig = new MapperConfiguration(c => c.AddProfile <TransferMappings>()); _mapper = _mapperConfig.CreateMapper(); _mediator = new Mock <IMediator>(); _mediator.Setup(m => m.SendAsync(_query)).ReturnsAsync(_response); _controller = new TransfersController(null, _mapper, _mediator.Object); }