Beispiel #1
0
        internal static async Task <User> CreateUser(IWimdioApiClient client)
        {
            var user = new NewUser
            {
                Password    = "******",
                FirstName   = "FirstName",
                LastName    = "LastName",
                Email       = $"dummy+{Guid.NewGuid().ToString().Split('-').First()}@email.com",
                Permissions = Permission.Read | Permission.Update
            };

            return(await client.CreateUser(user));
        }
Beispiel #2
0
        private async void btnSave_Click(object sender, EventArgs e)
        {
            Permission permissions = 0;

            for (var i = 0; i < clbPermissions.Items.Count; i++)
            {
                var permission = clbPermissions.GetSelected(i)
                               ? (Permission)Enum.Parse(typeof(Permission), clbPermissions.Items[i].ToString(), true)
                               : 0;
                permissions |= permission;
            }

            var newUser = new NewUser
            {
                Email       = txtUserEmail.Text,
                Password    = txtUserPassword.Text,
                FirstName   = txtFirstname.Text,
                LastName    = txtLastname.Text,
                Permissions = permissions
            };

            try
            {
                var user = await ApiClient.CreateUser(newUser);

                await UpdateUserList(true);

                if (user == null)
                {
                    throw new Exception("No error returned, but user has not been created");
                }

                lbxUsers.SelectedValue = user?.Id;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }