public bool CreateDemand(Demand demand) { //TODO try catch XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = "\t"; using (XmlWriter writer = XmlWriter.Create(GetXmlFileName(demand.getId()), settings)) { writer.WriteStartDocument(); writer.WriteStartElement("demand"); writer.WriteAttributeString("id", demand.getId()); writer.WriteElementString("state", demand.getState()); writer.WriteElementString("teacherId", demand.getOwner()); writer.WriteElementString("roomId", demand.getRoomId()); writer.WriteElementString("subjectId", demand.getSubjectId()); writer.WriteElementString("subjectName", demand.getSubjectName()); writer.WriteElementString("day", demand.getDay()); writer.WriteElementString("startTime", demand.getStartTime()); writer.WriteElementString("endTime", demand.getEndTime()); writer.WriteEndElement(); writer.WriteEndDocument(); } return true; }
//Demand Submission private bool requestDemandSubmission(String selected_class = "", String day="", String startTime = "", String endTime="") { List<ClassRoom> rooms = db.getAllRoom(); cmd = tui.demandSubmissionMenu(rooms, selected_class, day, startTime, endTime); if (cmd.cmd != "exit") { Demand newDemand = new Demand(cmd.data[1], "null", userLoggedIn.getNeptunCode(), cmd.data[0], cmd.data[1], cmd.data[2], cmd.data[3], cmd.data[4], cmd.data[5]); if (db.demandSubmission(newDemand, userLoggedIn.getNeptunCode())) { tui.demandSubmission_successful(); return true; } else { tui.demandSubmission_unsuccessful(); return false; } } else { return false; } }
private int requestDemandChange(String demand_id) { Demand demand = db.getDemand(demand_id); ; cmd = tui.demandChangeSubMenu(demand, db.getAllRoom()); if (cmd.cmd != "exit") { Demand newDemand = new Demand(cmd.data[1], "null", userLoggedIn.getNeptunCode(), cmd.data[0], cmd.data[1], cmd.data[2], cmd.data[3], cmd.data[4], cmd.data[5]); bool ret = db.demandChange(newDemand); if (ret) { return 1; } else { return -1; } } else { return 0; } }
public CMD demandChangeSubMenu(Demand demand, List<ClassRoom> rooms) { position = 1; subMenuremove(15, countdemands); for (int i = 0; i < 20; i++) { Console.SetCursorPosition(i * 4, 9); Console.Write("____"); } Console.SetCursorPosition(1, 11); Console.Write("Adja meg, melyik termet szeretné igényelni a/az " + demand.getRoomId() + " helyett:"); Console.SetCursorPosition(5, 13); Console.Write(back + " "); countrooms = rooms.Count; for (int i = 0; i < countrooms; i++) { Console.SetCursorPosition(5, 15 + i); Console.Write(rooms[i].getId() + " "); } subMainUnderline(countrooms, 5); do { input = Console.ReadKey(); if (input.Key == ConsoleKey.DownArrow) position++; if (input.Key == ConsoleKey.UpArrow) position--; if (position < 1) position = countrooms + 1; if (position > countrooms + 1) position = 1; subMainUnderline(countrooms, 5); } while (input.Key != ConsoleKey.Enter); CMD command = new CMD(); command.data = new List<string>(); if (position == 1) command.cmd = "exit"; else command.data.Add(rooms[position - 2].getId()); String day = ""; switch(demand.getDay()) { case "Hetfo": day = "1"; break; case "Kedd": day = "2"; break; case "Szerda": day = "3"; break; case "Csutortok": day = "4"; break; case "Pentek": day = "5"; break; } String subjectID = ""; String subjectName = ""; String start = ""; String end = ""; if (command.cmd != "exit") { List<String> list; list = new List<string>(); list = demandSubMenu(demand.getSubjectId(), demand.getSubjectName(), day, demand.getStartTime(), demand.getEndTime()); subjectID = list[0]; subjectName = list[1]; day = list[2]; start = list[3]; end = list[4]; } String subjectDay = ""; switch (day) { case "1": subjectDay = "Hetfo"; break; case "2": subjectDay = "Kedd"; break; case "3": subjectDay = "Szerda"; break; case "4": subjectDay = "Csutortok"; break; case "5": subjectDay = "Pentek"; break; } if (position == 1) command.cmd = "exit"; else { command.data.Add(subjectID); command.data.Add(subjectName); command.data.Add(subjectDay); command.data.Add(start + ":00"); command.data.Add(end + ":00"); } return command; }
public bool ChangeDemand(Demand newDemand) { //TODO try catch CreateDemand(newDemand); return true; }
public bool demandSubmission(Demand newDemand, String neptun_code) { bool user = userHandler.AppendDemand(neptun_code, newDemand.getId()); bool demand = demandHandler.CreateDemand(newDemand); return user && demand; }
public bool demandChange(Demand newDemand) { return demandHandler.ChangeDemand(newDemand); }