Exemplo n.º 1
0
        public async Task <IActionResult> DeclineInvite([FromBody] DeclineInviteRequest request)
        {
            var currentUser = await _userManager.FindByNameAsync(User.Identity.Name);

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var league = await _fantasyCriticService.GetLeagueByID(request.LeagueID);

            if (league.HasNoValue)
            {
                return(BadRequest());
            }

            Result result = await _fantasyCriticService.DeclineInvite(league.Value, currentUser);

            if (result.IsFailure)
            {
                return(BadRequest(result.Error));
            }

            return(Ok());
        }