public object Get(UserTaskDetails request) { if (request.UserId == -1) { return(BadRequestResponse()); } try { var response = new Dictionary <string, dynamic> { { "success", 0 }, { "error", 0 } }; using (var conn = DbHelper.OpenConnection()) { var cmd = new MySqlCommand { Connection = conn, CommandText = "GetTeamMemberDetails", CommandType = CommandType.StoredProcedure, }; cmd.Parameters.AddWithValue("UserId", request.UserId); var reader = cmd.ExecuteReader(); if (reader.HasRows) { response["success"] = 1; var i = 0; while (reader.Read()) { if (i == 0) { response["nickname"] = reader.GetString("u_nickname"); response["tname"] = reader.GetString("t_name"); } response.AddToDynamicList("tasks", new { taskname = reader.GetString("tsk_name"), taskstatus = reader.IsDBNull("status") ? 0 : reader.GetInt32("status"), time_spent = reader.IsDBNull("time_spent") ? 0 : reader.GetInt64("time_spent"), }); i++; } } else { response["error"] = 1; response["error_msg"] = "No team members found."; } } return(response); } catch (Exception e) { Log.Error(e.Message, e); throw; } }
public object Get(UserTaskDetails request) { if (request.UserId == -1) return BadRequestResponse(); try { var response = new Dictionary<string, dynamic> { { "success", 0 }, { "error", 0 } }; using (var conn = DbHelper.OpenConnection()) { var cmd = new MySqlCommand { Connection = conn, CommandText = "GetTeamMemberDetails", CommandType = CommandType.StoredProcedure, }; cmd.Parameters.AddWithValue("UserId", request.UserId); var reader = cmd.ExecuteReader(); if (reader.HasRows) { response["success"] = 1; var i = 0; while (reader.Read()) { if (i == 0) { response["nickname"] = reader.GetString("u_nickname"); response["tname"] = reader.GetString("t_name"); } response.AddToDynamicList("tasks", new { taskname = reader.GetString("tsk_name"), taskstatus = reader.IsDBNull("status") ? 0 : reader.GetInt32("status"), time_spent = reader.IsDBNull("time_spent") ? 0 : reader.GetInt64("time_spent"), }); i++; } } else { response["error"] = 1; response["error_msg"] = "No team members found."; } } return response; } catch (Exception e) { Log.Error(e.Message, e); throw; } }