Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel;
- using System.Runtime.CompilerServices;
- namespace DataModel
- {
- public class Note : INotifyPropertyChanged
- {
- string header;
- string text;
- public string NoteHeader
- {
- get { return header; }
- set
- {
- header = value;
- OnPropertyChanged();
- }
- }
- public string NoteText
- {
- get { return text; }
- set
- {
- text = value;
- OnPropertyChanged();
- }
- }
- public int NoteId { get; set; }
- public bool Pin { get; set; }
- public int UserId { get; set; }
- public virtual User User { get; set; }
- public event PropertyChangedEventHandler PropertyChanged;
- void OnPropertyChanged([CallerMemberName]string propertyName = "")
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.IO;
- using System.Linq;
- using System.Net.Http;
- using System.Security.Cryptography;
- using System.Text;
- using System.Threading.Tasks;
- namespace Project.ViewModels
- public static string adress = "http://REAL:IP/";
- public static string Key = "KEY";
- public static ObservableCollection<Note> GetNotes() //Коллекция заметок
- {
- HttpClient client = new HttpClient();
- client.BaseAddress = new Uri(adress);
- var json = client.GetStringAsync($"api/notes");
- ObservableCollection<Note> notes = JsonConvert.DeserializeObject<ObservableCollection<Note>>(json.Result);
- ObservableCollection<Note> notedecrypted = notes;
- //Расшифровываем заголовок
- var x = notes.NoteHeader;
- var decryptedheader = Decrypt(x, Key);
- notedecrypted.NoteHeader = decryptedheader;
- //Расшифровываем текст
- var z = notes.NoteText;
- var decryptedtext = Decrypt(z, Key);
- notedecrypted.NoteText = decryptedtext;
- return notedecrypted;
- }
Add Comment
Please, Sign In to add comment