public List <Excursie> cauta(string nume, int intre1, int intre2) { return(server.Cauta(nume, intre1, intre2)); }
private object handleRequest(Request request) { Response response = null; if (request is LoginRequest) { Console.WriteLine("Login request ..."); LoginRequest logReq = (LoginRequest)request; Agent userDTO = logReq.User; try { bool ok = false; lock (server) { ok = server.Login(userDTO.Id, userDTO.Password, this); } if (ok == true) { return(new OkResponse()); } connected = false; return(new ErrorResponse("Invalid connection...")); } catch (Exception e) { connected = false; return(new ErrorResponse(e.Message)); } } if (request is GetAllRequest) { Console.WriteLine("GetAll request"); try { ExcursieDTO meciuriDTO = null; lock (server) { List <Excursie> meciuri = new List <Excursie>(); foreach (Excursie meci in server.GetAllE()) { meciuri.Add(meci); } meciuriDTO = new ExcursieDTO(meciuri); } return(new GetAllResponse(meciuriDTO)); } catch (Exception me) { return(new ErrorResponse(me.Message)); } } if (request is GetAllAvailableRequest) { Console.WriteLine("GetAllAvailable request"); try { RezervareDTO meciuriDTO = null; lock (server) { List <Rezervare> meciuri = new List <Rezervare>(); foreach (Rezervare meci in server.GetAll()) { meciuri.Add(meci); } meciuriDTO = new RezervareDTO(meciuri); } return(new GetAllAvailableResponse(meciuriDTO)); } catch (Exception me) { return(new ErrorResponse(me.Message)); } } if (request is CautaRequest) { Console.WriteLine("Cauta request"); try { List <Excursie> soldTickets = new List <Excursie>(); CautaDTO meciuriDTO; CautaRequest saveRequest = (CautaRequest)request; IntervalDTO req = saveRequest.Cautat; lock (server) { soldTickets = server.Cauta(req.Nume, req.Intre1, req.Intre2); meciuriDTO = new CautaDTO(soldTickets); } return(new CautaResponse(meciuriDTO)); } catch (Exception me) { return(new ErrorResponse(me.Message)); } } if (request is AdaugaRequest) { Console.WriteLine("Adauga request"); try { AdaugaRequest updateMecirequest = (AdaugaRequest)request; RezervareDTO1 req = updateMecirequest.Ticket; lock (server) { server.Adauga(req.Id, req.Nume, req.Telefon, req.Bilet, req.Ex, req.Ag); } return(new AdaugaResponse()); } catch (Exception me) { return(new ErrorResponse(me.Message)); } } return(response); }