public bool AddOrUpdateActivityVoteRecord(ActivityVote vote) { bool result = false; var conn = DBHelper.GetSqlConnection(); try { conn.Open(); result = activityDao.InsertOrUpdateActivityVote(conn, vote); } catch (Exception e) { LogService.Log("AddOrUpdateActivityVoteRecord--" + e.Message, e.ToString()); } finally { conn.Close(); } return result; }
public ActionResult UpdateVoteStatus(int activityId, bool isVoted) { var vote = new ActivityVote() { ActivityId = activityId, InsertedTimestamp = DateTime.Now, IsVoted = isVoted, LastUpdatedTimestamp = DateTime.Now, UserId = CurrentWeChatUser.UserId, WechatUserOpenId = CurrentWeChatUser.OpenId }; var result = service.AddOrUpdateActivityVoteRecord(vote); var data = new { IsSuccessFul = result }; return Json(data); }
public bool InsertOrUpdateActivityVote(SqlConnection conn, ActivityVote vote) { SqlParameter[] parameters = { new SqlParameter("@VoteId", vote.VoteId), new SqlParameter("@UserId", vote.UserId), new SqlParameter("@WechatUserOpenId", vote.WechatUserOpenId), new SqlParameter("@ActivityId", vote.ActivityId), new SqlParameter("@IsVoted", vote.IsVoted), new SqlParameter("@InsertedTimestamp", vote.InsertedTimestamp), new SqlParameter("@LastUpdatedTimestamp", vote.LastUpdatedTimestamp) }; DBHelper.CheckSqlSpParameter(parameters); return DBHelper.RunNonQueryProcedure(conn, "sp_InsertOrUpdateActivityVote", parameters) > 0; }