private void CreateRequests() { int i = 1; int[] iray = { 0, 1, 2, 3, 4, 5, 6, 7 }; Random rand = new Random(); int reqcode; foreach (Group group in groups) { reqcode = rand.Next(7); RequestClassroom request = new RequestClassroom(group.Id, group.Size(), reqcode); requests.Add(request); i++; } }
//takes boolbits from DB and creates a binary code to int... Denne metode skal bruges når DB-table // over classRoomWaitingList skal omskrives til objekter. Objektet skal dannes som et // RequestClassroom med denne property requestCode. public List <RequestClassroom> GetAllRequests() { List <RequestClassroom> stillNotFulfilled = new List <RequestClassroom>(); using (var con = new DBCon()) { SqlDataReader rs = con.ExecuteStringGet("SELECT * FROM ClassRoomWaitinglist"); int tempId = 0; int tempGroupId = 0; int tempSize = 0; int requestCode = 0; bool bitWhiteboard = false; bool bitMonitor = false; bool bitProjector = false; if (rs.HasRows) { while (rs.Read()) { tempId = (int)rs.GetValue(0); tempGroupId = (int)rs.GetValue(1); tempSize = (int)rs.GetValue(2); bitWhiteboard = (bool)rs.GetValue(3); bitMonitor = (bool)rs.GetValue(4); bitProjector = (bool)rs.GetValue(5); requestCode = CreateBinaryCode(bitWhiteboard, bitMonitor, bitProjector); RequestClassroom requestClassroom = new RequestClassroom(tempGroupId, tempSize, requestCode); stillNotFulfilled.Add(requestClassroom); } } } return(stillNotFulfilled); }