public JsonResult delComment(comment comment) { User user = (User)Session["user"]; if (user != null) { if (user.type == 1) { DbNewsDataContext db = new DbNewsDataContext(); var query = from t in db.comment where t.id == comment.id select t; foreach (comment item in query) { db.comment.DeleteOnSubmit(item); } db.SubmitChanges(); return(Json(Result.success())); } else { return(Json(Result.fail())); } } else { return(Json(Result.fail())); } }
public JsonResult addNews(news news) { User user = (User)Session["user"]; if (user != null) { if (user.type == 1) { news.userId = user.id; news.date = DateTime.Now; DbNewsDataContext db = new DbNewsDataContext(); db.news.InsertOnSubmit(news); db.SubmitChanges(); return(Json(Result.success())); } else { return(Json(Result.fail())); } } else { return(Json(Result.fail())); } }
public JsonResult addUser(user requestData) { requestData.nickname = requestData.username; requestData.type = 0; DbNewsDataContext db = new DbNewsDataContext(); db.user.InsertOnSubmit(requestData); db.SubmitChanges(); return(Json(Result.success())); }
public JsonResult addComment(comment comment) { User user = (User)Session["user"]; if (user != null) { comment.userId = user.id; comment.status = 0; comment.date = DateTime.Now; DbNewsDataContext db = new DbNewsDataContext(); db.comment.InsertOnSubmit(comment); db.SubmitChanges(); return(Json(Result.success())); } else { return(Json(Result.fail())); } }
public JsonResult setUserPassword(User requestData) { User user = (User)Session["user"]; if (user != null) { DbNewsDataContext db = new DbNewsDataContext(); var query = from t in db.user where t.id == user.id select t; foreach (user item in query) { item.password = requestData.password; db.SubmitChanges(); } return(Json(Result.success())); } else { return(Json(Result.fail())); } }
public JsonResult addCategory(category category) { User user = (User)Session["user"]; if (user != null) { if (user.type == 1) { DbNewsDataContext db = new DbNewsDataContext(); db.category.InsertOnSubmit(category); db.SubmitChanges(); return(Json(Result.success())); } else { return(Json(Result.fail())); } } else { return(Json(Result.fail())); } }