예제 #1
0
        public void RemoveUser(User userToRemove)
        {
            User performingUser = SystemContext.SystemContext.CurrentUser;

            if (performingUser.PrivilegeLevel >= userToRemove.PrivilegeLevel)
            {
                throw new AccessDeniedException(string.Format(MSG_PRIVILEGE_VIOLATED, performingUser.Name, userToRemove.PrivilegeLevel));
            }

            SystemUserDAO.GetInstance().Delete(User2SystemUserTO.Map(userToRemove));
        }
예제 #2
0
        public override void ShowCustomMessage()
        {
            var user = new User();

            user.Name           = Helpers.PageHelper.GetValidInput <string>("Imie:");
            user.Password       = Helpers.PageHelper.GetValidInput <string>("Hasło:");
            user.PhoneNumber    = Helpers.PageHelper.GetValidInput <string>("Nr telefonu:");
            user.PrivilegeLevel = DefaultPrivileges.User;

            var userTO = User2SystemUserTO.Map(user);

            SystemUserDAO.GetInstance().Insert(userTO);
        }
예제 #3
0
        public void RegisterUser(User registeredUser)
        {
            User registratingUser = SystemContext.SystemContext.CurrentUser;

            if (registratingUser.PrivilegeLevel >= registeredUser.PrivilegeLevel)
            {
                throw new AccessDeniedException(string.Format(MSG_PRIVILEGE_VIOLATED, registratingUser.Name, registeredUser.PrivilegeLevel));
            }

            var registeredUserTO = User2SystemUserTO.Map(registeredUser);

            SystemUserDAO.GetInstance().Insert(registeredUserTO);
        }
예제 #4
0
        public void PromoteUser(User userToPromote, int newPrivilegeLevel)
        {
            User performingUser = SystemContext.SystemContext.CurrentUser;

            if (performingUser.PrivilegeLevel >= newPrivilegeLevel)
            {
                throw new AccessDeniedException(string.Format(MSG_PRIVILEGE_VIOLATED, performingUser.Name, newPrivilegeLevel - 1));
            }

            if (userToPromote.PrivilegeLevel >= newPrivilegeLevel)
            {
                throw new ArgumentOutOfRangeException("newPrivilegeLevel", string.Format("New privilege level ({0}) should be greater than current ({1})", newPrivilegeLevel, userToPromote.PrivilegeLevel));
            }

            userToPromote.PrivilegeLevel = newPrivilegeLevel;
            SystemUserDAO.GetInstance().Update(User2SystemUserTO.Map(userToPromote));
        }