public void CancelEditAnswer() { if (editingAnswer == null) return; editingAnswer.EditedBody = editingAnswer.Body; editingAnswer.IsEdit = false; editingAnswer = null; }
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(); }); }
public void EditAnswer(Answer answer) { answer.IsEdit = true; editingAnswer = answer; }
public async void UnmarkAsAccepted(Answer answer) { await RunTaskAsync(async () => { await answerRestService.UnmarkAsAccepted(answer.AnswerId); await PopulateQuestion(); }, busy => answer.IsVotingBusy = busy); }
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); }
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); }
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; }