void rb_Checked(object sender, RoutedEventArgs e) { try { var currentCheckBoxItem = sender as RadioButton; string name = currentCheckBoxItem.Name; var questionAnswer = name.Split('-'); long qId = Convert.ToInt64(questionAnswer[0]); long aId = Convert.ToInt64(questionAnswer[1]); if (currentCheckBoxItem.IsChecked == true) { Task.Run(new Action(() => { try { var question = Voting.Questions.Where(x => x.QuestionId == qId).FirstOrDefault(); var vote = question.Votes.FirstOrDefault(); if (vote == null) { vote = new VotesClass(); vote.AnswerIds.Add(aId); question.Votes.Add(vote); } else { vote.AnswerIds.Clear(); vote.AnswerIds.Add(aId); } } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.WP8); } })); } } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.WP8); } }
void commentTb_LostFocus(object sender, RoutedEventArgs e) { var currentCheckBoxItem = sender as TextBox; var text = currentCheckBoxItem.Text; if (!String.IsNullOrEmpty(currentCheckBoxItem.Text)) { string name = currentCheckBoxItem.Name; var questionAnswer = name.Split('-'); long qId = Convert.ToInt64(questionAnswer[1]); Task.Run(new Action(() => { try { var question = Voting.Questions.Where(x => x.QuestionId == qId).FirstOrDefault(); var vote = question.Votes.FirstOrDefault(); if (vote != null) { vote.OtherText = text; } else { vote = new VotesClass(); vote.OtherText = text; question.Votes.Add(vote); } } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.WP8); } })); } }