Пример #1
0
        /// <summary>
        /// Add a tag to a trade.
        /// </summary>
        protected void SetTag(Trade trade, Tag tag)
        {
            if (tag == null) return;
            if (trade.Tags != null && trade.Tags.Contains(tag)) return;

            if(trade.Tags == null)
            {
                trade.Tags = new ObservableCollection<Tag>();
            }

            trade.Tags.Add(tag);

            Logger.Log(LogLevel.Info, "User script {0} added tag {1} to trade {2}", this.GetType().Name, tag, trade);
        }
Пример #2
0
        private void SetTags(IEnumerable <Trade> trades, Tag tag, bool add)
        {
            foreach (Trade t in trades)
            {
                if (!add)
                {
                    t.Tags.Remove(tag);
                }
                else
                {
                    t.Tags.Add(tag);
                }
                t.TagStringUpdated();
            }

            Context.SaveChanges();
        }
Пример #3
0
        private async void DeleteTag(Tag tag)
        {
            MessageDialogResult res = await DialogService.ShowMessageAsync(Parent,
                "Delete Tag",
                string.Format("Are you sure you want to delete {0}?", tag.Name),
                MessageDialogStyle.AffirmativeAndNegative);
            if (res != MessageDialogResult.Affirmative) return;

            //keep track of the trades with this tag, we need to update their tagstrings
            var trades = Context.Trades.ToList().Where(x => x.Tags.Contains(tag)).ToList();

            Context.Tags.Remove(tag);
            Context.SaveChanges();

            foreach (Trade t in trades)
            {
                t.TagStringUpdated();
            }
        }
Пример #4
0
        private void SetTags(IEnumerable<Trade> trades, Tag tag, bool add)
        {
            foreach (Trade t in trades)
            {
                if (!add)
                {
                    t.Tags.Remove(tag);
                }
                else
                {
                    t.Tags.Add(tag);
                }
                t.TagStringUpdated();
            }

            Context.SaveChanges();
        }