public void Create(CcmUser user, string password, bool currentUserIsLocalAdmin = false) { if (_radiusUserRepository.UserExists(user.UserName)) { log.Warn("Can't create user. Username {0} already exists in RADIUS database", user.UserName); throw new ApplicationException("Användarnamnet finns redan i RADIUS databas."); } if (_userRepository.FindByUserName(user.UserName) != null) { log.Warn("Can't create user. Username {0} already exists in CCM database", user.UserName); throw new ApplicationException("Användarnamnet finns redan i CCMs databas."); } log.Debug("Creating user in radius."); user.RadiusId = _radiusUserRepository.CreateUser(user.UserName, password, user.UserType); if (user.RadiusId <= 0) { throw new ApplicationException("Användaren kunde inte skapas i RADIUS."); } log.Debug("Creating user in ccm db"); _userRepository.Create(user, currentUserIsLocalAdmin); }