public List <Zbor> getAllFlight()
        {
            List <Zbor> res = new List <Zbor>();

            sendRequest(new GetFlightsRequest());
            IResponse response = readResponse();

            if (response is GetFlightsResponse)
            {
                GetFlightsResponse r = (GetFlightsResponse)response;
                res = DTOUtils.getFromDTO(r.Flights);
            }
            return(res);
        }
Beispiel #2
0
        private IResponse handleRequest(IRequest request)
        {
            IResponse response = null;

            if (request is LogInRequest)
            {
                Console.WriteLine("Login request ...");
                LogInRequest logReq = (LogInRequest)request;
                AngajatDTO   udto   = logReq.User;
                Angajat      user   = DTOUtils.getFromDTO(udto);

                try
                {
                    lock (server)
                    {
                        bool ok = server.logIn(user.User, user.Parola);
                        if (ok == true)
                        {
                            response = new OkResponse();
                        }
                        else
                        {
                            response = new ErrorResponse("log in error");
                        }
                    }
                }
                catch (Exception e)
                {
                    connected = false;
                    return(new ErrorResponse(e.Message));
                }
            }
            else
            if (request is GetFlightsRequest)
            {
                List <Zbor> flights = new List <Zbor>();
                flights  = server.getAllFlight();
                response = new GetFlightsResponse(DTOUtils.getDTO(flights));
            }
            else
            if (request is SearchFlightsRequest)
            {
                SearchFlightsRequest r       = (SearchFlightsRequest)request;
                List <Zbor>          flights = new List <Zbor>();
                flights  = server.findByDestinatieDataplecareFlight(r.Destinatie, r.DataPlecare);
                response = new SearchFlightsResponse(DTOUtils.getDTO(flights));
            }
            else
            if (request is AddBiletRequest)
            {
                AddBiletRequest r = (AddBiletRequest)request;
                server.addBilet(r.Client, r.Turisti, r.Adresa, r.IdDestinatie);
                response = new AddBiletResponse();
            }
            else
            {
                if (request is FindByIdZborRequest)
                {
                    FindByIdZborRequest r = (FindByIdZborRequest)request;
                    Zbor z = server.findByIdZbor(r.IdZbor);
                    response = new FindByIdResponse(DTOUtils.getDTO(z));
                }
            }
            return(response);
        }