private void addRuleButton_Click(object sender, RoutedEventArgs e) { EntryDTO entry = new EntryDTO(); entry.ParagraphNumber = paragraphNumberTextBox.Text; entry.Headline = headlineTextBox.Text; entry.Text = ruleTextBox.Text; entry.Revision = revisionTextBox.Text; entry.Editor = editorTextBox.Text; entry.TOC = tocListId; //add the new rule. var response = comElements.post("Entry", entry); if (response.StatusCode == HttpStatusCode.Created) { MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("Rule has been added", "Rule Created", buttons); } else { MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("Rule has not been added", "Server incident", buttons); } this.Close(); }
private void btnCreateUser_ClickAsync(object sender, RoutedEventArgs e) { //if the password confirmation is OK if (checkIfPasswordAlike()) { string userName = this.txtBoxUserName.Text; //Start process by asking the backend if the username already exists. CommunicationElements comElements = new CommunicationElements(); // make the Http request and recieve the reponse. var response = comElements.get("User", "UserName="******""); // if username already exists if (response.StatusCode == System.Net.HttpStatusCode.Found) { //give message to user and make him try again with another username. this.txtBoxUserName.Text = ""; MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("Username is already in use. Try another username", "Username already in use", buttons, MessageBoxIcon.Warning); this.txtBoxUserName.Focus(); } else { //If username is not in use create a new UserDTO object UserDTO user = new UserDTO(); user.FirstName = this.txtBoxFirstName.Text; user.MiddleName = this.txtBoxMiddleName.Text; user.LastName = this.txtBoxLastName.Text; user.UserName = this.txtBoxUserName.Text; user.Password = this.pswBoxPassword.Password.ToString(); user.Date = DateTime.Now; response = comElements.post("User", user); if (response.StatusCode == HttpStatusCode.Created) { MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("User Created", "User Created", buttons); //Change to login window using MainWindowState singleton //Change menustate using MainWindowState singleton NavigationService.Navigate(null); MainWindowState.Instance.changePageInFrame(new Login()); MainWindowState.Instance.changeMenuState("login"); } else { MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("User not Created", "Database Incident", buttons); } } } }