public InternalPage()
 {
     InitializeComponent();
     this.BindingContext = viewModel = new InternalPageViewModel();
     postItemService     = DependencyService.Get <IInternalPostItemService>();
     Init();
 }
Esempio n. 2
0
        public async void Option_Clicked(object sender, EventArgs e)
        {
            int DELETE_POST  = 1;
            int VIEW_PROFILE = 2;
            int CHAT         = 3;

            var postItem = viewModel.PostItem;
            IDictionary <int, string> keyValues = new Dictionary <int, string>();

            keyValues[VIEW_PROFILE] = Language.thong_tin_ca_nhan;
            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(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;
                }

                IInternalPostItemService postItemService = DependencyService.Get <IInternalPostItemService>();
                await postItemService.RemovePostItem(postItem.Id);

                await Navigation.PopAsync();

                MessagingCenter.Send <InternalDetailPage, 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));
            }
        }
Esempio n. 3
0
        public async Task <bool> Follow(string PostId)
        {
            IInternalPostItemService postItemService = DependencyService.Get <IInternalPostItemService>();
            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);
        }