public async Task BetForAwayTeamShouldReturnProperHypermediaLinks( Fixture fixture, Team homeTeam, Team awayTeam) => await _apiHelper.InTheContextOfAnAuthenticatedUser( async client => { // Arrange var currentMatch = await _matchTestHelper .RegistrateMatchAsync(fixture, homeTeam, awayTeam); var httpRequest = new MatchAwayBetInput { MatchId = currentMatch.Id, AwayBet = fixture.Create <decimal>(), }; // Act var response = await client.PostAsJsonAsync("/bets/away-team", httpRequest); // Assert var expectedLinks = new List <string> { LinkNames.Self }; await response.ShouldBeAResource <UserMatchBetResource>(expectedLinks); }, fixture);
public async Task <IActionResult> BetForAwayTeam([FromBody] MatchAwayBetInput input) => (await Mediator.Send(new UserBetForAwayTeam(input, CurrentUserId)) .MapAsync(_ => ToEmptyResourceAsync <UserMatchBetResource>())) .Match(resource => CreatedAtAction(nameof(BetForAwayTeam), resource), Error);
public UserBetForAwayTeam(MatchAwayBetInput input, Guid userId) { MatchId = input.MatchId; UserId = userId; AwayBet = input.AwayBet; }