Exemple #1
0
    public async Task <IActionResult> CreateAccount([FromBody] CreateUserInfo info)
    {
        logger.LogInformation("Create Attempt: " + info.username);
        AuthenticationResult result = await authentication.CreateAccount(info.username, info.password);

        return(Result(result));
    }
Exemple #2
0
        private void addUserMenuItem_Click(object sender, RoutedEventArgs e)
        {
            // Create new user information
            CreateUserInfo newUserInfo = new CreateUserInfo();

            // Instantiate the dialog box
            CreateUserDialog dlg = new CreateUserDialog();

            // Configure the dialog box
            dlg.Owner            = this;
            dlg.DataContext      = newUserInfo;
            newUserInfo.Username = "";

            // Open the dialog box modally
            dlg.ShowDialog();

            // Process data entered by user if dialog box is accepted
            if (dlg.DialogResult == true)
            {
                // Try to add this new user to the database
                if (userDataModel.AddNewUser(newUserInfo))
                {
                }
                else
                {
                }
            }
        }
Exemple #3
0
        public async Task <IActionResult> AddUser([FromBody] CreateUserInfo vm)
        {
            var user = new User
            {
                UserId     = Guid.NewGuid().ToString(),
                UserName   = vm.UserName,
                Password   = vm.Password,
                FirstName  = vm.FirstName,
                MiddleName = vm.MiddleName,
                LastName   = vm.LastName,
                Email      = vm.Email,
                Phone      = vm.Phone,
                Mobile     = vm.Mobile
            };

            var userRole = new UserRole
            {
                UserId = user.UserId,
                RoleId = vm.RoleId
            };


            await _appDbContext.AddRangeAsync(user, userRole);

            await _appDbContext.SaveChangesAsync();

            return(Ok());
        }
        CreateUserInfo NewCreateUserInfo()
        {
            var info = new CreateUserInfo();

            info.FirstName = FirstName;
            info.LastName  = LastName;

            info.Username = Username;
            info.Password = password_TXT.PasswordText;

            info.Company = Company;

            info.Email = Email;
            info.Phone = Phone;

            info.Address1 = Address1;
            info.Address2 = Address2;
            info.City     = City;

            if (country_COMBO.SelectedItem != null)
            {
                info.Country = country_COMBO.SelectedItem.ToString();
            }
            if (state_COMBO.SelectedItem != null)
            {
                info.State = state_COMBO.SelectedItem.ToString();
            }

            info.Zipcode = ZipCode;

            return(info);
        }
Exemple #5
0
        public async Task <Result <UserDto> > Handle(CreateUserInfo request, CancellationToken cancellationToken)
        {
            var openIdUser = await _currentUser.GetOpenIdUser();

            if (openIdUser.IsFailed)
            {
                return(Result <UserDto> .Error(openIdUser.Errors.FirstOrDefault()));
            }

            var user = await _userRepository.CreateAsync(User.Create(openIdUser.Value));

            return(user == null ? Result <UserDto> .Error("Failed to create user") : Result <UserDto> .Success(_mapper.Map <UserDto>(user)));
        }
