Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Pineczive.Models.Data_Access
- {
- public class LeagueGatewayXML : ILeague
- {
- // VRÁTÍ SEZNAM VŠECH LEAGUE
- public List<League> getLeagues()
- {
- List<League> temp = new List<League>();
- List<string> tempIds = new List<string>();
- List<string> tempNames = new List<string>();
- XDocument doc = XDocument.Load("C:\\Users\\Saphiron\\documents\\visual studio 2012\\Projects\\Pineczive\\Pineczive\\App_Data\\Leagues.xml");
- var ids = doc.Descendants("id");
- var names = doc.Descendants("name");
- foreach (var i in ids)
- {
- tempIds.Add(i.Value.ToString());
- }
- foreach (var n in names)
- {
- tempNames.Add(n.Value.ToString());
- }
- for (int i = 0; i < tempIds.Count(); i++)
- {
- temp.Add(new League(tempIds[i], tempNames[i], false, "cze",string.Empty, string.Empty));
- }
- return temp;
- }
- }
- }
- namespace Pineczive.Models.Data_Access
- {
- public class LeagueGateway : Connection, ILeague
- {
- private SqlCommand myCommand;
- // VRÁTÍ SEZNAM VŠECH LEAGUE
- public List<League> getLeagues()
- {
- string commandText = "SELECT * FROM League";
- List<League> leagueList = new List<League>();
- using (SqlConnection conn = base.NewConnection())
- {
- conn.Open();
- myCommand = new SqlCommand(commandText, conn);
- SqlDataReader myReader = null;
- myReader = myCommand.ExecuteReader();
- while (myReader.Read())
- {
- leagueList.Add(new League(myReader[0].ToString(), myReader[1].ToString(), Boolean.Parse(myReader[2].ToString()), myReader[3].ToString(), myReader[4].ToString(), myReader[5].ToString()));
- }
- myReader.Close();
- conn.Close();
- return leagueList;
- }
- }
- }
- }
- namespace Pineczive.Models.Business_Logic
- {
- interface ILeague
- {
- List<Models.League> getLeagues();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment