public async void getbbdd(int type = 1, int size = 15, int typeid = 5, bool isReflush = false) { List <BBDDFeed> bbddlist; if (isReflush) { BBDD.Clear(); bbddpage = 0; } bbddlist = await CommunityFeedsService.GetBBDD(type, bbddpage ++, size, typeid); for (int j = 0; j < bbddlist.Count; j++) { BBDD.Add(bbddlist[j]); } }
public async void gethot(int type = 0, int size = 15, int typeid = 0, bool isReflush = false) { List <HotFeed> hotlist; if (isReflush) { HotFeeds.Clear(); hotpage = 0; } hotlist = await CommunityFeedsService.GetHot(type, hotpage ++, size, typeid); for (int i = 0; i < hotlist.Count; i++) { HotFeeds.Add(hotlist[i]); } }
private async void liskButton_Click(object sender, RoutedEventArgs e) { //TODO:未登陆时 不能点赞 //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { var b = sender as Button; string num_id = b.TabIndex.ToString(); Debug.WriteLine(num_id); Debug.WriteLine("id " + num_id.Substring(2)); string like_num = ""; try { if (int.Parse(num_id[0].ToString()) < 5) //hot { HotFeed hotfeed = ViewModel.HotFeeds.First(p => p.article_id.Equals(num_id.Substring(2))); if (hotfeed.is_my_Like == "true" || hotfeed.is_my_Like == "True") { like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), false); if (like_num != "") { hotfeed.like_num = like_num; hotfeed.is_my_Like = "false"; if (ViewModel.BBDD.Count(p => p.id.Equals(num_id.Substring(2))) != 0) { BBDDFeed s = ViewModel.BBDD.First(p => p.id.Equals(num_id.Substring(2))); if (s != null) { s.like_num = like_num; s.is_my_like = "false"; } } } } else { like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), true); if (like_num != "") { hotfeed.like_num = like_num; hotfeed.is_my_Like = "true"; if (ViewModel.BBDD.Count(p => p.id.Equals(num_id.Substring(2))) != 0) { BBDDFeed s = ViewModel.BBDD.First(p => p.id.Equals(num_id.Substring(2))); if (s != null) { s.like_num = like_num; s.is_my_like = "true"; } } } } } else if (num_id[0] == '5') //bbdd { BBDDFeed bbddfeed = ViewModel.BBDD.First(p => p.id.Equals(num_id.Substring(2))); if (bbddfeed.is_my_like == "true" || bbddfeed.is_my_like == "True") { like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), false); if (like_num != "") { bbddfeed.like_num = like_num; bbddfeed.is_my_like = "false"; if (ViewModel.HotFeeds.Count(p => p.article_id.Equals(num_id.Substring(2))) != 0) { HotFeed h = ViewModel.HotFeeds.First(p => p.article_id.Equals(num_id.Substring(2))); if (h != null) { h.like_num = like_num; h.is_my_Like = "false"; } } } } else { like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), true); if (like_num != "") { bbddfeed.like_num = like_num; bbddfeed.is_my_like = "true"; if (ViewModel.HotFeeds.Count(p => p.article_id.Equals(num_id.Substring(2))) != 0) { HotFeed h = ViewModel.HotFeeds.First(p => p.article_id.Equals(num_id.Substring(2))); if (h != null) { h.like_num = like_num; h.is_my_Like = "true"; } } } } } } catch (Exception) { Debug.WriteLine("点赞异常"); } } else { var msgPopup = new Data.loginControl("您还没有登录 无法点赞~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { Debug.WriteLine("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } } catch { var msgPopup = new Data.loginControl("您还没有登录 无法点赞~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { Debug.WriteLine("您可以先去社区逛一逛~"); }; msgPopup.ShowWIndow(); } }
private async void LikeButton_Click(object sender, RoutedEventArgs e) { //TODO:未登陆时 不能点赞 //if (appSetting.Values.ContainsKey("idNum")) try { var vault = new Windows.Security.Credentials.PasswordVault(); var credentialList = vault.FindAllByResource(resourceName); credentialList[0].RetrievePassword(); if (credentialList.Count > 0) { var b = sender as Button; string num_id = b.TabIndex.ToString(); Debug.WriteLine(num_id); Debug.WriteLine("id " + num_id.Substring(2)); string like_num = ""; if (ViewModel.BBDD != null) { BBDDFeed bbddfeed = ViewModel.BBDD; if (bbddfeed.is_my_like == "true" || bbddfeed.is_my_like == "True") { like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), false); if (like_num != "") { bbddfeed.like_num = like_num; bbddfeed.is_my_like = "false"; //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.like_num = like_num; // h.is_my_Like = "false"; //} } } else { like_num = await CommunityFeedsService.setPraise(bbddfeed.type_id, num_id.Substring(2), true); if (like_num != "") { bbddfeed.like_num = like_num; bbddfeed.is_my_like = "true"; //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.like_num = like_num; // h.is_my_Like = "true"; //} } } } if (ViewModel.hotfeed != null) { HotFeed hotfeed = ViewModel.hotfeed; if (hotfeed.is_my_Like == "true" || hotfeed.is_my_Like == "True") { like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), false); if (like_num != "") { hotfeed.like_num = like_num; hotfeed.is_my_Like = "false"; //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.like_num = like_num; // h.is_my_Like = "false"; //} } } else { like_num = await CommunityFeedsService.setPraise(hotfeed.type_id, num_id.Substring(2), true); if (like_num != "") { hotfeed.like_num = like_num; hotfeed.is_my_Like = "true"; //if (args is HotFeed) //{ // HotFeed h = args as HotFeed; // h.like_num = like_num; // h.is_my_Like = "true"; //} } } } } else { var msgPopup = new Data.loginControl("您还没有登录 无法点赞~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); }; msgPopup.ShowWIndow(); } } catch { var msgPopup = new Data.loginControl("您还没有登录 无法点赞~"); msgPopup.LeftClick += (s, c) => { Frame rootFrame = Window.Current.Content as Frame; rootFrame.Navigate(typeof(LoginPage)); }; msgPopup.RightClick += (s, c) => { new MessageDialog("您可以先四处逛一逛~"); }; msgPopup.ShowWIndow(); } }