예제 #1
0
        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);
예제 #2
0
 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);
예제 #3
0
 public UserBetForAwayTeam(MatchAwayBetInput input, Guid userId)
 {
     MatchId = input.MatchId;
     UserId  = userId;
     AwayBet = input.AwayBet;
 }