private void Login_Click(object sender, RoutedEventArgs e) { ToggleError(null); string name = TextBox_Name.Text; string password = TextBox_Password.Password; try { AuthenticationModel authModel = NotesApi.GetAuthenticationModel(name, password); IRestResponse <UserDto> response = NotesApi.Execute <UserDto>("Authentication/Login", Method.POST, authModel); UserDto result = NotesApi.GetData(response); if (string.IsNullOrEmpty(result.Token)) { throw new Exception("Failed to login"); } UserAuthenticated?.Invoke(this, new AuthenticationEventArgs { User = result }); } catch (Exception x) { ToggleError(x.Message); } }
protected override void OnInitialized(EventArgs e) { try { NoteControls = new List <NoteFragment>(); List_Notes.ItemsSource = NoteControls; List <NoteDto> notes = NotesApi.GetData(NotesApi.Execute <List <NoteDto> >("Dashboard/Notes", RestSharp.Method.GET)); if (notes.Count() > 0) { foreach (NoteDto note in notes) { NoteFragment noteControl = new NoteFragment(note); noteControl.DataContext = noteControl; //noteControl.ToggleEdit(true); NoteControls.Add(noteControl); } List_Notes.Items.Refresh(); } } catch (Exception x) { ; } base.OnInitialized(e); }
private void UpdateNote() { Note.Title = TextBox_Title.Text; Note.Content = TextBox_Content.Text; NoteDto note = Note; note = NotesApi.GetData(NotesApi.Execute <NoteDto>("Dashboard/UpdateNote", RestSharp.Method.POST, note)); }
protected override void OnInitialized(EventArgs e) { try { List <NoteDto> notes = NotesApi.GetData(NotesApi.Execute <List <NoteDto> >("Dashboard/Notes", RestSharp.Method.GET)); if (notes.Count() > 0) { foreach (NoteDto note in notes) { NoteFragment noteControl = new NoteFragment(note); noteControl.DataContext = noteControl; //noteControl.ToggleEdit(true); NoteControls.Add(noteControl); } List_Notes.ItemsSource = NoteControls; List_Organizations.ItemsSource = NoteControls; List_Projects.ItemsSource = NoteControls; } //List<OrganizationDto> organizations = NotesApi.GetData(NotesApi.Execute<List<OrganizationDto>>("Dashboard/Organizations", RestSharp.Method.GET)); //if (organizations.Count() > 0) //{ // foreach (OrganizationDto organization in organizations) // { // OrganizationFragment organizationControl = new OrganizationFragment(organization); // organizationControl.DataContext = organizationControl; // //organizationControl.ToggleEdit(true); // OrganizationControls.Add(organizationControl); // } // List_Organizations.ItemsSource = OrganizationControls; // List_Organizations.ItemsSource = OrganizationControls; // List_Projects.ItemsSource = OrganizationControls; //} //List<ProjectDto> projects = NotesApi.GetData(NotesApi.Execute<List<ProjectDto>>("Dashboard/Projects", RestSharp.Method.GET)); //if (projects.Count() > 0) //{ // foreach (ProjectDto project in projects) // { // ProjectFragment projectControl = new ProjectFragment(project); // projectControl.DataContext = projectControl; // //projectControl.ToggleEdit(true); // ProjectControls.Add(projectControl); // } // List_Projects.ItemsSource = ProjectControls; // List_Organizations.ItemsSource = ProjectControls; // List_Projects.ItemsSource = ProjectControls; //} } catch (Exception x) { ; } base.OnInitialized(e); }
private void Button_AddNote_Click(object sender, RoutedEventArgs e) { try { NoteDto note = NotesApi.GetData(NotesApi.Execute <NoteDto>("Dashboard/CreateNote", RestSharp.Method.GET)); if (note != null) { NoteFragment noteControl = new NoteFragment(note); noteControl.DataContext = noteControl; noteControl.ToggleEdit(true); NoteControls.Add(noteControl); List_Notes.Items.Refresh(); } } catch (Exception x) { ; } }
private void Register_Click(object sender, RoutedEventArgs e) { ToggleError(null); string name = TextBox_Name.Text; string password = TextBox_Password.Password; string password2 = TextBox_Password2.Password; try { if (password != password2) { throw new Exception("Passwords must match"); } AuthenticationModel authModel = NotesApi.GetAuthenticationModel(name, password); IRestResponse <UserDto> response = NotesApi.Execute <UserDto>("Authentication/Register", Method.PUT, authModel); UserDto result = response.Data; if (string.IsNullOrEmpty(result.Token)) { throw new Exception("Failed to Register"); } UserAuthenticated?.Invoke(this, new AuthenticationEventArgs { User = result }); Visibility = Visibility.Collapsed; } catch (Exception x) { ToggleError(x.Message); } }