internal void GetPeriod(Period p) { Request request = new Request() { Operation = Operation.GetPeriod, RequestObject = p }; SenderAndReceiver.Send(request); Response response = SenderAndReceiver.Receive() as Response; if (response.IsSuccessful) { throw new GetAllException(response.Error); } }
internal void Listen() { try { while (true) { Response response; try { Request request = senderAndReceiver.Receive() as Request; response = OperationHandler(request); } catch (Exception ex) { response = new Response() { IsSuccessful = false, Error = ex.Message }; } senderAndReceiver.Send(response); } } catch (Exception) { } }
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"); } }