コード例 #1
0
        /// <summary>
        ///     更新七龙珠 用户信息
        /// </summary>
        /// <returns></returns>
        public static async Task <bool> UpdateDragonBallUserInfoModelAsync(BaseDbHelper dbHelper,
                                                                           DragonBallUserInfoModel model)
        {
            var sql = @" update Activity.[dbo].[tbl_DragonBallUserInfo]
                         set 
                                  [FinishMissionCount] = @FinishMissionCount
                                  ,[DragonBallCount] = @DragonBallCount
                                  ,DragonBallSummonCount = @DragonBallSummonCount
                                  ,LastUpdateDateTime = getdate()
                        where pkid = @pkid and LastUpdateDateTime = @LastUpdateDateTime and (DragonBallCount - @DragonBallCount) >= 0
                          ";

            using (var cmd = new SqlCommand(sql))
            {
                cmd.AddParameter("@FinishMissionCount", model.FinishMissionCount);
                cmd.AddParameter("@DragonBallCount", model.DragonBallCount);
                cmd.AddParameter("@DragonBallSummonCount", model.DragonBallSummonCount);


                cmd.AddParameter("@pkid", model.PKID);
                cmd.AddParameter("@LastUpdateDateTime", model.LastUpdateDateTime);

                var result = await dbHelper.ExecuteNonQueryAsync(cmd);

                return(result > 0);
            }
        }
コード例 #2
0
        /// <summary>
        ///     新增七龙珠 用户信息
        /// </summary>
        /// <returns></returns>
        public static async Task <long> InsertDragonBallUserInfoModelAsync(BaseDbHelper dbHelper,
                                                                           DragonBallUserInfoModel model)
        {
            var sql = @" insert into  Activity.[dbo].[tbl_DragonBallUserInfo]
                         (  
                            UserId,
                            FinishMissionCount,
                            DragonBallCount,
                            DragonBallSummonCount,
                            CreateDatetime,
                            LastUpdateDateTime
                         )
                         values (
                            @UserId,
                            @FinishMissionCount,
                            @DragonBallCount,
                            @DragonBallSummonCount,
                            getdate(),
                            getdate()
                         );
                        SELECT SCOPE_IDENTITY();
                          ";

            using (var cmd = new SqlCommand(sql))
            {
                cmd.AddParameter("@userid", model.UserId);
                cmd.AddParameter("@FinishMissionCount", model.FinishMissionCount);
                cmd.AddParameter("@DragonBallCount", model.DragonBallCount);
                cmd.AddParameter("@DragonBallSummonCount", model.DragonBallSummonCount);


                var result = await dbHelper.ExecuteScalarAsync(cmd);

                return(Convert.ToInt64(result));
            }
        }