public async Task <IActionResult> FillAllGames([FromBody] Match[] MatchsData) { if (await _forecastService.FillAllGames(MatchsData)) { int userId = User.GetClaim <int>(ClaimType.Id); string userMail = User.GetClaim <string>(ClaimType.Mail); string TeamName = User.GetClaim <string>(ClaimType.TeamName); //Send mails if needed string resul = User.GetClaim <string>(ClaimType.ReceiveMails); ImmutableArray <Matchs> m; if (resul != null || resul == "1") { //send mail m = await _forecastService.GetUserMatchs(userId); await _mailService.SendMyResultsAsync(userMail, TeamName, m); } var isAdmin = (await _authorizationService.AuthorizeAsync(User, ProdePolicy.IsAdmin)).Succeeded; if (isAdmin) { if (m == null) { m = await _forecastService.GetUserMatchs(userId); } var to = await _userService.GetMailsFromAdminForecastReceivers(); //send mail to users await _mailService.SendAdminResultsAsync(to, TeamName, m); } return(new OkObjectResult(true)); } return(BadRequest()); }