コード例 #1
0
        public void CancelEditAnswer()
        {
            if (editingAnswer == null) return;

            editingAnswer.EditedBody = editingAnswer.Body;
            editingAnswer.IsEdit = false;

            editingAnswer = null;
        }
コード例 #2
0
        public async void RemoveAnswer(Answer answer)
        {
            if (MessageBox.Show(AppResources.Confirm_RemoveAnswer, AppResources.Confirm_Title, MessageBoxButton.OKCancel) != MessageBoxResult.OK)
                return;

            await RunTaskAsync(async () =>
            {
                await answerRestService.Remove(answer.AnswerId);
                await PopulateQuestion();
            });
        }
コード例 #3
0
 public void EditAnswer(Answer answer)
 {
     answer.IsEdit = true;
     editingAnswer = answer;
 }
コード例 #4
0
 public async void UnmarkAsAccepted(Answer answer)
 {
     await RunTaskAsync(async () =>
     {
         await answerRestService.UnmarkAsAccepted(answer.AnswerId);
         await PopulateQuestion();
     }, busy => answer.IsVotingBusy = busy);
 }
コード例 #5
0
        public async void MarkAsAccepted(Answer answer)
        {
            await RunTaskAsync(async () =>
            {
                //Only one answer can be accepted.
                Answer accepted = Answers.FirstOrDefault(x => x.IsAccepted);

                if (accepted != null)
                {
                    await answerRestService.UnmarkAsAccepted(answer.AnswerId);
                }
                else
                {
                    await answerRestService.MarkAsAccepted(answer.AnswerId);
                }

                await PopulateQuestion();
            }, busy => answer.IsVotingBusy = busy);

        }
コード例 #6
0
        public async void AnswerDown(Answer answer)
        {
            if (!appSettings.IsAuthenticated)
            {
                navigationService.UriFor<Login.LoginViewModel>().Navigate();
                return;
            }

            await RunTaskAsync(async () =>
            {
                bool alreadyVotedDown = answer.Votes.Any(x => x.Key == appSettings.UserId && x.Value == VoteDirection.Down);

                if (alreadyVotedDown)
                {
                    await answerRestService.Unvote(answer.AnswerId);
                }
                else
                {
                    await answerRestService.VoteDown(answer.AnswerId);
                }

                await PopulateQuestion();
            }, (busy) => answer.IsVotingBusy = busy);


        }
コード例 #7
0
 private static void UpdateAnswer(Answer localAnswer, Answer remoteAnswer)
 {
     localAnswer.Author = remoteAnswer.Author;
     localAnswer.Body = remoteAnswer.Body;
     localAnswer.CreatedAt = remoteAnswer.CreatedAt;
     localAnswer.EditedAt = remoteAnswer.EditedAt;
     localAnswer.EditedBody = remoteAnswer.EditedBody;
     localAnswer.IsAccepted = remoteAnswer.IsAccepted;
     localAnswer.IsEdit = false;
     localAnswer.QuestionId = remoteAnswer.QuestionId;
     localAnswer.Rating = remoteAnswer.Rating;
     localAnswer.Votes = remoteAnswer.Votes;
 }