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)); }
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); }
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); }
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)); }