Exemple #6
0
        /// <summary>
        /// Lorsqu'on veut s'enregistrer.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;

            string sErreurs = "";

            // Vérifications de bases...
            if (txtUtilisateur.Text.Trim().Length < 3)
            {
                sErreurs += "-Le nom d'utilisateur doit être minimalement 3 caractères de long.\n";
            }

            if (txtPasse.Password.Trim().Length < 3)
            {
                sErreurs += "-Le mot de passe doit être minimalement 3 caractères de long.\n";
            }

            if (txtEmail.Text.Trim().Length < 7)
            {
                sErreurs += "-L'adresse email est invalide :^(\n";
            }

            using (var svcClient = new UserServiceClient())
            {
                CreateUserInfo cui = new CreateUserInfo();
                cui.Email    = txtEmail.Text;
                cui.Password = txtPasse.Password;
                cui.Username = txtUtilisateur.Text;

                bool ok = svcClient.CreateUser(cui);

                if (!ok)
                {
                    sErreurs += "-Utilisateur existant ou email déjà en utilisation.\n" +
                                "-Serveur peut-être hors-ligne?";
                }
            }

            if (sErreurs.Length > 0)
            {
                MessageBox.Show(sErreurs, "Erreur");
                IsEnabled = true;
                return;
            }
            else
            {
                MessageBox.Show("Inscription réussie! vous pouvez désormais vous connecter.");
                Close();
            }
        }
        void CreateUser_GUI(UpdateUser_Return result, CreateUserInfo createInfo)
        {
            if (result.Info != null)
            {
                if (mw != null)
                {
                    mw.Login(createInfo.Username, createInfo.Password);
                }
            }
            else
            {
                TrakHound_UI.MessageBox.Show("Error during User Creation! Try Again.");
            }

            Saving = false;
        }
 //方法
 public DepartInformation(string orgName, string orgCode, long orgParentcode, string orgType, string unitId,
                          string unionType, string orgPath, string orgSequence, string orgLevel, string orgGlobalNo,
                          long parentId, CreateUserInfo createUserInfo, DepartInformation departInformation)
 {
     this.orgName           = orgName ?? throw new ArgumentNullException(nameof(orgName));
     this.orgCode           = orgCode ?? throw new ArgumentNullException(nameof(orgCode));
     this.orgParentcode     = orgParentcode;
     this.orgType           = orgType ?? throw new ArgumentNullException(nameof(orgType));
     this.unitId            = unitId ?? throw new ArgumentNullException(nameof(unitId));
     this.unionType         = unionType ?? throw new ArgumentNullException(nameof(unionType));
     this.orgPath           = orgPath ?? throw new ArgumentNullException(nameof(orgPath));
     this.orgSequence       = orgSequence ?? throw new ArgumentNullException(nameof(orgSequence));
     this.orgLevel          = orgLevel ?? throw new ArgumentNullException(nameof(orgLevel));
     this.orgGlobalNo       = orgGlobalNo ?? throw new ArgumentNullException(nameof(orgGlobalNo));
     _departparentId        = parentId;
     this.createUserInfo    = createUserInfo ?? throw new ArgumentNullException(nameof(createUserInfo));
     this.departInformation = departInformation ?? throw new ArgumentNullException(nameof(departInformation));
 }
        /// <summary>
        ///  添加用户全部信息
        /// </summary>
        public UserInformation(string userId, string UserPwd, string Gender, DateTime Birthdate, string UserName,
                               string PhoneCall, string MobileCall, string Email, CreateUserInfo CreateInfo, Address address)
        {
            this.userId         = userId;
            this.userName       = UserName;
            this.userPwd        = UserPwd;
            this.gender         = Gender;
            this.birthdate      = Birthdate;
            this.phoneCall      = PhoneCall;
            this.mobileCall     = MobileCall;
            this.email          = Email;
            this.createUserInfo = CreateInfo;
            this.updateTime     = DateTime.Now;
            this.createtime     = DateTime.Now;
            this.userStatusId   = UserStatus.Activated.Id;

            this.address = address;
        }
        /// <summary>
        /// Lorsqu'on veut s'enregistrer.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            IsEnabled = false;

            string sErreurs = "";

            // Vérifications de bases...
            if (txtUtilisateur.Text.Trim().Length < 3)
                sErreurs += "-Le nom d'utilisateur doit être minimalement 3 caractères de long.\n";

            if (txtPasse.Password.Trim().Length < 3)
                sErreurs += "-Le mot de passe doit être minimalement 3 caractères de long.\n";

            if (txtEmail.Text.Trim().Length < 7)
                sErreurs += "-L'adresse email est invalide :^(\n";

            using (var svcClient = new UserServiceClient())
            {
                CreateUserInfo cui = new CreateUserInfo();
                cui.Email = txtEmail.Text;
                cui.Password = txtPasse.Password;
                cui.Username = txtUtilisateur.Text;

                bool ok = svcClient.CreateUser(cui);

                if (!ok)
                    sErreurs += "-Utilisateur existant ou email déjà en utilisation.\n" +
                                "-Serveur peut-être hors-ligne?";
            }

            if (sErreurs.Length > 0)
            {
                MessageBox.Show(sErreurs, "Erreur");
                IsEnabled = true;
                return;
            }
            else
            {
                MessageBox.Show("Inscription réussie! vous pouvez désormais vous connecter.");
                Close();
            }
        }
        void CreateUser(CreateUserInfo info)
        {
            Saving = true;

            ThreadPool.QueueUserWorkItem(new WaitCallback(CreateUser_Worker), info);
        }