//there must be always a method in the Program class that will be called to obtain the data public static object GetData() { var data = new SenderAndReceiver(); data.Name = "John"; data.Sender = "Sally"; return(data); }
internal void Connect() { if (socket != null && socket.Connected) { return; } socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(ConfigurationManager.AppSettings["ip"], Int32.Parse(ConfigurationManager.AppSettings["port"])); SenderAndReceiver = new SenderAndReceiver(socket); }
internal void SaveAbsentsAndPeriod(Period period) { Request request = new Request() { Operation = Operation.AddAbsentsAndPeriod, RequestObject = period }; SenderAndReceiver.Send(request); Response response = SenderAndReceiver.Receive() as Response; if (!response.IsSuccessful) { throw new AddException(response.Error); } }
internal void SaveStudent(Student student) { Request request = new Request() { Operation = Operation.AddStudent, RequestObject = student }; SenderAndReceiver.Send(request); Response response = SenderAndReceiver.Receive() as Response; if (!response.IsSuccessful) { throw new AddException(response.Error); } }
internal void SaveTeacher(Teacher teacher) { Request request = new Request() { Operation = Operation.AddTeacher, RequestObject = teacher }; SenderAndReceiver.Send(request); Response response = SenderAndReceiver.Receive() as Response; if (!response.IsSuccessful) { throw new AddException(response.Error); } }
internal void SaveSchoolClass(SchoolClass schoolClass) { Request request = new Request() { Operation = Operation.AddSchoolClass, RequestObject = schoolClass }; SenderAndReceiver.Send(request); Response response = SenderAndReceiver.Receive() as Response; if (!response.IsSuccessful) { throw new AddException(response.Error); } }
internal List <SchoolClass> GetAllSchoolClasses() { Request request = new Request() { Operation = Operation.GetAllSchoolClasses }; SenderAndReceiver.Send(request); Response response = SenderAndReceiver.Receive() as Response; if (!response.IsSuccessful) { throw new GetAllException(response.Error); } return(response.Result as List <SchoolClass>); }
internal List <Student> GetAllStudentsFromSchoolClass(SchoolClass selectedItem) { Request request = new Request() { Operation = Operation.GetAllStudentsFromSchoolClass, RequestObject = selectedItem }; SenderAndReceiver.Send(request); Response response = SenderAndReceiver.Receive() as Response; if (!response.IsSuccessful) { throw new Exception(response.Error); } return(response.Result as List <Student>); }
internal List <Student> GetAllGradesForStudents(List <Student> students) { Request request = new Request() { Operation = Operation.GetAllGrades, RequestObject = students }; SenderAndReceiver.Send(request); Response response = SenderAndReceiver.Receive() as Response; if (!response.IsSuccessful) { throw new GetAllException(response.Error); } return(response.Result as List <Student>); }
internal object Login(Admin user) { Request request = new Request() { Operation = Operation.Login, RequestObject = user }; SenderAndReceiver.Send(request); Response response = SenderAndReceiver.Receive() as Response; if (response.IsSuccessful) { return(response.Result); } else { throw new LoginException("User doesn't exist"); } }
public ClientHandler(Socket client, Server server) { this.client = client; this.server = server; senderAndReceiver = new SenderAndReceiver(client); }