Esempio n. 1
0
        public NoteManager(Patron patron, string menuOption, Note noteSelected)
        {
            _presenter = new NotePresenter(this);
            _patron = patron;
            DataContext = patron;
            InitializeComponent();
            if (noteSelected != null)
            {
                NoteListView.SelectedValue = noteSelected;
                NoteBoxActive.Text = noteSelected.Text;
            }
            if (menuOption == "active")
            {
                noteTabs.SelectedIndex = 0;
                CriticalCheckboxUpdate.IsChecked = noteSelected.Critical;
            }
            if (menuOption == "archived")
            {
                noteTabs.SelectedIndex = 1;
            }
            if (menuOption == "add")
            {
                noteTabs.SelectedIndex = 0;
                DiscardButton.Visibility = Visibility.Visible;
                CriticalCheckbox.Visibility = Visibility.Visible;
                AddButton.Visibility = Visibility.Visible;

                NewNoteButton.Visibility = Visibility.Hidden;
                CriticalCheckboxUpdate.Visibility = Visibility.Hidden;
                UpdateButton.Visibility = Visibility.Hidden;
                ArchiveButton.Visibility = Visibility.Hidden;
                NoteBoxActive.Text = "";
                NoteBoxActive.Focus();
            }
        }
Esempio n. 2
0
        private void Add_Note(object sender, RoutedEventArgs e)
        {
            Note note = new Note();
            note.PersonId = _patron.Identifiers.PersonId;
            note.Text = NoteBoxActive.Text;
            note.Critical = CriticalCheckbox.IsChecked.Value;
            if (NoteBoxActive.Text != null && NoteBoxActive.Text != "")
            {
                note = _presenter.AddNote(note);
            }
            _patron.Notes.ActiveNotes.Insert(0, note);
            NoteListView.SelectedItem = note;

            DiscardButton.Visibility = Visibility.Hidden;
            CriticalCheckbox.Visibility = Visibility.Hidden;
            AddButton.Visibility = Visibility.Hidden;

            NewNoteButton.Visibility = Visibility.Visible;
            CriticalCheckboxUpdate.Visibility = Visibility.Visible;
            UpdateButton.Visibility = Visibility.Visible;
            ArchiveButton.Visibility = Visibility.Visible;
            NoteBoxActive.Text = note.Text;
        }
Esempio n. 3
0
 private void CommandBinding_ArchivedNotesCommand(object sender, ExecutedRoutedEventArgs e)
 {
     var cardView = UserCardDetails.Content as UserCardDetailsTotalTabs;
     if (cardView != null)
     {
         var cardViewPresenter = cardView.DataContext as UserCardDetailsViewPresenter;
         string menuOpening = "archived";
         Note nullNote = new Note();
         if (_NoteManager == null)
         {
             _NoteManager = new NoteManager(cardViewPresenter.Patron, menuOpening, nullNote);
             _NoteManager.Show();
         }
         else
         {
             _NoteManager.Hide();
             _NoteManager = null;
             _NoteManager = new NoteManager(cardViewPresenter.Patron, menuOpening, nullNote);
             _NoteManager.Show();
         }
     }
 }
Esempio n. 4
0
        public Note UpdateNoteClient(Note note)
        {
            note.Text = note.Text.Replace("'", "''");
            var serializer = new XmlSerializer(typeof(Note));

            var memoryStream = new MemoryStream();
            var streamWriter = new StreamWriter(memoryStream, System.Text.Encoding.UTF8);

            serializer.Serialize(streamWriter, note);

            byte[] utf8EncodedXml = memoryStream.ToArray();
            //            string serializedValue = Encoding.UTF8.GetString(utf8EncodedXml);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(String.Concat(URI.RESTurl(), "UpdateNote"));
            request.Method = "POST";
            request.ContentType = "application/xml";
            request.ContentLength = utf8EncodedXml.Length;
            this.authenticationProvider.AuthenticatePostRequest(request, null); //serializedValue);
            request.Accept = "application/xml";

            Stream dataStream = request.GetRequestStream();
            dataStream.Write(utf8EncodedXml, 0, utf8EncodedXml.Length);
            dataStream.Close();

            HttpWebResponse response = null;

            Note newNote = null;

            try
            {
                using (response = (HttpWebResponse)request.GetResponse())
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        Stream ReceiveStream = response.GetResponseStream();
                        StreamReader readStream = new StreamReader(ReceiveStream);
                        string xml = readStream.ReadToEnd();

                        newNote = (Note)serializer.Deserialize(new StringReader(xml));
                    }
                }
            }
            catch (WebException webEx)
            {
                if (response == null)
                {
                    System.Diagnostics.Debug.WriteLine(webEx.Message);
                    throw webEx;
                }

                switch (response.StatusCode)
                {
                    case HttpStatusCode.NotFound:
                        System.Diagnostics.Debug.WriteLine("Not Found error: " + webEx.Message);
                        break;
                    case HttpStatusCode.InternalServerError:
                        System.Diagnostics.Debug.WriteLine("Server error: " + webEx.Message);
                        break;
                    default:
                        System.Diagnostics.Debug.WriteLine("Unknown Status code: " + response.StatusCode);
                        break;
                }
            }
            return newNote;
        }