Exemplo n.º 1
0
        public SubTag Remove(ulong ChannelId, int Index)
        {
            if (Tags.ContainsKey(ChannelId))
            {
                if (Tags[ChannelId].Count <= Index || Index < 0)
                {
                    return(null);
                }
                SubTag tag = Tags[ChannelId][Index];

                Tags[ChannelId].RemoveAt(Index);
                Save();

                return(tag);
            }
            return(null);
        }
Exemplo n.º 2
0
        public AddResult Add(ulong ChannelId, List <string> Tags)
        {
            SubTag n = new SubTag()
            {
                Tags = Tags
            };

            if (this.Tags.ContainsKey(ChannelId))
            {
                for (int i = 0; i < this.Tags[ChannelId].Count; i++)
                {
                    SubTag current = this.Tags[ChannelId][i];

                    if (current.Identical(n))
                    {
                        return(AddResult.AlreadyContains);
                    }
                }

                List <Post> posts = Gelbooru.FetchImages(Tags);
                if (posts.Count == 0)
                {
                    return(AddResult.NoImages);
                }

                n.PostIds = posts.Select(t => t.PostId).ToList();
                this.Tags[ChannelId].Add(n);
            }
            else
            {
                List <Post> posts = Gelbooru.FetchImages(Tags);
                if (posts.Count == 0)
                {
                    return(AddResult.NoImages);
                }

                n.PostIds = posts.Select(t => t.PostId).ToList();
                this.Tags.Add(ChannelId, new List <SubTag>()
                {
                    n
                });
            }
            Save();

            return(AddResult.Success);
        }
Exemplo n.º 3
0
 public bool Identical(SubTag tag) => ContainsIgnoreOrder(tag.Tags, Tags);