Example #1
0
        //[Authorize(Roles = "Admin")]
        public IActionResult PromoteUser(string userName, int roleId)
        {
            IActionResult result = Unauthorized();

            try
            {
                if (roleId < 4 && roleId > 0)
                {
                    _db.UpdateUserRole(_db.GetUserItemByLogin(userName), roleId);
                }
                result = Ok();
            }
            catch (Exception)
            {
                result = BadRequest(new { Message = "Role update failed." });
            }
            return(result);
        }