Exemplo n.º 1
0
        public void Adauga(int id, string nume, string telefon, int bilet, Excursie ex, Agent ag)
        {
            RezervareDTO1 i = new RezervareDTO1(id, nume, telefon, bilet, ex, ag);

            sendRequest(new AdaugaRequest(i));
            Response res = readResponse();

            if (res is ErrorResponse)
            {
                ErrorResponse err = (ErrorResponse)res;
                throw new Exception(err.Message);
            }
        }
 public UpdateNrLocuriResponse(RezervareDTO1 soldTicket)
 {
     this.soldTicket = soldTicket;
 }
 public AdaugaResponse(RezervareDTO1 soldTicket)
 {
     this.rezv = soldTicket;
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public UpdateNrLocuriRequest(RezervareDTO1 soldTicket)
 {
     this.soldTicket = soldTicket;
 }
Exemplo n.º 6
0
 public AdaugaRequest(RezervareDTO1 soldTicket)
 {
     this.rezv = soldTicket;
 }