public EventCommand(ConstellationEventTypeEnum type, ChannelAdvancedModel channel) : this(type, channel.id, channel.user.username) { }
public override async Task <CommandBase> GetNewCommand() { if (await this.Validate()) { if (this.command == null) { if (this.OtherEventTypeTextBox.Visibility == Visibility.Visible) { this.command = new EventCommand(EnumHelper.GetEnumValueFromString <OtherEventTypeEnum>(this.OtherEventTypeTextBox.Text), ChannelSession.Channel.id.ToString()); } else if (this.EventTypeComboBox.Visibility == Visibility.Visible) { ConstellationEventTypeEnum eventType = EnumHelper.GetEnumValueFromString <ConstellationEventTypeEnum>((string)this.EventTypeComboBox.SelectedItem); ChannelAdvancedModel channel = null; UserModel user = null; if (eventType.ToString().Contains("channel") || eventType.ToString().Contains("progression")) { channel = await ChannelSession.Connection.GetChannel(uint.Parse(this.EventIDTextBox.Text)); if (channel == null) { await MessageBoxHelper.ShowMessageDialog("Unable to find the channel for the specified username"); return(null); } } else if (eventType.ToString().Contains("user")) { user = await ChannelSession.Connection.GetUser(uint.Parse(this.EventIDTextBox.Text)); if (user == null) { await MessageBoxHelper.ShowMessageDialog("Unable to find a user for the specified username"); return(null); } } if (channel != null) { this.command = new EventCommand(eventType, channel); } else if (user != null) { this.command = new EventCommand(eventType, user); } else { this.command = new EventCommand(eventType); } } if (ChannelSession.Settings.EventCommands.Any(se => se.UniqueEventID.Equals(this.command.UniqueEventID))) { await MessageBoxHelper.ShowMessageDialog("This event already exists"); return(null); } ChannelSession.Settings.EventCommands.Add(this.command); } this.command.Unlocked = this.UnlockedControl.Unlocked; return(this.command); } return(null); }