public async Task <IActionResult> Delete(int matchId) { //Get header token if (Request.Headers.TryGetValue("Authorization", out StringValues headerValues) && matchId > -1) { var token = _customEncoder.DecodeBearerAuth(headerValues.First()); if (token != null) { var user = await _userService.GetUserAsyncByToken(token); if (user != null) { //Verify if the token exist and is not expire if (await _authenticationService.CheckIfTokenIsValidAsync(token)) { //Verify if messages for this userId exist var isDeleted = await _matchService.DeleteAsyncMatch(matchId); if (isDeleted == false) { return(StatusCode(404, "Unable to delete match.")); } return(StatusCode(204, "The match has been deleted.")); } return(StatusCode(401, "Invalid Token.")); } return(StatusCode(401, "Invalid Token.")); } return(StatusCode(401, "Invalid Authorization.")); } return(StatusCode(401, "Invalid Authorization.")); }
public async Task <IActionResult> DeleteMatch(int id) { await _matchService.DeleteAsyncMatch(id); return(NoContent()); }