コード例 #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);
            }
        }
コード例 #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);
        }
コード例 #3
0
        private void OnUserAuthenticated(object sender, AuthenticationEventArgs e)
        {
            UserDto user = e.User;

            ((App)Application.Current).User = user;
            NotesApi.SetToken(user.Token);

            //Label_LoginDebug.Content = string.Format("Logged in as {0}", user.Name);
            //Label_LoginDebug.Visibility = Visibility.Visible;

            //Button_Register.Visibility = Visibility.Collapsed;
            //Button_Login.Visibility = Visibility.Collapsed;

            DashboardViewModel dashboardModel = new DashboardViewModel
            {
                Organizations = new List <OrganizationDto>(),
                Projects      = new List <ProjectDto>(),
                UserNotes     = new List <NoteDto>()
            };

            Home.Grid_NoUser.Visibility   = Visibility.Collapsed;
            Home.Grid_WithUser.Visibility = Visibility.Visible;

            AccountMenu.Login.Visibility    = Visibility.Collapsed;
            AccountMenu.Register.Visibility = Visibility.Collapsed;

            AccountMenu.User.Visibility = Visibility.Visible;

            Dashboard = new DashboardView();
            //MainGrid.Children.Add(Dashboard);
            //MainWindowControls.Visibility = Visibility.Collapsed;
        }
コード例 #4
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));
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        private void OnUserLogout(object sender, EventArgs e)
        {
            ((App)Application.Current).User = null;
            NotesApi.SetToken(null);

            AccountMenu.Login.Visibility    = Visibility.Visible;
            AccountMenu.Register.Visibility = Visibility.Visible;

            AccountMenu.User.Visibility = Visibility.Collapsed;

            //MainGrid.Children.Add(Dashboard);
            //MainWindowControls.Visibility = Visibility.Collapsed;
        }
コード例 #7
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)
     {
         ;
     }
 }
コード例 #8
0
        /// <summary>
        /// Creates a client to work with VK API methods.
        /// </summary>
        public CitrinaClient()
        {
            AuthHelper = new AuthHelper();
            Execute    = new ExecuteApi();

            Account       = new AccountApi();
            Ads           = new AdsApi();
            Apps          = new AppsApi();
            Auth          = new AuthApi();
            Board         = new BoardApi();
            Database      = new DatabaseApi();
            Docs          = new DocsApi();
            Fave          = new FaveApi();
            Friends       = new FriendsApi();
            Gifts         = new GiftsApi();
            Groups        = new GroupsApi();
            Leads         = new LeadsApi();
            Likes         = new LikesApi();
            Market        = new MarketApi();
            Messages      = new MessagesApi();
            Newsfeed      = new NewsfeedApi();
            Notes         = new NotesApi();
            Notifications = new NotificationsApi();
            Orders        = new OrdersApi();
            Pages         = new PagesApi();
            Photos        = new PhotosApi();
            Places        = new PlacesApi();
            Polls         = new PollsApi();
            Search        = new SearchApi();
            Secure        = new SecureApi();
            Stats         = new StatsApi();
            Status        = new StatusApi();
            Storage       = new StorageApi();
            Users         = new UsersApi();
            Utils         = new UtilsApi();
            Video         = new VideoApi();
            Wall          = new WallApi();
            Widgets       = new WidgetsApi();
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
 public void Init()
 {
     instance = new NotesApi();
 }
コード例 #11
0
 public void Init()
 {
     client   = new ApiClient(subdomain, clientId, clientSecret: clientSecret);
     instance = client.Notes;
 }