public IEnumerable <Coach> GetCoaches() { var result = new List <Coach>(); using (SqlConnection connection = new SqlConnection(connectionstring)) { SqlCommand cmd = new SqlCommand("GetCoaches", connection); //SQL-команда cmd.CommandType = System.Data.CommandType.StoredProcedure; connection.Open(); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) //пока читаем { int idCoach = (int)read["IDCoach"]; string firstName = (string)read["FirstName"]; string lastName = (string)read["LastName"]; string telephoneNumber = (string)read["TelephoneNumber"]; int? mainHall = read["MainHall"] as int?; if (mainHall.HasValue) { var coach = new Coach { IDCoach = idCoach, FirstName = firstName, LastName = lastName, TelephoneNumber = telephoneNumber, MainHall = _hallDao.GetNeedHalls((int)read["MainHall"]) }; result.Add(coach); } else { var coach = new Coach { IDCoach = idCoach, FirstName = firstName, LastName = lastName, TelephoneNumber = telephoneNumber, MainHall = "NULL" }; result.Add(coach); } } } return(result); }
public string GetNeedHalls(int idHall) { return(_hallDao.GetNeedHalls(idHall)); }
public IEnumerable <Hall> GetNeedHalls(int idHall) { return(hallDao.GetNeedHalls(idHall)); }