public RedirectResult AddTags(string tags, string fileID) { string[] tag = tags.Split(' '); foreach (var item in tag) { Tag newTag = new Tag(); var getTag = from n in db.Tags where n.tagName.Trim() == item select n; if (getTag.Count() == 0) { newTag.tagName = item; db.Tags.InsertOnSubmit(newTag); db.SubmitChanges(); sif_TagFile newTagFile = new sif_TagFile(); newTagFile.idFile = Int32.Parse(fileID); newTagFile.idTag = newTag.idTag; db.sif_TagFiles.InsertOnSubmit(newTagFile); db.SubmitChanges(); } else { sif_TagFile newTagFile = new sif_TagFile(); newTagFile.idFile = Int32.Parse(fileID); newTagFile.idTag = getTag.First().idTag; db.sif_TagFiles.InsertOnSubmit(newTagFile); db.SubmitChanges(); } } return Redirect("Files"); }
partial void Deletesif_TagFile(sif_TagFile instance);
partial void Updatesif_TagFile(sif_TagFile instance);
partial void Insertsif_TagFile(sif_TagFile instance);
private void detach_sif_TagFiles(sif_TagFile entity) { this.SendPropertyChanging(); entity.File = null; }
private void attach_sif_TagFiles(sif_TagFile entity) { this.SendPropertyChanging(); entity.File = this; }