Beispiel #1
0
        public static void ucitajUredjaje()
        {
            Uredjaji uredjaji = proxySimulator.PreuzmiUredjaje();

            foreach (SolarniPanel sp in uredjaji.Paneli)
            {
                new Thread(() => PokreniSolarnuPanelu(sp.JedinstvenoIme, sp.MaksimalnaSnaga)).Start();
            }

            foreach (Baterija b in uredjaji.Baterije)
            {
                new Thread(() => PokreniBateriju(b.JedinstvenoIme, b.MaksimalnaSnaga, b.Kapacitet)).Start();
            }

            foreach (Potrosac p in uredjaji.Potrosaci)
            {
                potrosaciUpaljeni.Add(p.JedinstvenoIme, p.Upaljen);
                new Thread(() => PokreniPotrosac(p.JedinstvenoIme, p.Potrosnja)).Start();
            }

            foreach (ElektricniAutomobil ea in uredjaji.Automobili)
            {
                if (ea.NaPunjacu)
                {
                    zaUkljucivanje = ea.JedinstvenoIme;
                    if (ea.PuniSe)
                    {
                        zaPokretanjePunjenja = ea.JedinstvenoIme;
                    }
                }
                new Thread(() => PokreniElektricniAutomobil(ea.JedinstvenoIme, ea.BaterijaAuta.MaksimalnaSnaga, ea.BaterijaAuta.Kapacitet)).Start();
            }
        }
        private void UcitajServise(int uredjajId)
        {
            Uredjaji       uredjaj = _context.Uredjaji.Find(uredjajId);
            List <Servisi> servisiIsteKategorije = _context.Servisi.Include(x => x.Uredjaj).Where(x => x.Uredjaj.KategorijaId == uredjaj.KategorijaId).ToList();
            List <int>     serviseri             = new List <int>();
            List <Servisi> servisiServisera;

            foreach (var servis in servisiIsteKategorije)
            {
                if (servis.OcjenaServisa > 0)
                {
                    if (!serviseri.Contains(servis.ServiserId))
                    {
                        serviseri.Add(servis.ServiserId);
                    }
                }
            }
            foreach (var serviser in serviseri)
            {
                servisiServisera = new List <Servisi>();
                foreach (var servis in servisiIsteKategorije)
                {
                    if (servis.OcjenaServisa > 0 && servis.ServiserId == serviser)
                    {
                        servisiServisera.Add(servis);
                    }
                }
                servisi.Add(serviser, servisiServisera);
            }
        }
        public Uredjaji PreuzmiUredjaje()
        {
            Uredjaji uredjaji = new Uredjaji();

            uredjaji.Automobili = new List <ElektricniAutomobil>();
            foreach (ElektricniAutomobil a in automobili)
            {
                uredjaji.Automobili.Add(a);
            }
            uredjaji.Baterije = new List <Baterija>();
            foreach (Baterija b in baterije)
            {
                uredjaji.Baterije.Add(b);
            }
            uredjaji.Potrosaci = new List <Potrosac>();
            foreach (Potrosac p in potrosaci)
            {
                uredjaji.Potrosaci.Add(p);
            }
            uredjaji.Paneli = new List <SolarniPanel>();
            foreach (SolarniPanel s in solarniPaneli)
            {
                uredjaji.Paneli.Add(s);
            }

            return(uredjaji);
        }
Beispiel #4
0
        //
        // GET: /Uredjaji/Edit/5

        public ActionResult Edit(int id)
        {
            Uredjaji uredjaji = db.Uredjaji.Single(u => u.id_ur == id);

            ViewBag.id_model = new SelectList(db.Modeli_Uredjaja, "id_model", "Naziv", uredjaji.id_model);
            ViewBag.id_oper  = new SelectList(db.Operateri, "id_oper", "Naziv", uredjaji.id_oper);
            return(View(uredjaji));
        }
Beispiel #5
0
        public ActionResult DeleteConfirmed(int id)
        {
            Uredjaji uredjaji = db.Uredjaji.Single(u => u.id_ur == id);

            db.Uredjaji.DeleteObject(uredjaji);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public Uredjaji PreuzmiUredjaje()
        {
            Uredjaji uredjaji = new Uredjaji();

            uredjaji.Automobili = MainWindow.ElektricniAutomobili.ToList();
            uredjaji.Baterije   = MainWindow.Baterije.ToList();
            uredjaji.Potrosaci  = MainWindow.Potrosaci.ToList();
            uredjaji.Paneli     = MainWindow.SolarniPaneli.ToList();

            return(uredjaji);
        }
Beispiel #7
0
        public ActionResult Create(Uredjaji uredjaji)
        {
            if (ModelState.IsValid)
            {
                db.Uredjaji.AddObject(uredjaji);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_model = new SelectList(db.Modeli_Uredjaja, "id_model", "Naziv", uredjaji.id_model);
            ViewBag.id_oper  = new SelectList(db.Operateri, "id_oper", "Naziv", uredjaji.id_oper);
            return(View(uredjaji));
        }
Beispiel #8
0
 public ActionResult Edit(Uredjaji uredjaji)
 {
     if (ModelState.IsValid)
     {
         db.Uredjaji.Attach(uredjaji);
         db.ObjectStateManager.ChangeObjectState(uredjaji, EntityState.Modified);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_model = new SelectList(db.Modeli_Uredjaja, "id_model", "Naziv", uredjaji.id_model);
     ViewBag.id_oper  = new SelectList(db.Operateri, "id_oper", "Naziv", uredjaji.id_oper);
     return(View(uredjaji));
 }
        private static IEnumerable <TestCaseData> UcitajTest1()
        {
            Uredjaji uredjaji = new Uredjaji();

            uredjaji.Automobili = new List <ElektricniAutomobil>();
            uredjaji.Automobili.Add(new ElektricniAutomobil(new Baterija("Bat1", 100, 200), "Auto1", false, false));
            uredjaji.Baterije = new List <Baterija>();
            uredjaji.Baterije.Add(new Baterija("Bat2", 200, 300));
            uredjaji.Paneli = new List <SolarniPanel>();
            uredjaji.Paneli.Add(new SolarniPanel("Sol1", 100));
            uredjaji.Potrosaci = new List <Potrosac>();
            uredjaji.Potrosaci.Add(new Potrosac("Pot1", 100));
            yield return(new TestCaseData().Returns(uredjaji));
        }
Beispiel #10
0
        //
        // GET: /Uredjaji/Details/5

        public ViewResult Details(int id)
        {
            Uredjaji uredjaji = db.Uredjaji.Single(u => u.id_ur == id);

            return(View(uredjaji));
        }
Beispiel #11
0
        //
        // GET: /Uredjaji/Delete/5

        public ActionResult Delete(int id)
        {
            Uredjaji uredjaji = db.Uredjaji.Single(u => u.id_ur == id);

            return(View(uredjaji));
        }