Пример #1
0
        public async Task BetForHomeTeamShouldReturnProperHypermediaLinks(
            Fixture fixture,
            Team homeTeam,
            Team awayTeam) =>
        await _apiHelper.InTheContextOfAnAuthenticatedUser(
            async client =>
        {
            // Arrange
            var currentMatch = await _matchTestHelper.RegistrateMatchAsync(fixture, homeTeam, awayTeam);

            var httpRequest = new MatchHomeBetInput
            {
                MatchId = currentMatch.Id,
                HomeBet = fixture.Create <decimal>(),
            };

            // Act
            var response = await client.PostAsJsonAsync("/bets/home-team", httpRequest);

            // Assert
            var expectedLinks = new List <string>
            {
                LinkNames.Self
            };

            await response.ShouldBeAResource <UserMatchBetResource>(expectedLinks);
        }, fixture);
Пример #2
0
 public async Task <IActionResult> BetForHomeTeam([FromBody] MatchHomeBetInput input) =>
 (await Mediator.Send(new UserBetForHomeTeam(input, CurrentUserId))
  .MapAsync(_ => ToEmptyResourceAsync <UserMatchBetResource>()))
 .Match(resource => CreatedAtAction(nameof(BetForHomeTeam), resource), Error);
 public UserBetForHomeTeam(MatchHomeBetInput input, Guid userId)
 {
     HomeBet = input.HomeBet;
     UserId  = userId;
     MatchId = input.MatchId;
 }