public ActionResult DeleteToFollow(int id = 0) { UC_Follow uf = db.UC_Follow.Find(id); db.UC_Follow.Remove(uf); db.SaveChanges(); return(RedirectToAction("FollowList")); }
//public void AddFollow(int userID, int classID) //{ // UC_Follow follow = Check(userID, classID); // if (follow == null) // { // follow = new UC_Follow(); // follow.UserID = userID; // follow.ClassID = classID; // db.UC_Follow.Add(follow); // } // db.SaveChanges(); //} public string AddFollow(int userID, int classID) { UC_Follow follow = Check(userID, classID); if (follow == null) { follow = new UC_Follow(); follow.UserID = userID; follow.ClassID = classID; db.UC_Follow.Add(follow); db.SaveChanges(); return("成功加入收藏"); } return("已收藏此課程"); }