Example #1
0
        /// <summary>
        /// 赞某一动态
        /// </summary>
        /// <param name="activityId"></param>
        /// <param name="userId"></param>
        /// <param name="operSuccess">是否成功:如果是false,则表明用户已经赞过了,不能重复赞</param>
        /// <returns></returns>
        public int PraiseActivity(int activityId, int userId, out bool operSuccess)
        {
            var sqlwhere = string.Format("Int_ActivityPraise.ActivityId={0} AND Int_ActivityPraise.UserId={1}",
                                         activityId, userId);
            var model = _dataAccess.GetList <ActivityPraise>(sqlwhere).FirstOrDefault();

            if (model == null)
            {
                model            = new ActivityPraise();
                model.ActivityId = activityId;
                model.UserId     = userId;
                model.PraiseTime = DateTime.Now;
                _dataAccess.AddEntity(model);
                //更新冗余
                _dataAccess.UpdateField("Int_UserActivity", "PraiseCount", "PraiseCount+1", "ActivityId=" + activityId);
                operSuccess = true;
            }
            else
            {
                operSuccess = false;
            }

            return
                ((int)_dataAccess.ExecuteScalar(
                     "SELECT PraiseCount FROM Int_UserActivity WHERE ActivityId=" + activityId));
        }
Example #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ActivityPraise model)
 {
     return(_dataAccess.UpdateEntity(model) > 0);
 }
Example #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(ActivityPraise model)
 {
     return(_dataAccess.AddEntity(model));
 }