Example #1
0
        public static Dictionary<string, string> UpdateRecord(StageData data)
        {
            using (var db = WebApiApplication.GetDB())
            {
                var transaction = db.BeginTransaction();
                string Message, ResultCode = null;

                try
                {
                    var command = new SqlCommand();
                    command.Connection = db;
                    command.Transaction = transaction;
                    command.CommandText = @"USP_StageUpdateRecord";
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.Add("@UserID", data.FacebookID);
                    command.Parameters.Add("@Point", data.Point);

                    command.Parameters.Add("@Message", SqlDbType.VarChar, 500);
                    command.Parameters["@Message"].Direction = ParameterDirection.Output;
                    command.Parameters.Add("@ResultCode", SqlDbType.Int);
                    command.Parameters["@ResultCode"].Direction = ParameterDirection.Output;

                    command.ExecuteNonQuery();
                    Message = command.Parameters["@Message"].Value.ToString();
                    command.ExecuteNonQuery();
                    ResultCode = command.Parameters["@ResultCode"].Value.ToString();
                    transaction.Commit();

                    Dictionary<string, string> dict = new Dictionary<string, string>();
                    dict.Add("Message", Message);
                    dict.Add("ResultCode", ResultCode.ToString());

                    return dict;
                }
                catch (System.Exception ex)
                {
                    Console.Write(ex.Message);
                    transaction.Rollback();
                    throw ex;
                }
            }
        }
Example #2
0
        public static StageResult UpdateRecord(StageData data)
        {
            StageResult result = new StageResult();
            using (var db = DB.GetDB())
            {

                try
                {
                    var command = new SqlCommand();
                    command.Connection = db;
                    command.CommandText = @"USP_StageUpdateRecord";
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.Add("@UserID", data.UserID);
                    command.Parameters.Add("@Point", data.Point);

                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        //Dictionary<string, string> dict = new Dictionary<string, string>();

                        result.ExpAfterGame = (int)reader["ExpAfterGame"];
                        result.ExpBeforeGame = (int)reader["ExpBeforeGame"];
                        result.LevelAfterGame = (int)reader["LevelAfterGame"];
                        result.LevelBeforeGame = (int)reader["LevelBeforeGame"];
                        result.IsLevelUp = (int)reader["IsLevelUp"];
                        result.Message = reader["Message"].ToString();
                        result.ResultCode = (int)reader["ResultCode"];

                    }
                    reader.Close();

                    return result;
                }
                catch (System.Exception ex)
                {
                    Console.Write(ex.Message);
                    throw ex;
                }
            }
        }
 // POST
 public Dictionary<string, string> Post(StageData Data)
 {
     Dictionary<string, string> return_json = StageModel.UpdateRecord(Data);
     return return_json;
 }
 /*
 URL     : /UpdateResult
 Method  : POST
 내용     : 스테이지 결과를 서버에 업로드해서 데이터베이스에 기록하는 API
 */
 public StageResult Post(StageData Data)
 {
     StageResult result = StageModel.UpdateRecord(Data);
     return result;
 }