Esempio n. 1
0
        private bool Retrieve(CriminalEvent criminalEvent, out string result)
        {
            result = string.Empty;

            try
            {
                if (criminalEvent == null)
                {
                    result = "Record To Create Is Null";

                    return(false);
                }

                if (!crud.Create(criminalEvent, out result))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception e)
            {
                result = e.Message;

                return(false);
            }
        }
Esempio n. 2
0
    static void Main(string[] args)
    {
        TestClass testClass = new TestClass();

        testClass.Create();
        var crud = new Crud <Person>();

        // Note we're not specifying an ID for *new* entities, the Crud class needs to assign it upon saving
        crud.Create(new Person()
        {
            Name = "Someone", Age = 24
        });
        crud.Create(new Person()
        {
            Name = "Someone2", Age = 24
        });
        var list = crud.ReadAll();

        list.ForEach(x => Console.WriteLine("{0} {1}", x.Id, x.Name));

        var person1 = list.Single(x => x.Id == 1);

        person1.Name = "Someone3";
        person1.Age  = 20;
        Crud.Update(person1);
        Console.ReadKey();
    }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Literatura l = new Literatura {
                Naslov          = textBox1.Text,
                GodinaIzdavanja = int.Parse(textBox2.Text),
                Autori          = listaAutora
            };

            Knjiga k = new Knjiga
            {
                ISBN       = textBox4.Text,
                Izdavac    = textBox3.Text,
                Literatura = l
            };

            ISession s = DataLayer.GetSession();

            Crud <Literatura> .Create(s, l);

            Crud <Knjiga> .Create(s, k);

            s.Close();

            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";

            dataGridView1.DataSource = null;
            dataGridView1.Update();
            dataGridView1.Refresh();
        }
Esempio n. 4
0
        public override void InitRemotable(DextopRemote remote, DextopConfig config)
        {
            base.InitRemotable(remote, config);
            var crud = new Crud();

            crud.Create(new[] { new GridModel {
                                    Name       = "Player 1",
                                    Age        = 30,
                                    Basketball = true,
                                    Football   = true,
                                    Gender     = Gender.Male,
                                    Height     = 180,
                                    Weight     = 100
                                }, new GridModel {
                                    Name       = "Player 2",
                                    Age        = 29,
                                    Basketball = true,
                                    Football   = true,
                                    Gender     = Gender.Male,
                                    Height     = 175,
                                    Weight     = 90
                                } });
            Remote.AddStore("model", crud);
            Remote.AddLookupData("Gender", new[] {
                new object[] { Gender.Male, "Male" },
                new object[] { Gender.Female, "Female" }
            });
        }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            Literatura l = new Literatura
            {
                Naslov          = textBox1.Text,
                GodinaIzdavanja = int.Parse(textBox2.Text),
                Autori          = listaAutora
            };

            Clanak c = new Clanak
            {
                Broj_casopisa = int.Parse(textBox3.Text),
                ISSN          = textBox4.Text,
                Literatura    = l
            };

            ISession s = DataLayer.GetSession();

            Crud <Literatura> .Create(s, l);

            Crud <Clanak> .Create(s, c);

            s.Close();

            textBox1.Text            = "";
            textBox2.Text            = "";
            textBox3.Text            = "";
            textBox4.Text            = "";
            dataGridView1.DataSource = null;
            dataGridView1.Update();
            dataGridView1.Refresh();
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            ISession s = DataLayer.GetSession();

            Literatura l = new Literatura
            {
                Naslov          = textBox1.Text,
                GodinaIzdavanja = int.Parse(textBox2.Text),
                Autori          = listaAutora
            };

            Rad r = new Rad
            {
                MestoObjavljivanja = textBox4.Text,
                URL             = textBox3.Text,
                FormatDokumenta = textBox5.Text,
                Literatura      = l
            };

            Crud <Literatura> .Create(s, l);

            Crud <Rad> .Create(s, r);

            s.Close();

            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";

            dataGridView1.DataSource = null;
            dataGridView1.Update();
            dataGridView1.Refresh();
        }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            ISession s     = DataLayer.GetSession();
            int      index = comboBox1.SelectedIndex;
            int      id    = IdPredmeta[index];

            Predmet predmet = Crud <Predmet> .Read(s, id);

            TeorijskiProjekat t = new TeorijskiProjekat
            {
                Ime                  = textBox2.Text,
                MaxBrojStrana        = int.Parse(textBox1.Text),
                SkolskaGodina        = textBox3.Text,
                PojedinacnoIliGrupno = textBox4.Text,
                Predmet              = predmet
            };

            Crud <TeorijskiProjekat> .Create(s, t);

            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";

            s.Close();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow != null && trenutnoIzabraniTim != -1)
            {
                ISession s          = DataLayer.GetSession();
                int      ProjekatId = int.Parse(dataGridView2.CurrentRow.Cells[0].Value.ToString());
                Projekat p          = Crud <Projekat> .Read(s, ProjekatId);

                Tim t = Crud <Tim> .Read(s, trenutnoIzabraniTim);

                ProjekatTim veza = new ProjekatTim()
                {
                    DatumBiranja = DateTime.Now,
                    RokPredaje   = DateTime.Now.AddMonths(3),
                    Projekat     = p,
                    Tim          = t
                };
                Crud <ProjekatTim> .Create(s, veza);

                Tim tim = Crud <Tim> .Read(s, trenutnoIzabraniTim);

                dataGridView3.DataSource = null;
                dataGridView3.Update();
                dataGridView3.Refresh();
                dataGridView3.DataSource         = tim.Projekti;
                dataGridView3.Columns[0].Visible = false;
                dataGridView3.Columns[5].Visible = false;
                dataGridView3.Columns[4].Visible = false;
                s.Close();
            }
        }
 // POST api/clanak
 public void Post([FromBody] WebStranice WebStranice)
 {
     //linija je dodata da bi mogli da testiramo sa objektima koje dobijemo kao rezultat
     //kontrolera ge. Potavlja se objekat iz baze, zbog toga sto je u odgovarajucoj tabeli spoljni kljuc obavezan
     WebStranice.PrakticniProjekat = new PrakticniProjekat()
     {
         Id = 167
     };
     Crud <WebStranice> .Create(sesija, WebStranice);
 }
