Exemplo n.º 1
0
        public async Task <ActionResult <string> > UpdateRole([FromBody] JObject jObject)
        {
            string username = jObject["username"].Value <string>();
            string role     = jObject["role"].Value <string>();

            if (role is not Role.Admin && role is not Role.User)
            {
                return(BadRequest("NOT DONE: Role does not exist"));
            }

            return(await _dataAccess.ChangeRole(username, role)
                ? Ok("DONE")
                : (ActionResult <string>)BadRequest("NOT DONE: Username does not exist"));
        }