void OnEditOptionsChanged(PollOptionEditor option, string property) { switch (property) { case "Key": if (string.IsNullOrEmpty(option.OldKey)) { option.Poll = selectedpoll; context.GetModule <PollModule>().CreatePollOption(option.Poll, option.Key, option.Description); } else { context.GetModule <PollModule>().ChangePollOption(option.Poll, option.OldKey, option.Key, option.Description); } votes.Where(v => v.Vote == option.OldKey).ToArray().Foreach(v => v.Vote = option.Key); break; case "Locked": context.GetModule <PollModule>().LockOption(option.Poll, option.Key, option.Locked); break; default: context.GetModule <PollModule>().ChangePollOption(option.Poll, option.OldKey, option.Key, option.Description); break; } option.Apply(); }
void Context_RemoveOption(object sender, RoutedEventArgs e) { PollOptionEditor option = grdPollOptions.SelectedItem as PollOptionEditor; if (option == null) { return; } context.GetModule <PollModule>().RemovePollOption(option.Poll, option.Key); }
void grdPollOptions_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { PollOptionEditor item = grdPollOptions.SelectedItem as PollOptionEditor; ctxRemoveOption.IsEnabled = item != null; }