private VehicleMakeModelDTOCollection makeCollectionToDTO(VehicleMakeCollection makeCollection) { VehicleMakeModelDTOCollection tempList = new VehicleMakeModelDTOCollection(); if (makeCollection !=null) { foreach(VehicleMake item in makeCollection) { if (string.IsNullOrEmpty(item.VehicleMakeName)) tempList.Add(new VehicleMakeModelDTO { VehicleMakeId = item.VehicleMakeId }); else tempList.Add(new VehicleMakeModelDTO { VehicleMakeId = item.VehicleMakeId, MakeName = item.VehicleMakeName }); } } return tempList; }
public static VehicleMakeCollection GetCollection() { VehicleMakeCollection tempList = null; using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("usp_GetVehicleMake", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollection); myConnection.Open(); using (SqlDataReader myReader = myCommand.ExecuteReader()) { if (myReader.HasRows) { tempList = new VehicleMakeCollection(); while (myReader.Read()) { tempList.Add(FillDataRecord(myReader)); } } myReader.Close(); } } } return tempList; }