//Event dodavanja novog delegata
        private void buttonDodaj_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new BazaDbContext())
            {
                var contact = new Delegat
                {
                    Ime     = ImeInput.Text,
                    Prezime = PrezimeInput.Text,

                    Datum = Convert.ToInt32(DatumInput.Text),

                    Slika = uploadSlika
                };
                db.Delegati.Add(contact);

                db.SaveChanges();
                //reset polja za unos
                ImeInput.Text     = string.Empty;
                PrezimeInput.Text = string.Empty;

                DatumInput.Text = string.Empty;

                //refresh liste trenera
                DelegatiIS.ItemsSource = db.Delegati.OrderBy(c => c.Ime).ToList();
            }
        }
        //dodavanje novog tima
        private void buttonDodaj_tim_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new BazaDbContext())
            {
                var contact = new Tim
                {
                    NazivTima  = NazivInput_Tim.Text,
                    TrenerTima = TrenerInput_tim.Text,

                    DatumOsnivanja = Convert.ToInt32(DatumInput_tim.Text),

                    Slika = uploadSlika_tim
                };
                db.Timovi.Add(contact);

                db.SaveChanges();
                //reset polja za unos
                NazivInput_Tim.Text  = string.Empty;
                TrenerInput_tim.Text = string.Empty;
                DatumInput_tim.Text  = string.Empty;

                //refresh liste timova
                TimoviIS.ItemsSource = db.Timovi.OrderBy(c => c.NazivTima).ToList();
            }
        }
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     using (var db = new BazaDbContext())
     {
         DelegatiIS.ItemsSource = db.Delegati.OrderBy(c => c.Ime).ToList();
         TimoviIS.ItemsSource   = db.Timovi.OrderBy(c => c.NazivTima).ToList();
     }
 }
Example #4
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
                Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
                Microsoft.ApplicationInsights.WindowsCollectors.Session);
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            using (var db = new BazaDbContext())
            {
                db.Database.ApplyMigrations();

                //DefaultPodaci.Initialize(db);
            }
        }
 private void UnesiLiguDugme_Click(object sender, RoutedEventArgs e)
 {
     using (var db = new BazaDbContext())
     {
         NasaLiga                  = new Liga();
         NasaLiga.NazivLige        = NazivInputLiga.Text;
         NasaLiga.LigaId           = broj++;
         NasaLiga.Timovi           = new List <Tim>();
         NasaLiga.UtakmiceRaspored = new RasporedUtakmice();
         NasaLiga.Delegati         = new List <Delegat>();
         NasaLiga.fourSqaureId     = "12";
         db.Liga.Add(NasaLiga);
         db.SaveChanges();
         //reset polja za unos
         NazivInputLiga.Text = string.Empty;
     }
 }
Example #6
0
        public void Kolegij_KreiranjeBrisanje()
        {
            BazaDbContext db = new BazaDbContext();

            Kolegij kolegij = new Kolegij()
            {
                Id               = 0,
                Naziv            = "Kolegij",
                Ects             = 4,
                NositeljKolegija = "Mirko",
                Semestar         = 4
            };

            db.PopisKolegija.Add(kolegij);
            db.SaveChanges();

            db.PopisKolegija.Remove(kolegij);
            int obrisano = db.SaveChanges();

            Assert.AreEqual(1, obrisano);
        }
        //Event za brisanje delegata
        private void Button_Click_Delete(object sender, RoutedEventArgs e)
        {
            //Dobavljanje objekta iz liste koji je kori[ten da se popuni red u listview
            DependencyObject dep = (DependencyObject)e.OriginalSource;

            while ((dep != null) && !(dep is ListViewItem))
            {
                dep = VisualTreeHelper.GetParent(dep);
            }
            if (dep == null)
            {
                return;
            }
            using (var db = new BazaDbContext())
            {
                db.Delegati.Remove((Delegat)DelegatiIS.ItemFromContainer(dep));
                //Nije jos obrisano dok nije Save
                db.SaveChanges();
                //Refresh liste restorana
                DelegatiIS.ItemsSource = db.Delegati.OrderBy(c => c.Ime).ToList();
            }
        }