Пример #1
0
        //I know this code is not fantastic, just messing around with Mongo
        private void btnAddUser_Click(object sender, RoutedEventArgs e)
        {
            var user = new User();

            user.username = txtUsername.Text;
            user.firstName = txtFirstName.Text;
            user.lastName = txtLastName.Text;
            user.dateAdded = DateTime.Now;
            user.lastUpdated = DateTime.Now;
            user.deleted = false;

            var returnedList = Database.InsertUsers(new List<User>() { user });
            refreshTimers();
        }
Пример #2
0
        private void btnAddMillionUsers_Click(object sender, RoutedEventArgs e)
        {
            var userList = new List<User>();

            for (var i = 0; i < 1000000; i++)
            {
                var newUser = new User()
                {
                    username = "******" + i.ToString(),
                    firstName = "Frank" + i.ToString(),
                    lastName = "Bob" + i.ToString(),
                    dateAdded = DateTime.Now,
                    lastUpdated = DateTime.Now,
                    deleted = false
                };

                userList.Add(newUser);
            }

            var returnedList = Database.InsertUsers(userList);
            refreshTimers();
        }
Пример #3
0
        private void btnUpdateUser_Click(object sender, RoutedEventArgs e)
        {
            if (lstUserResults.SelectedIndex > -1)
            {
                var listItem = (ListBoxItem)lstUserResults.Items[lstUserResults.SelectedIndex];

                var updatedUser = new User()
                {
                    username = txtUpdateUserUsername.Text,
                    firstName = txtUpdateUserFirstName.Text,
                    lastName = txtUpdateUserLastName.Text,
                    Id = (ObjectId)listItem.Value,
                    deleted = chkDeleted.IsChecked
                };

                var updatedUsers = Database.UpdateUsers(new List<User>() { updatedUser });
                refreshTimers();
            }
        }