public B2BPage() { InitializeComponent(); this.BindingContext = viewModel = new B2BPageViewModel(); LV.ItemTapped += LV_ItemTapped; postItemService = DependencyService.Get <IB2BPostItemService>(); Init(); }
public async Task <bool> Follow(string PostId) { IB2BPostItemService postItemService = DependencyService.Get <IB2BPostItemService>(); var isFollow = await postItemService.Follow(PostId, UserLogged.Id); var currentPost = this.Data.Where(x => x.Id == PostId).SingleOrDefault(); if (currentPost != null) { currentPost.IsFollow = isFollow; } return(isFollow); }
public async void Option_Clicked(object sender, EventArgs e) { int DELETE_POST = 1; int VIEW_PROFILE = 2; int CHAT = 3; int VIEW_COMPANYPROFILE = 4; var postItem = viewModel.PostItem; IDictionary <int, string> keyValues = new Dictionary <int, string>(); keyValues[VIEW_PROFILE] = Language.thong_tin_ca_nhan; keyValues[VIEW_COMPANYPROFILE] = Language.thong_tin_cong_ty; if (UserLogged.IsLogged && postItem.CreatedBy.UserId == UserLogged.Id) { keyValues[DELETE_POST] = Language.xoa_bai_dang; } else { keyValues[CHAT] = Language.sundihome_chat; } var result = await DisplayActionSheet(Language.tuy_chon, Language.huy, null, keyValues.Values.ToArray()); if (keyValues.ContainsKey(VIEW_COMPANYPROFILE) && result == keyValues[VIEW_COMPANYPROFILE]) { var userResponse = await ApiHelper.Get <User>(ApiRouter.USER_GET_USER_BY_ID + "/" + postItem.CreatedById); if (userResponse.IsSuccess) { var user = userResponse.Content as User; var companyID = user.CompanyId.Value; await Navigation.PushAsync(new CompanyProfileDetailPage(companyID)); } } else if (keyValues.ContainsKey(DELETE_POST) && result == keyValues[DELETE_POST]) { var answer = await DisplayAlert(Language.xac_nhan_xoa, Language.ban_co_chac_chan_muon_xoa_tin_dang_nay_khong, Language.xoa, Language.huy); if (!answer) { return; } IB2BPostItemService postItemService = DependencyService.Get <IB2BPostItemService>(); await postItemService.RemovePostItem(postItem.Id); await Navigation.PopAsync(); MessagingCenter.Send <B2BDetailPage, string>(this, "OnDeleteSuccess", postItem.Id); } else if (result == keyValues[VIEW_PROFILE]) { await Navigation.PushAsync(new UserProfilePage(Guid.Parse(postItem.CreatedBy.UserId))); } else if (keyValues.ContainsKey(CHAT) && result == keyValues[CHAT]) { if (!UserLogged.IsLogged) { await DisplayAlert("", Language.vui_long_dang_nhap, Language.dong); ((AppShell)Shell.Current).SetLoginPageActive(); return; } await Navigation.PushAsync(new ChatPage(postItem.CreatedBy.UserId)); } }