Esempio n. 10
0
 // POST api/clanak
 public void Post([FromBody] Rad Rad)
 {
     //linija je dodata da bi mogli da testiramo sa objektima koje dobijemo kao rezultat
     //kontrolera ge. Potavlja se objekat iz baze, zbog toga sto je u odgovarajucoj tabeli spoljni kljuc obavezan
     Rad.Literatura = new Literatura()
     {
         Id = 81
     };
     Crud <Rad> .Create(sesija, Rad);
 }
Esempio n. 11
0
 // POST api/clanak
 public void Post([FromBody] PrakticniProjekat PrakticniProjekat)
 {
     //linija je dodata da bi mogli da testiramo sa objektima koje dobijemo kao rezultat
     //kontrolera ge. Potavlja se objekat iz baze, zbog toga sto je u odgovarajucoj tabeli spoljni kljuc obavezan
     PrakticniProjekat.Predmet = new Predmet()
     {
         Id = 44
     };
     Crud <PrakticniProjekat> .Create(sesija, PrakticniProjekat);
 }
Esempio n. 12
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            //To make this thing work you first need to make an instance of the Crud class and fill in the asked parameters.
            Crud Connection = new Crud("your server.com", "your database", "your username", "your password");

            //Then you can what you want, with data you can do 4 things, create, read, update and delete, in short terms (CRUD)

            //-Create: C-//
            Contact AContact = new Contact();

            AContact.Name  = "Steven";
            AContact.Email = "*****@*****.**";

            Connection.Create(AContact);
            //---------//

            //-Read: R-//
            List <Tag> ListOfAllTags = Connection.SelectAll <Tag>();

            Tag ATag = new Tag();

            ATag.Name = "you search value";

            List <Tag> ListOfSpecificTags = Connection.SelectWhere(ATag);
            //---------//

            //-Update: U-//
            //The id needs to be set in the update object otherwise the update cant work because the id will be 0.
            Tag UpdateTag = new Tag();

            UpdateTag.Id   = 6;
            UpdateTag.Name = "Dependency Injection";

            Connection.Update <Tag>(UpdateTag);
            //---------//

            //-Delete: D-//
            Tag DeleteTag = new Tag();

            DeleteTag.Id   = 4;
            DeleteTag.Name = "Sander Moerman";

            Connection.Delete(ATag);
            //---------//
        }
        public override void InitRemotable(DextopRemote remote, DextopConfig config)
        {
            base.InitRemotable(remote, config);

            var crud = new Crud();

            crud.Create(new[] { new GridModel {
                                    Name   = "John Doe",
                                    Age    = 24,
                                    Gender = Gender.Male,
                                    Height = 183
                                }, new GridModel {
                                    Name       = "Jane Doe",
                                    Age        = 25,
                                    Basketball = true,
                                    Volleyball = true,
                                    Gender     = Gender.Female,
                                    Height     = 165
                                }, new GridModel {
                                    Name     = "John Wayne",
                                    Age      = 72,
                                    Football = true,
                                    Gender   = Gender.Male,
                                    Height   = 180
                                }, new GridModel {
                                    Name       = "Laura Palmer",
                                    Age        = 70,
                                    Basketball = true,
                                    Football   = true,
                                    Gender     = Gender.Female,
                                    Height     = 172
                                }, new GridModel {
                                    Name       = "Mariah Carrey",
                                    Age        = 43,
                                    Basketball = true,
                                    Football   = true,
                                    Volleyball = true,
                                    Gender     = Gender.Female,
                                    Height     = 170
                                } });
            Remote.AddStore("model", crud);
            Remote.AddLookupData("Gender", new[] {
                new object[] { Gender.Male, "Male" },
                new object[] { Gender.Female, "Female" }
            });
        }
