/// <summary> /// Deprecated Method for adding a new object to the Tags EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTags(Tags tags) { base.AddObject("Tags", tags); }
public void TagoviUnos(string tagovi, int clid) { using (Spajanje s = new Spajanje()) { List<TagClanci> tgs = (from tg in s.Context.TagClanci where tg.ClanakID == clid select tg).ToList(); foreach (TagClanci tg in tgs) { s.Context.TagClanci.DeleteObject(tg); s.Context.SaveChanges(); } List<string> tegs = tagovi.Split(',').ToList(); if (tegs.Count > 0 && tegs[0] != string.Empty) { List<Tags> Tagtemp = new List<Tags>(); Tags tgtmp; foreach (string it in tegs) { tgtmp = new Tags(); tgtmp.Ime = it; tgtmp.Opis = it; Tagtemp.Add(tgtmp); } Tags tmpTag; TagClanci tmpTclan; foreach (Tags tgs2 in Tagtemp) { tmpTag = null; tmpTag = (from tt in s.Context.Tags where tt.Ime == tgs2.Ime select tt).FirstOrDefault(); if (tmpTag == null) { s.Context.Tags.AddObject(tgs2); s.Context.SaveChanges(); tmpTag = s.Context.Tags.ToList().Last(); } tmpTclan = new TagClanci(); tmpTclan.ClanakID = clid; tmpTclan.TagID = tmpTag.TagID; s.Context.TagClanci.AddObject(tmpTclan); s.Context.SaveChanges(); } } } }
/// <summary> /// Create a new Tags object. /// </summary> /// <param name="tagID">Initial value of the TagID property.</param> public static Tags CreateTags(global::System.Int32 tagID) { Tags tags = new Tags(); tags.TagID = tagID; return tags; }
public int GetTagIdByName(string name) { Tags tag = context.Tags.ToList().Where(x => x.Ime == name).FirstOrDefault(); if (tag != null) { return tag.TagID; } else { Tags t = new Tags(); t.Ime = name; context.Tags.AddObject(t); context.SaveChanges(); Tags tagZ = context.Tags.LastOrDefault(); if (tagZ != null) { return tagZ.TagID; } return 0; } }