public async Task <IActionResult> GrantRoleAsync([FromRoute] string guildId, RoleActionDto roleActionDto) { await _botService.GrantRoleAsync( guildId, roleActionDto.UserId, roleActionDto.RoleId, await _userManager.GetUserAsync(User) ); return(Ok()); }
public IHttpActionResult RoleAction(RoleActionDto roleActionDto) { string[] temp = roleActionDto.RoleAction.Split(' '); var actionid = temp[1]; var roleid = temp[0]; if (!_dbContext.RoleActions.Any(a => a.ActionId == actionid && a.RoleId == roleid)) { return(BadRequest("Không có action")); } var roleaction = new RoleAction { ActionId = actionid, RoleId = roleid }; _dbContext.RoleActions.Attach(roleaction); _dbContext.Entry(roleaction).State = EntityState.Deleted; _dbContext.SaveChanges(); return(Ok()); }
public async Task <IActionResult> RevokeRoleAsync([FromRoute] string guildId, RoleActionDto roleActionDto) { await _botService.RevokeRoleAsync( guildId, roleActionDto.UserId, roleActionDto.RoleId, await _userManager.GetUserAsync(User), roleActionDto.Reason ?? "No reason specified." ); return(Ok()); }