Esempio n. 14
0
        private void button7_Click(object sender, EventArgs e)
        {
            Tim t = new Tim
            {
                Ime      = textBox9.Text,
                Studenti = listaStudenata
            };

            t.BrojClanova = int.Parse(textBox10.Text);

            ISession s = DataLayer.GetSession();

            Crud <Tim> .Create(s, t);

            s.Close();

            textBox9.Text  = "";
            textBox10.Text = "";
        }
Esempio n. 15
0
        private void button1_Click(object sender, EventArgs e)
        {
            Izvestaj i = new Izvestaj
            {
                Opis         = textBox9.Text,
                RokPredaje   = DateTime.Parse(textBox8.Text),
                VremePredaje = DateTime.Parse(textBox7.Text)
            };

            int index            = comboBox1.SelectedIndex;
            int id               = IdProjekta[index];
            PrakticniProjekat pp = Crud <PrakticniProjekat> .Read(s, id);

            i.PrakticniProjekat = pp;

            Crud <Izvestaj> .Create(s, i);

            textBox9.Text = "";
            textBox8.Text = "";
            textBox7.Text = "";
        }
Esempio n. 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            int sem = Int32.Parse(textBox3.Text);

            Predmet p = new Predmet
            {
                Ime      = textBox2.Text,
                Sifra    = textBox1.Text,
                Semestar = sem,
                Katedra  = textBox4.Text
            };

            ISession s = DataLayer.GetSession();

            Crud <Predmet> .Create(s, p);

            textBox2.Text = "";
            textBox1.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";

            s.Close();
        }
Esempio n. 17
0
        private void button1_Click(object sender, EventArgs e)
        {
            Student student = new Student
            {
                BrojIndeksa  = int.Parse(textBox1.Text),
                Ime          = textBox2.Text,
                ImeRoditelja = textBox3.Text,
                Prezime      = textBox4.Text,
                Smer         = textBox5.Text
            };

            ISession s = DataLayer.GetSession();

            Crud <Student> .Create(s, student);

            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";


            s.Close();
        }
Esempio n. 18
0
 // POST api/clanak
 public void Post([FromBody] Predmet Predmet)
 {
     Crud <Predmet> .Create(sesija, Predmet);
 }
Esempio n. 19
0
 // POST api/clanak
 public void Post([FromBody] Student student)
 {
     Crud <Student> .Create(sesija, student);
 }
Esempio n. 20
0
 // POST api/clanak
 public void Post([FromBody] Literatura Literatura)
 {
     Crud <Literatura> .Create(sesija, Literatura);
 }
Esempio n. 21
0
 // POST api/clanak
 public void Post([FromBody] Tim Tim)
 {
     Crud <Tim> .Create(sesija, Tim);
 }