Beispiel #1
0
        /// <summary>
        /// Update the <see cref="Options"/> List
        /// </summary>
        private void UpdateOptions()
        {
            var newOptions = this.Thing.Option.Except(this.Options.Select(x => x.Thing)).ToList();
            var oldOptions = this.Options.Select(x => x.Thing).Except(this.Thing.Option).ToList();

            foreach (var option in newOptions)
            {
                var row = new OptionRowViewModel(option, this.Session, this);
                row.Index = this.Thing.Option.IndexOf(option);

                this.Options.Add(row);
            }

            foreach (var option in oldOptions)
            {
                var row = this.Options.SingleOrDefault(x => x.Thing == option);
                if (row != null)
                {
                    this.Options.Remove(row);
                }
            }

            this.Options.Sort((o1, o2) => o1.Index.CompareTo(o2.Index));
            this.UpdateDefaultOption();
        }
Beispiel #2
0
        /// <summary>
        /// Set the default <see cref="Option"/>
        /// </summary>
        private void UpdateDefaultOption()
        {
            var defaultOption = this.Thing.DefaultOption;

            if (this.defaultOptionRow != null)
            {
                this.defaultOptionRow.IsDefaultOption = false;
            }

            if (defaultOption == null)
            {
                this.defaultOptionRow = null;
                return;
            }

            var row = this.Options.Single(x => x.Thing == defaultOption);

            this.defaultOptionRow = row;
            row.IsDefaultOption   = true;
        }