예제 #1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Tags EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTags(Tag tag)
 {
     base.AddObject("Tags", tag);
 }
예제 #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();
 }
예제 #3
0
 /// <summary>
 /// Create a new Tag object.
 /// </summary>
 /// <param name="tag_Id">Initial value of the Tag_Id property.</param>
 /// <param name="tagID">Initial value of the TagID property.</param>
 public static Tag CreateTag(global::System.Int32 tag_Id, global::System.String tagID)
 {
     Tag tag = new Tag();
     tag.Tag_Id = tag_Id;
     tag.TagID = tagID;
     return tag;
 }
예제 #4
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();
 }