//public BindingSource findAllPart() { // BindingSource bindingSource = new BindingSource(); // foreach (Participant p in server.findAllParticipants()) // bindingSource.Add(p); // return bindingSource; //} public BindingSource findAllPartForEvent(Event e) { BindingSource bindingSource = new BindingSource(); foreach (Participant p in server.findPartForEvent(e)) { bindingSource.Add(p); } return(bindingSource); }
private Response handleRequest(Request request) { Response response = null; if (request is LoginRequest) { Console.WriteLine("Login request ..."); LoginRequest logReq = (LoginRequest)request; Organizer org = logReq.Organizer; try { lock (server) { server.login(org, this); } return(new OkResponse()); } catch (SwimException e) { connected = false; return(new ErrorResponse(e.Message)); } } if (request is LogoutRequest) { Console.WriteLine("Logout request"); LogoutRequest logReq = (LogoutRequest)request; Organizer org = logReq.Organizer; try { lock (server) { server.logout(org, this); } connected = false; return(new OkResponse()); } catch (SwimException e) { return(new ErrorResponse(e.Message)); } } if (request is GetEventsNosPartRequest) { Console.WriteLine("GetEventsNosPartRequest request ..."); try { lock (server) { return(new GetEventsNosPartResponse(server.findEventsNosParticipants())); } } catch (SwimException e) { return(new ErrorResponse(e.Message)); } } if (request is GetAllPart4EventRequest) { Console.WriteLine("Searching participants for event..."); GetAllPart4EventRequest partReq = (GetAllPart4EventRequest)request; Event ev = partReq.Event; try { lock (server) { return(new GetAllPart4EventResponse(server.findPartForEvent(ev))); } } catch (SwimException e) { return(new ErrorResponse(e.Message)); } } if (request is GetAllPartRequest) { Console.WriteLine("Searching all participants..."); try { lock (server) { return(new GetAllPartResponse(server.findAllParticipants())); } } catch (SwimException e) { return(new ErrorResponse(e.Message)); } } if (request is AddPart2EventRequest) { Console.WriteLine("Adding participant to event..."); AddPart2EventRequest partReq = (AddPart2EventRequest)request; EventPartDTO ev = partReq.EventPartDTOent; try { lock (server) { server.addPart2Event(ev); } return(new OkResponse()); } catch (SwimException e) { return(new ErrorResponse(e.Message)); } } if (request is AddParticipantRequest) { Console.WriteLine("Adding participant..."); AddParticipantRequest partReq = (AddParticipantRequest)request; Participant part = partReq.Participant; try { lock (server) { server.addParticipant(part); } return(new OkResponse()); } catch (SwimException e) { return(new ErrorResponse(e.Message)); } } return(response); }