Ejemplo n.º 1
0
 public void RemoveTag(Tag tag)
 {
     var postTags = _context.PostTags.Where(x => x.TagId == tag.Id).ToList();
     foreach (var postTag in postTags)
     {
         _context.PostTags.Remove(postTag);
     }
     _context.Tags.Remove(tag);
     Save();
 }
Ejemplo n.º 2
0
 public void AddNewTag(string tagName, string tagUrlSeo)
 {
     List<int> numlist = new List<int>();
     int num = 0;
     var tags = _context.Tags.ToList();
     if (tags.Count() != 0)
     {
         foreach (var tg in tags)
         {
             var tagid = tg.Id;
             Int32.TryParse(tagid.Replace("tag", ""), out num);
             numlist.Add(num);
         }
         numlist.Sort();
         num = numlist.Last();
         num++;
     }
     else
     {
         num = 1;
     }
     var newid = "tag" + num.ToString();
     var tag = new Tag { Id = newid, Name = tagName, UrlSeo = tagUrlSeo, Checked = false };
     _context.Tags.Add(tag);
     Save();
 }