示例#1
0
 public IActionResult AddTag(TagViewModel tag)
 {
     if (tag == null)
     {
         return(Json("失败"));
     }
     if (tag.Id == 0)
     {
         var result = _tagManager.AddEntity(new Tag
         {
             Name      = tag.Name,
             IsInChina = tag.IsInChina,
             IsOpen    = tag.IsOpen,
             Src       = tag.Src,
         });
         if (result != null)
         {
             return(Json("添加成功"));
         }
         return(Json("添加失败"));
     }
     else
     {
         var DBtag = _tagManager.LoadEntities(x => x.Id == tag.Id).FirstOrDefault();
         if (DBtag != null)
         {
             DBtag.IsInChina = tag.IsInChina;
             DBtag.IsOpen    = tag.IsOpen;
             DBtag.Name      = tag.Name;
             DBtag.Src       = tag.Src;
         }
         var result = _tagManager.EditEntity(DBtag);
         if (result)
         {
             return(Json("修改成功"));
         }
     }
     return(Json("失败"));
 }