public List <ShiftDTO> GetAllShiftsForClub(string month) { string query = "SELECT * FROM dienst WHERE MONTH(startMoment) = @month"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); // parameters.Add(new KeyValuePair<string, string>("id", id.ToString())); parameters.Add(new KeyValuePair <string, string>("month", month)); DataSet results = ExecuteQuery(query, parameters); List <ShiftDTO> shifts = new List <ShiftDTO>(); if (results != null) { for (int i = 0; i < results.Tables[0].Rows.Count; i++) { ShiftDTO shift = DataSetParser.DataSetToShift(results, i); if (shift.ID != 0) { // Get members ID query = "SELECT lidID FROM `lid-dienst-combo` WHERE dienstID=@id"; parameters.Clear(); parameters.Add(new KeyValuePair <string, string>("id", shift.ID.ToString())); DataSet res = ExecuteQuery(query, parameters); if (res.Tables[0].Rows.Count != 0) { int memberId = (int)res.Tables[0].Rows[0][0]; // Get actual member query = "SELECT * FROM leden WHERE id = @id"; parameters.Clear(); parameters.Add(new KeyValuePair <string, string>("id", memberId.ToString())); DataSet member = ExecuteQuery(query, parameters); // Add member to shift shift.Members = DataSetParser.DataSetToMember(member, 0); } } shifts.Add(shift); } } return(shifts); }
public ShiftDTO FindShiftById(int id) { string query = "Select * from dienst where id=@id"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); parameters.Add(new KeyValuePair <string, string>("id", id.ToString())); DataSet results = ExecuteQuery(query, parameters); ShiftDTO s = new ShiftDTO(); if (results != null && results.Tables[0].Rows.Count > 0) { s = DataSetParser.DataSetToShift(results, 0); } return(s); }
public List <ShiftDTO> GetAllShift() { string query = "Select * from dienst"; List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >(); DataSet results = ExecuteQuery(query, parameters); List <ShiftDTO> shifts = new List <ShiftDTO>(); if (results != null) { for (int x = 0; x < results.Tables[0].Rows.Count; x++) { ShiftDTO s = DataSetParser.DataSetToShift(results, x); shifts.Add(s); } } return(shifts); }