Exemplo n.º 1
0
        public void Execute(object parameter)
        {
            string username  = _mainWindowViewModel.userPageViewModel.User.Username;
            string password  = _mainWindowViewModel.userPageViewModel.User.Password;
            string noteTitle = _addNewNoteViewModel.Title;
            string noteText  = _addNewNoteViewModel.Note;

            var t = Task.Run(() => _mainWindowViewModel.WebServise.AddNote(username, password, noteTitle, noteText));

            t.Wait();

            if (t.Result.ToString().Substring(0, 7) == "Success")
            {
                int jsonLength = t.Result.ToString().Length - 7;
                myBindingList <Note> addedNote = JsonConvert.DeserializeObject <myBindingList <Note> >(t.Result.ToString().Substring(7, jsonLength));


                _mainWindowViewModel.userPageViewModel.UserNotesList.Add(addedNote[0]);
                _updateViewCommand.Execute("UserPage");
            }
            else
            {
                MessageBox.Show(t.Result.ToString());
            }
        }
Exemplo n.º 2
0
        public void Execute(object parameter)
        {
            var t = Task.Run(() => _mainWindowViewModel.WebServise.Login(_loginViewModel.Username, _loginViewModel.Password));

            t.Wait();

            if (t.Result.ToString().Substring(0, 7) == "Success")
            {
                int jsonLength = t.Result.ToString().Length - 7;
                myBindingList <Note> userNotesList = JsonConvert.DeserializeObject <myBindingList <Note> >(t.Result.ToString().Substring(7, jsonLength));

                _mainWindowViewModel.userPageViewModel.User = new User(_loginViewModel.Username,
                                                                       _loginViewModel.Password,
                                                                       userNotesList
                                                                       );

                _mainWindowViewModel.userPageViewModel.BindUserNotes();

                _updateViewCommand.Execute("UserPage");
            }
            else
            {
                MessageBox.Show(t.Result.ToString());
            }
        }
Exemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     bindingList = new myBindingList <myInt>();
     bindingList.Add(new myInt(8));
     bindingList.Add(new myInt(9));
     bindingList.Add(new myInt(11));
     bindingList.Add(new myInt(12));
     dataGridView1.DataSource  = bindingList;
     bindingList.BeforeRemove += bindingList_BeforeRemove;
 }
Exemplo n.º 4
0
        public UserPageViewModel(MainWindowViewModel mainWindowViewModel)
        {
            _mainWindowViewModel            = mainWindowViewModel;
            UpdateViewToEditNoteViewCommand = new UpdateViewToEditNoteViewCommand(this, mainWindowViewModel);
            UpdateViewCommand = new UpdateViewCommand(mainWindowViewModel);
            LogoutCommand     = new LogoutCommand(mainWindowViewModel);

            UserNotesList = new myBindingList <Note>();

            UserNotesList.BeforeRemove += UserNotesList_BeforeRemove;
        }
Exemplo n.º 5
0
 public User(string username, string password, myBindingList <Note> userNotes)
 {
     Username  = username;
     Password  = password;
     UserNotes = userNotes;
 }