Exemplo n.º 1
0
 internal Permissions(User.UserRoles CurrentRole, Content.Folder CurrentFolder)
 {
     _userRole = CurrentRole;
     _folder = CurrentFolder;
     string SystemMessage = string.Empty;
     Load();
 }
Exemplo n.º 2
0
        public IHttpActionResult ChangeUserRoleForUser(int id, User.UserRoles role)
        {
            User userModel = userService.UpdateUserRole(id, role);

            if (userModel == null)
            {
                return(NotFound());
            }

            return(Ok(userModel));
        }
Exemplo n.º 3
0
        public User UpdateUserRole(int id, User.UserRoles newRole)
        {
            User user = db.UsersRepository.GetByID(id);

            if (user != null)
            {
                user.user_role = newRole;
                db.UsersRepository.Update(user);
                db.Save();
            }

            return(user);
        }
Exemplo n.º 4
0
        public IHttpActionResult ChangeUserRoleForUser(int id, User.UserRoles role)
        {
            User userModel = db.UsersRepository.GetByID(id);

            if (userModel == null)
            {
                return(NotFound());
            }

            userModel.user_role = role;
            db.Save();

            return(Ok(userModel));

            // return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 5
0
        public IHttpActionResult PutUserModel(int id, User userModel)
        {
            if (!ModelState.IsValid)
            {
                Debug.WriteLine("Invalid ModelState at PutUserModel");
                return(BadRequest(ModelState));
            }

            if (id != userModel.id)
            {
                Debug.WriteLine("Invalid ModelState at PutUserModel, id not found...! OK, we are using some other sutf");
                return(BadRequest());
            }

            // Simply for trying out why my commits do not show up....

            // ZAHTEV: ne menjati user_role ni password
            User savedUser = db.UsersRepository.GetByID(id);

            string savedPassword = db.UsersRepository.GetByID(id).password;

            User.UserRoles savedRole = db.UsersRepository.GetByID(id).user_role;
            // Let's try this one out
            userModel.password  = savedPassword;
            userModel.user_role = savedRole;

            // lets try brute force...
            savedUser.first_name = userModel.first_name;
            savedUser.last_name  = userModel.last_name;
            savedUser.email      = userModel.email;
            savedUser.username   = userModel.username;

            // savedUser = userModel;
            // db.UserRepository.Update(userModel);
            db.UsersRepository.Update(savedUser);
            db.Save();

            return(StatusCode(HttpStatusCode.NoContent));
        }