public bool CheckRole(string token, RolesEnum role) { var rolesRepository = new RolesRepository(); var id = rolesRepository.FindByName(role.ToString()).Id; var decodedToken = Decode(token); var tokenId = int.Parse(decodedToken["role"].ToString()); return(id == tokenId); }
public IHttpActionResult FindByName(string id) { try { var role = _rolesRepository.FindByName(id); return(Ok(role)); } catch (Exception e) { return(BadRequest(e.Message)); } }