Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 5
0
 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)
     {
         ;
     }
 }