static public void updatelikeviews(string str, string count) { if (user_id == null) { System.Web.HttpContext.Current.Response.Write("<script>alert('你还没有登录!先去登录吧');location.href='/Views/Index/Index.aspx'</script>"); } Like like_two = new Like(); like_two.articleId = article.articleId; like_two.accountId = user_id; article.likes = Int32.Parse(count); articleDao.Update(article); List <Like> likes = likeDao.GetListByAccount(user_id); foreach (Like like in likes) { if (like.articleId == id) { likeDao.Delete(like); return; } } if (str == "已赞") { likeDao.Delete(like_two); } if (str == "赞") { likeDao.Insert(like_two); } }
public bool Delete(Like like) { return(dao.Delete(like)); }