Пример #1
0
        public bool dodajLicnePodatke(LicniPodaci p)
        {
            try
            {
                dodajAdresu(p.Adresa);

                if (!proveraDaLiPostojiTelefon(p.telefon))
                {
                    var query = new Neo4jClient.Cypher.CypherQuery(
                        "MATCH(Addr1:Adresa {UlicaIBroj: '" + p.Adresa.UlicaIBroj + "'})" +
                        "CREATE(LP1: LicniPodaci{ ime: '" + p.ime + "',prezime: '" + p.prezime + "'," +
                        "telefon: '" + p.telefon + "',datumRodjenja: '" + p.datumRodjenja + "'})" +
                        " CREATE (LP1)-[r:NALAZI_SE]->(Addr1) RETURN LP1",
                        new Dictionary <string, object>(), CypherResultMode.Set);
                    ((IRawGraphClient)client).ExecuteGetCypherResults <LicniPodaci>(query);

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Пример #2
0
        public Osoba vratiOsobu(int id)
        {
            try
            {
                var query = new Neo4jClient.Cypher.CypherQuery("start n=node(" + id + ") match (n)-[r:MOJI_PODACI]->(podaci)-[a:NALAZI_SE]->(adresa) return adresa",
                                                               new Dictionary <string, object>(), CypherResultMode.Set);
                Adresa adresa = ((IRawGraphClient)client).ExecuteGetCypherResults <Adresa>(query).ToList()[0];

                query = new Neo4jClient.Cypher.CypherQuery("start n=node(" + id + ") match (n)-[r:MOJI_PODACI]->(podaci) return podaci",
                                                           new Dictionary <string, object>(), CypherResultMode.Set);
                LicniPodaci podaci = ((IRawGraphClient)client).ExecuteGetCypherResults <LicniPodaci>(query).ToList()[0];
                podaci.Adresa = adresa;

                query = new Neo4jClient.Cypher.CypherQuery("start n=node(" + id + ") match (n)-[r:MOJA_AUTENTIFIKACIJA]->(auth) return auth",
                                                           new Dictionary <string, object>(), CypherResultMode.Set);
                Autentifikacija auth = ((IRawGraphClient)client).ExecuteGetCypherResults <Autentifikacija>(query).ToList()[0];


                query = new Neo4jClient.Cypher.CypherQuery("start n=node(" + id + ") match (n)-[k:IMA_KVAR]->(kvar)<-[r:U_RADIONICI]-(radionica) return radionica",
                                                           new Dictionary <string, object>(), CypherResultMode.Set);
                List <Radionica> radionice = ((IRawGraphClient)client).ExecuteGetCypherResults <Radionica>(query).ToList();

                query = new Neo4jClient.Cypher.CypherQuery("start n=node(" + id + ") match (n)-[k:IMA_KVAR]->(kvar) return kvar",
                                                           new Dictionary <string, object>(), CypherResultMode.Set);
                List <Kvar> kvarovi = ((IRawGraphClient)client).ExecuteGetCypherResults <Kvar>(query).ToList();

                query = new Neo4jClient.Cypher.CypherQuery("start n=node(" + id + ") match (n) return n",
                                                           new Dictionary <string, object>(), CypherResultMode.Set);
                Osoba k = ((IRawGraphClient)client).ExecuteGetCypherResults <Osoba>(query).ToList()[0];

                k.authPodaci = auth;
                k.podaci     = podaci;
                foreach (Kvar kv in kvarovi)
                {
                    k.kvarovi.Add(kv);
                }

                return(k);
            }
            catch (Exception e)
            {
                return(null);
            }
        }