public async Task <ActionResult> PostGameGuilds(int gameId, int guildId) { var email = HttpContext.User.Claims.First(e => e.Type == "Email").Value; var user = await _userManager.FindByEmailAsync(email); var roles = await _userManager.GetRolesAsync(user); if (await _games.VerifyManager(user.Id, gameId) || roles.Contains("Administrator")) { await _games.AddGameGuild(gameId, guildId); return(Ok()); } return(BadRequest("Manager does not have access")); }
public async Task <ActionResult <GuildsDTO> > PostGuilds(GuildsDTO guilds, int gameId) { var email = HttpContext.User.Claims.First(e => e.Type == "Email").Value; var user = await _userManager.FindByEmailAsync(email); var roles = await _userManager.GetRolesAsync(user); if (await _guilds.VerifyManager(user.Id, gameId) || roles.Contains("Administrator")) { await _guilds.Create(guilds); await _games.AddGameGuild(gameId, guilds.Id); return(CreatedAtAction("GetGuilds", new { id = guilds.Id }, guilds)); } return(BadRequest("Manager does not have access")); }