Exemple #1
0
        private static void SkoleNaKonzolu(string imeGrada)
        {
            using (var context = new ProbaContext())
            {
                var listaGradId = context.Grad.Where(x => x.Naziv.Equals(imeGrada))
                                  .Select(x => x.Id).ToList();
                if (listaGradId.Count <= 0)
                {
                    Console.WriteLine("Ovog grada nema u bazi!");
                    return;
                }
                int gradId = listaGradId[0];

                var skole = context.Skola.Where(x => x.GradId == gradId)
                            .Include(x => x.Grad);

                var data = new StringBuilder();
                foreach (var s in skole)
                {
                    data.AppendLine($"Naziv: {s.Naziv}");
                    data.AppendLine($"Adresa: {s.Adresa}");
                }
                Console.WriteLine(data.ToString());
            }
        }
Exemple #2
0
 private static void DodajGrad(string imeGrada)
 {
     using (var context = new ProbaContext())
     {
         Grad g = new Grad();
         g.Naziv = imeGrada;
         context.Grad.Add(g);
         context.SaveChanges();
     }
 }
Exemple #3
0
 private static void DodajSkolu(string imeSkole, string adresaSkole, int idGrada)
 {
     using (var context = new ProbaContext())
     {
         Skola s = new Skola();
         s.Naziv  = imeSkole;
         s.Adresa = adresaSkole;
         s.GradId = idGrada;
         context.Skola.Add(s);
         context.SaveChanges();
     }
 }
Exemple #4
0
 private static void GradoviNaKonzolu()
 {
     using (var context = new ProbaContext())
     {
         var gradovi = context.Grad;
         var data    = new StringBuilder();
         foreach (Grad g in gradovi)
         {
             data.AppendLine($"Naziv grada: {g.Naziv}");
             data.AppendLine($"Id grada: {g.Id}");
         }
         Console.WriteLine(data.ToString());
     }
 }
Exemple #5
0
 private static void SkoleNaKonzolu()
 {
     using (var context = new ProbaContext())
     {
         var skole = context.Skola.Include(p => p.Grad);
         var data  = new StringBuilder();
         foreach (Skola s in skole)
         {
             data.AppendLine($"Naziv: {s.Naziv}");
             data.AppendLine($"Adresa: {s.Adresa}");
             data.AppendLine($"Grad: {s.Grad.Naziv}");
         }
         Console.WriteLine(data.ToString());
     }
 }