Esempio n. 1
0
 public PostingListPage(Engine.ClientEngine.PostingLookupCondition searchCond, RespLookupPosting lookup)
 {
     InitializeComponent();
     m_searchCondition = searchCond;
     m_viewModel       = new ViewModel(searchCond, lookup);
     BindingContext    = m_viewModel;
 }
Esempio n. 2
0
            public ViewModel(Engine.ClientEngine.PostingLookupCondition searchCond, RespLookupPosting lookup)
            {
                MakeConditionText(searchCond ?? Engine.ClientEngine.PostingLookupCondition.empty);

                pageStatus = string.Format("{0}/{1}", lookup.currentPage + 1, lookup.totalPage);

                canGoPrev = lookup.currentPage > 0;
                canGoNext = (lookup.currentPage + 1) < lookup.totalPage;

                items = new ObservableCollection <Item>();
                foreach (var entry in lookup.entries)
                {
                    items.Add(new Item(entry));
                }
            }
        private async void myTagEntryView_TagTapped(object sender, ItemTappedEventArgs e)
        {
            if (e.Item != null)
            {
                var tagitem = e.Item as ViewModel.TagItem;

                var choice = await DisplayActionSheet(string.Format("태그 '{0}' 에 대해서...", tagitem.tag), "취소", null, new [] { c_tagActionSearch, c_tagActionDelete });

                switch (choice)
                {
                case c_tagActionSearch:
                {
                    var cond = new Engine.ClientEngine.PostingLookupCondition {
                        tag = tagitem.tag
                    };

                    RespLookupPosting result = null;
                    await App.RunLongTask(() =>
                        {
                            result = App.instance.core.post.LookupPosting(cond);
                        });

                    if (result != null)
                    {
                        await Navigation.PushAsync(new PostingListPage(cond, result));
                    }
                }
                break;

                case c_tagActionDelete:
                {
                    await App.RunLongTask(() =>
                        {
                            App.instance.core.post.DeleteTag(m_postingID, tagitem.tag);
                        });

                    m_viewModel.myTagItems.Remove(tagitem);
                }
                break;
                }
            }
        }
Esempio n. 4
0
            void MakeConditionText(Engine.ClientEngine.PostingLookupCondition searchCond)
            {
                var strBuilder    = new System.Text.StringBuilder();
                var anySearchCond = false;

                var titleAvail = !string.IsNullOrWhiteSpace(searchCond.title);
                var descAvail  = !string.IsNullOrWhiteSpace(searchCond.desc);

                if (titleAvail && descAvail && searchCond.title == searchCond.desc)
                {
                    strBuilder.Append(" 글+제목:").Append(searchCond.title);
                    anySearchCond = true;
                }
                else
                {
                    if (titleAvail)
                    {
                        strBuilder.Append(" 제목:").Append(searchCond.title);
                        anySearchCond = true;
                    }
                    if (descAvail)
                    {
                        strBuilder.Append(" 글:").Append(searchCond.desc);
                        anySearchCond = true;
                    }
                }

                if (!string.IsNullOrWhiteSpace(searchCond.user))
                {
                    strBuilder.Append(" 글쓴이:").Append(searchCond.user);
                    anySearchCond = true;
                }

                if (!string.IsNullOrWhiteSpace(searchCond.tag))
                {
                    strBuilder.Append(" 태그:").Append(searchCond.tag);
                    anySearchCond = true;
                }

                title           = anySearchCond ? "검색 결과" : "최근 글";
                searchCondition = anySearchCond ? strBuilder.ToString() : null;
            }
        private async void BtnAction_Clicked(object sender, EventArgs e)
        {
            var actions = new List <string>();

            actions.Add(c_actionAllPosting);

            if (!App.instance.isAdmin && m_viewModel.userName == (string)App.Current.Properties["username"])
            {
                actions.Add(c_actionDeleteUser);
            }

            if (App.instance.isAdmin)
            {
                actions.Add(c_actionBlindUser);
            }

            var choice = await DisplayActionSheet("무엇을 하시겠습니까?", "취소", null, actions.ToArray());

            switch (choice)
            {
            case c_actionAllPosting:
            {
                RespLookupPosting result = null;
                var searchCond           = new Engine.ClientEngine.PostingLookupCondition {
                    user = m_viewModel.userName
                };
                await App.RunLongTask(() =>
                    {
                        result = App.instance.core.post.LookupPosting(searchCond);
                    });

                if (result != null)
                {
                    await Navigation.PushAsync(new PostingListPage(searchCond, result));
                }
                else
                {
                    await DisplayAlert("오류", "포스팅을 조회할 수 없습니다.", "확인");
                }
            }
            break;

            case c_actionDeleteUser:
            {
                var result = await DisplayAlert("확인", "정말로 회원 탈퇴를 하시겠습니까?", "네", "아니오");

                if (result)
                {
                    result = await DisplayAlert("확인", "다시 한 번 확인하겠습니다. 정말로 회원 탈퇴를 하시겠습니까?", "네", "아니오");

                    if (result)
                    {
                        await App.RunLongTask(() => App.instance.core.user.DeleteUser());
                        await DisplayAlert("회원 탈퇴", "회원 탈퇴를 완료하였습니다. 안녕히가세요...", "확인");

                        App.instance.core.auth.ClearAuth();
                        App.GetLoginPage();
                    }
                }
            }
            break;

            case c_actionBlindUser:
            {
                var result = await DisplayAlert("확인", "정말로 이 유저를 블라인드 처리할까요?", "네", "아니오");

                if (result)
                {
                    await App.RunLongTask(() => App.instance.core.user.BlindUser(m_viewModel.userName, true));
                    await DisplayAlert("완료", "블라인드 처리를 완료했습니다.", "확인");

                    App.GetMainPage();
                }
            }
            break;
            }
        }