public override Task <GetLeadersResponse> GetLeaders(BlankMsg request, ServerCallContext context) { var tmp = new GetLeadersResponse(); _dbConnection.Open(); var command = "SELECT WorkerID, Name, TeamName, TeamID FROM Worker WHERE Level = 1"; var newCommand = new SqlCommand(command, _dbConnection); var dataReader = newCommand.ExecuteReader(); while (dataReader.Read()) { tmp.Leaders.Add(new leaderItem { LeaderId = dataReader.GetInt32(0), LeaderName = dataReader.GetString(1), TeamName = dataReader.GetString(2), TeamId = dataReader.GetInt32(3) }); } dataReader.Close(); _dbConnection.Close(); return(System.Threading.Tasks.Task.FromResult(tmp)); }
public override Task <TeamListResp> GetAllWorkers(BlankMsg request, ServerCallContext context) { TeamListResp tmp = new TeamListResp(); DBConnection.Open(); String command = "SELECT WorkerID, Name FROM Worker"; SqlCommand newCommand = new SqlCommand(command, DBConnection); SqlDataReader dataReader = newCommand.ExecuteReader(); while (dataReader.Read()) { tmp.TeamDesc.Add(new TeamDescription { Index = dataReader.GetInt32(0), Name = dataReader.GetString(1) }); } dataReader.Close(); DBConnection.Close(); return(System.Threading.Tasks.Task.FromResult(tmp)); }
public override Task <DepartmentsListResp> GetDepartments(BlankMsg request, ServerCallContext context) { var tmp = new DepartmentsListResp(); _dbConnection.Open(); String command = "SELECT * FROM Department"; SqlCommand newCommand = new SqlCommand(command, _dbConnection); SqlDataReader dataReader = newCommand.ExecuteReader(); while (dataReader.Read()) { tmp.DepsDesc.Add(new DepartmentDescription { Index = dataReader.GetInt32(0), Name = dataReader.GetString(1) }); } dataReader.Close(); _dbConnection.Close(); return(System.Threading.Tasks.Task.FromResult(tmp)); }