public JsonResult AddToDefinition(string tagName, int definitionId)
        {
            var ajaxResponse = new Dictionary<string, string>();
            ajaxResponse["actionType"] = "create";

            int tagId = AddTagToDataBase(tagName);
            var relation =
                _db.DefTagRelations.FirstOrDefault(
                    x => x.DefinitionID == definitionId && x.TagID == tagId);

            if (relation != null)
            {
                ajaxResponse["doExist"] = "true";
            }
            else
            {
                ajaxResponse["doExist"] = "false";
                relation = new DefTagRelation
                {
                    DefinitionID = definitionId,
                    TagID = tagId,
                };

                _db.DefTagRelations.AddObject(relation);
                _db.SaveChanges();
            }

            ajaxResponse["id"] = tagId.ToString(CultureInfo.InvariantCulture);
            ajaxResponse["message"] = "Тэг успешно добавлен";
            ajaxResponse["success"] = "true";
            ajaxResponse["body"] = tagName;
            return Json(ajaxResponse, JsonRequestBehavior.AllowGet);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the DefTagRelations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDefTagRelations(DefTagRelation defTagRelation)
 {
     base.AddObject("DefTagRelations", defTagRelation);
 }
 /// <summary>
 /// Deletes DefTagRelation from database
 /// </summary>
 /// <param name="relation"></param>
 private void RemoveDefFromDataBase(DefTagRelation relation)
 {
     _db.DefTagRelations.DeleteObject(relation);
     _db.SaveChanges();
 }
 /// <summary>
 /// Create a new DefTagRelation object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="tagID">Initial value of the TagID property.</param>
 /// <param name="definitionID">Initial value of the DefinitionID property.</param>
 public static DefTagRelation CreateDefTagRelation(global::System.Int32 id, global::System.Int32 tagID, global::System.Int32 definitionID)
 {
     DefTagRelation defTagRelation = new DefTagRelation();
     defTagRelation.ID = id;
     defTagRelation.TagID = tagID;
     defTagRelation.DefinitionID = definitionID;
     return defTagRelation;
 }