public ActionResult editTag(Tag tag) { if (!isLogin()) return RedirectToAction("login", "auth"); User user = getCurrentUser(); tag.UserId = user.Id; Provider db = new Provider(); try { db.updateTag(tag); db.mergeTag(tag.Id, tag.Name); } catch (Exception e) { return Content("fail" + e.Message); } return Content("ok"); }
public ActionResult addTag(Tag tag) { if (!isLogin()) return RedirectToAction("login", "auth"); User user = getCurrentUser(); tag.UserId = user.Id; tag.Count = 0; Provider db = new Provider(); try { db.insertTag(tag); } catch (Exception e) { return Content("fail" + e.Message); } tag.Id=(int)db.getDataRow("SELECT Id FROM Tag ORDER BY Id DESC")["Id"]; db.mergeTag(tag.Id, tag.Name); string content = "<li id='tag_item_+" + tag.Id + "> <span class='tag_name'>" + tag.Name + " </span><a href='javascript:void(0)' onclick='showEditTag(" + tag.Id + ")'>编辑</a> | <a href='javascript:void(0)' onclick='showDeleteTag(" + tag.Id + ")'>删除</a></li>"; return Content(content); }