public bool Follow(CommunityPoco community) { User_Communities UC = new User_Communities(); UC.CommunitieId = community.Id; UC.UserId = community.userId; UC.FollowingDate = DateTime.Now; var cs = db.User_Communities.OrderByDescending(c => c.Sort).FirstOrDefault(u => u.UserId == community.userId).Sort; if (cs == null) { UC.Sort = 1; } else { UC.Sort = ++cs; } db.User_Communities.Add(UC); if (db.SaveChanges() > 0) { return(true); } else { return(false); } }
public bool UnFollow(CommunityPoco community) { User_Communities UC = new User_Communities(); var cs = db.User_Communities.Single(uc => uc.CommunitieId == community.Id && uc.UserId == community.userId); db.User_Communities.Remove(cs); if (db.SaveChanges() > 0) { return(true); } else { return(false); } }
public ActionResult UnFollow(CommunityPoco comunityInfo) { bool result = data.UnFollow(comunityInfo); return(Json(result, JsonRequestBehavior.AllowGet)); }