Ejemplo n.º 1
0
        public tblTags AddIfNotExist(string tag)
        {
            tblTags newTag;

            using (DbContext context = this.CreateDbContext())
            {
                newTag = context.Set <tblTags>().SingleOrDefault(n => n.Name == tag);

                if (newTag == null)
                {
                    newTag = new tblTags()
                    {
                        Name       = tag,
                        TagRequest = 0
                    };
                    context.Set <tblTags>().Add(newTag);

                    context.SaveChanges();
                }
            }
            return(newTag);
        }
Ejemplo n.º 2
0
        public tblTags FindOrAddTag(string tag)
        {
            tblTags dbTag = _tagManager.AddIfNotExist(tag);

            return(dbTag);
        }