public Login() { this.InitializeComponent(); memberService = new MemberServiceImp(); //Lay token da luu file trong lan dang nhap trc: var token = memberService.ReadTokenFromLocalStorage(); }
public MySong() { this.InitializeComponent(); memberService = new MemberServiceImp(); this.listMusic = new ObservableCollection <Music>(); var token = memberService.ReadTokenFromLocalStorage(); var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Authorization", "Basic " + token); String responseContent = httpClient.GetAsync(ApiUrl.GET_MY_SONG_URL).Result.Content.ReadAsStringAsync().Result; List <Music> listSong = JsonConvert.DeserializeObject <List <Music> >(responseContent); foreach (Music item in listSong) { this.listMusic.Add(new Music() { name = item.name, singer = item.singer, thumbnail = item.thumbnail, link = item.link, }); } }
public ListSong() { this.memberService = new MemberServiceImp(); loginToken = memberService.ReadTokenFromLocalStorage(); if (loginToken == null) { } else { this.InitializeComponent(); this.songService = new SongServiceImp(); LoadSongs(); } }
public Upload() { this.memberService = new MemberServiceImp(); loginToken = memberService.ReadTokenFromLocalStorage(); if (loginToken == null) { //Not login: } else { this.InitializeComponent(); this.songService = new SongServiceImp(); } }
public NaView() { this.InitializeComponent(); uploadNav = this.upload; mysongNav = this.mysong; listsongNav = this.listsong; profileNav = this.profile; memberService = new MemberServiceImp(); tokenLogin = memberService.ReadTokenFromLocalStorage(); if (tokenLogin == null) { } else { Member memberLogin = memberService.GetInformation(tokenLogin); } }
public MySong() { this.memberService = new MemberServiceImp(); loginToken = memberService.ReadTokenFromLocalStorage(); if (loginToken == null) { } else { this.InitializeComponent(); this.songService = new SongServiceImp(); LoadSongs(); if (_songs.Count == 0) { this.empty.Visibility = Visibility.Visible; this.media.Visibility = Visibility.Collapsed; } } }
public Profile() { memberService = new MemberServiceImp(); loginToken = memberService.ReadTokenFromLocalStorage(); if (loginToken == null) { } else { this.InitializeComponent(); memLogged = memberService.GetInformation(loginToken); if (memLogged.gender == 0) { this.gender.Text = "Female"; } else if (memLogged.gender == 1) { this.gender.Text = "Male"; } DateTime dt = DateTime.Parse(memLogged.birthday); this.birthday.Text = String.Format("{0:ddd, MMM d, yyyy}", dt); } }
private void Submit_OnClick(object sender, RoutedEventArgs e) { Boolean subName, subThubnail, subLink; subName = subThubnail = subLink = true; if (this.Name.Text.Equals("")) { this.erroName.Text = "Name is requaired!"; subName = false; } else { this.erroName.Text = ""; subName = true; } if (this.Thumbnail.Text.Equals("")) { this.erroThumbnail.Text = "Thumbnail is requaired!"; subThubnail = false; } else { this.erroThumbnail.Text = ""; subThubnail = true; } if (this.Link.Text.Equals("")) { this.erroLink.Text = "Link is requaired!"; subLink = false; } else { this.erroLink.Text = ""; subLink = true; } if (subName && subThubnail && subLink) { Music newSong = new Music() { name = this.Name.Text, description = this.Description.Text, singer = this.Singer.Text, author = this.Author.Text, thumbnail = this.Thumbnail.Text, link = this.Link.Text }; string token = memberService.ReadTokenFromLocalStorage(); var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Authorization", "Basic " + token); HttpContent content = new StringContent(JsonConvert.SerializeObject(newSong), Encoding.UTF8, "application/json"); String responseContent = httpClient.PostAsync(ApiUrl.SONG_URL, content).Result.Content.ReadAsStringAsync().Result; Debug.WriteLine("Response: " + responseContent); messageSuccess(); } }