public GetZboruriCautareRequest(ZborDTO2 zbor) { this.zbor = zbor; }
private object handleRequest(Request request) { Response response = null; if (request is LoginRequest) { Console.WriteLine("Login request ..."); LoginRequest logReq = (LoginRequest)request; Angajat angajat = logReq.Angajat; try { lock (server) { server.LogIn(angajat, this); } return(new OkResponse()); } catch (FlightException e) { connected = false; return(new ErrorResponse(e.Message)); } } if (request is LogoutRequest) { Console.WriteLine("Logout request ..."); LogoutRequest logReq = (LogoutRequest)request; Angajat angajat = logReq.User; try { lock (server) { server.LogOut(angajat, this); } return(new OkResponse()); } catch (FlightException e) { connected = false; return(new ErrorResponse(e.Message)); } } if (request is GetZboruriRequest) { Console.WriteLine("Flights get request"); GetZboruriRequest getReq = (GetZboruriRequest)request; IEnumerable <Zbor> zboruri; try { lock (server) { zboruri = server.GetZboruri(); } return(new GetZboruriResponse(zboruri)); } catch (FlightException e) { connected = false; return(new ErrorResponse(e.Message)); } } if (request is GetZboruriCautareRequest) { Console.WriteLine("Find fligts request"); GetZboruriCautareRequest getReq = (GetZboruriCautareRequest)request; ZborDTO2 zbor = getReq.zborDTO2; IEnumerable <ZborDTO> zborDTOs; try { lock (server) { zborDTOs = server.GetZboruriCautare(zbor.destinatie, zbor.data); } return(new GetZboruriCautareResponse(zborDTOs)); } catch (FlightException e) { connected = false; return(new ErrorResponse(e.Message)); } } if (request is FindClientRequest) { Console.WriteLine("Finding client"); FindClientRequest findReq = (FindClientRequest)request; ClientDTO clientDTO = findReq.Client; Client client; try { lock (server) { client = server.FindClient(clientDTO.nume, clientDTO.adresa); } return(new FindClientResponse(client)); } catch (FlightException e) { connected = false; return(new ErrorResponse(e.Message)); } } if (request is FindZborRequest) { Console.WriteLine("Finding flight"); FindZborRequest findReq = (FindZborRequest)request; ZborDTO3 zborDTO3 = findReq.ZborDTO3; Zbor zbor; try { lock (server) { zbor = server.FindZbor(zborDTO3.destinatie, zborDTO3.data, zborDTO3.ora); } return(new FindZborResponse(zbor)); } catch (FlightException e) { connected = false; return(new ErrorResponse(e.Message)); } } if (request is FindIndexRequest) { Console.WriteLine("Finding index"); FindIndexRequest findReq = (FindIndexRequest)request; int index; try { lock (server) { index = server.FindIndex(); } return(new FindIndexResponse(index)); } catch (FlightException e) { connected = false; return(new ErrorResponse(e.Message)); } } if (request is BuyTickeRequest) { Console.WriteLine("Ticket bought"); BuyTickeRequest req = (BuyTickeRequest)request; Bilet bilet = req.Bilet; int id = req.Id; int nr = req.NrLocuri; try { lock (server) { server.CumparaBilet(bilet, id, nr); } return(new OkResponse()); }catch (FlightException e) { Console.WriteLine(e.Message); } } return(response); }