Guest User

Untitled

a guest
Jan 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. using System;
  2. using System.ComponentModel;
  3. using System.Runtime.CompilerServices;
  4.  
  5. namespace DataModel
  6. {
  7. public class Note : INotifyPropertyChanged
  8. {
  9. string header;
  10. string text;
  11. public string NoteHeader
  12. {
  13. get { return header; }
  14. set
  15. {
  16. header = value;
  17. OnPropertyChanged();
  18. }
  19. }
  20.  
  21. public string NoteText
  22. {
  23. get { return text; }
  24. set
  25. {
  26. text = value;
  27. OnPropertyChanged();
  28. }
  29. }
  30. public int NoteId { get; set; }
  31. public bool Pin { get; set; }
  32.  
  33.  
  34. public int UserId { get; set; }
  35. public virtual User User { get; set; }
  36.  
  37.  
  38. public event PropertyChangedEventHandler PropertyChanged;
  39. void OnPropertyChanged([CallerMemberName]string propertyName = "")
  40. {
  41. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  42. }
  43. }
  44. }
  45.  
  46. using Newtonsoft.Json;
  47. using System;
  48. using System.Collections.Generic;
  49. using System.Collections.ObjectModel;
  50. using System.IO;
  51. using System.Linq;
  52. using System.Net.Http;
  53. using System.Security.Cryptography;
  54. using System.Text;
  55. using System.Threading.Tasks;
  56.  
  57. namespace Project.ViewModels
  58.  
  59. public static string adress = "http://REAL:IP/";
  60. public static string Key = "KEY";
  61.  
  62. public static ObservableCollection<Note> GetNotes() //Коллекция заметок
  63. {
  64. HttpClient client = new HttpClient();
  65. client.BaseAddress = new Uri(adress);
  66. var json = client.GetStringAsync($"api/notes");
  67. ObservableCollection<Note> notes = JsonConvert.DeserializeObject<ObservableCollection<Note>>(json.Result);
  68.  
  69. ObservableCollection<Note> notedecrypted = notes;
  70. //Расшифровываем заголовок
  71.  
  72. var x = notes.NoteHeader;
  73. var decryptedheader = Decrypt(x, Key);
  74. notedecrypted.NoteHeader = decryptedheader;
  75.  
  76. //Расшифровываем текст
  77. var z = notes.NoteText;
  78. var decryptedtext = Decrypt(z, Key);
  79. notedecrypted.NoteText = decryptedtext;
  80.  
  81.  
  82. return notedecrypted;
  83. }
Add Comment
Please, Sign In to add comment