async void AddOption_Clicked(object sender, EventArgs e) { VoteOptions.Add(new VoteOption { VoteId = Item.Id }); MessagingCenter.Send(this, "AddOption", new VoteOption { VoteId = Item.Id }); LoadItemsCommand.Execute(true); }
async Task ExecuteLoadItemsCommand() { IsBusy = true; try { await Task.Delay(TimeSpan.FromSeconds(2)); VoteOptions.Add(new VoteOption { VoteId = Item.Id }); BindingContext = this; } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public override bool AddVote(string description, string command) { if (string.IsNullOrEmpty(description) || description.Length > VoteOption.MaxDescription) { Console.Print(OutputLevel.Standard, "votes", $"skipped invalid option '{description}'"); return(false); } if (string.IsNullOrEmpty(command) || command.Length > VoteOption.MaxCommand || !Console.IsLineValid(command)) { Console.Print(OutputLevel.Standard, "votes", $"skipped invalid command '{command}'"); return(false); } if (ContainsVote(description)) { Console.Print(OutputLevel.Standard, "votes", $"option '{description}' already exists"); return(false); } var voteOption = new VoteOption() { Description = description, Command = command }; VoteOptions.Add(voteOption.Description, voteOption); Console.Print(OutputLevel.Standard, "votes", $"added option '{voteOption.Description}' '{voteOption.Command}'"); Server.SendPackMsg(new GameMsg_SvVoteOptionAdd { Description = description }, MsgFlags.Vital, -1); return(true); }