Exemple #1
0
        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");
        }
Exemple #2
0
        public RedirectResult AddTag(int TaskID, string tagArray)
        {
            string[] tags = tagArray.Split(' ');

            foreach (var item in tags)
            {
                if (item == "") continue;
                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();

                    sifUserTask tagToAdd = new sifUserTask()
                    {
                        idTag = newTag.idTag,
                        idTask = TaskID
                    };
                    db.sifUserTasks.InsertOnSubmit(tagToAdd);
                    db.SubmitChanges();
                }
                else
                {
                    sifUserTask tagToAdd = new sifUserTask()
                    {
                        idTag = getTag.First().idTag,
                        idTask = TaskID
                    };
                    db.sifUserTasks.InsertOnSubmit(tagToAdd);
                    db.SubmitChanges();
                }
            }

            return Redirect("Index");
        }
 partial void DeleteTag(Tag instance);
 partial void UpdateTag(Tag instance);
 partial void InsertTag(Tag instance);
 /// <summary>
 /// Deprecated Method for adding a new object to the Tag EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTag(Tag tag)
 {
     base.AddObject("Tag", tag);
 }
 /// <summary>
 /// Create a new Tag object.
 /// </summary>
 /// <param name="idTag">Initial value of the idTag property.</param>
 /// <param name="tagName">Initial value of the tagName property.</param>
 public static Tag CreateTag(global::System.Int32 idTag, global::System.String tagName)
 {
     Tag tag = new Tag();
     tag.idTag = idTag;
     tag.tagName = tagName;
     return tag;
 }