Ejemplo n.º 1
0
 public void IskljuciLosiParametri(Potrosac p)
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         pp.Iskljuci(p);
     });
 }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     trenutni      = (Potrosac)e.Parameter;
     dpvm.Trenutni = trenutni;
     dpvm.popuni();
 }
Ejemplo n.º 3
0
        public void dodavanjePotrosaca()
        {
            SHESContext sc = new SHESContext();

            Console.WriteLine("Unesite ime potrosaca: ");
            string ip = Console.ReadLine();

            var pomocni = sc.Potrosaci.Find(ip);

            if (pomocni != null)
            {
                Console.WriteLine("Potrosac sa tim imenom vec postoji!");
            }
            else
            {
                Console.WriteLine("Unesite potrosnju: ");
                int pp = Int32.Parse(Console.ReadLine());

                Potrosac potrosac = new Potrosac(ip, pp);

                using (var db = new SHESContext())
                {
                    db.Potrosaci.Add(potrosac);
                    db.SaveChanges();
                    Console.WriteLine("Potrosac " + potrosac.Ime + " dodat u sistem");
                }
            }
        }
Ejemplo n.º 4
0
        public void PotrosacKonstruktorDobriParametri(string ime, double potrosnja)
        {
            Potrosac potrosac = new Potrosac(ime, potrosnja);

            Assert.AreEqual(potrosac.Ime, ime);
            Assert.AreEqual(potrosac.Potrosnja, potrosnja);
        }
Ejemplo n.º 5
0
 public void PotrosacKonstruktorLosiParametri(string ime, double potrosnja)
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         Potrosac potrosac = new Potrosac(ime, potrosnja);
     });
 }
Ejemplo n.º 6
0
        public void PotrosacKonstruktorDobriParametri(string jedinstvenoIme, double potrosnja)
        {
            Potrosac potrosac = new Potrosac(jedinstvenoIme, potrosnja);

            Assert.AreEqual(potrosac.JedinstvenoIme, jedinstvenoIme);
            Assert.AreEqual(potrosac.Potrosnja, potrosnja);
        }
Ejemplo n.º 7
0
 public void DodajPotrosacaLosiParametri(Potrosac p)
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         pp.DodajPotrosaca(p);
     });
 }
Ejemplo n.º 8
0
 public void PotrosacLosiParametri2(string ime, double?potrosnja, bool?upaljeno)
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         Potrosac potrosac = new Potrosac(ime, potrosnja, upaljeno);
     });
 }
        public ActionResult DeleteConfirmed(string id)
        {
            Potrosac potrosac = db.Potrosac.Find(id);

            db.Potrosac.Remove(potrosac);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 10
0
 public void PotrosacKonstruktorLosiParametri(string jedinstvenoIme, double potrosnja)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         Potrosac potrosac = new Potrosac(jedinstvenoIme, potrosnja);
     }
                                       );
 }
Ejemplo n.º 11
0
 public void DodajPotrosacaUBazu(Potrosac potrosac)
 {
     using (ApplicationContext repozitorijum = new ApplicationContext())
     {
         repozitorijum.Potrosaci.Add(potrosac);
         repozitorijum.SaveChanges();
     }
 }
Ejemplo n.º 12
0
        public void PotrosacDobriParametri(string ime, double?potrosnja, bool?upaljeno)
        {
            Potrosac potrosac = new Potrosac(ime, potrosnja, upaljeno);

            Assert.AreEqual(potrosac.Ime, ime);
            Assert.AreEqual(potrosac.Potrosnja, potrosnja);
            Assert.AreEqual(potrosac.Upaljeno, upaljeno);
        }
Ejemplo n.º 13
0
 public void ObrisiPotrosacUBazi(Potrosac potrosac)
 {
     using (ApplicationContext repozitorijum = new ApplicationContext())
     {
         repozitorijum.Entry(potrosac).State = EntityState.Deleted;
         repozitorijum.SaveChanges();
     }
 }
Ejemplo n.º 14
0
 public void TearDown()
 {
     p1    = null;
     p2    = null;
     p3    = null;
     p4    = null;
     lista = null;
 }
Ejemplo n.º 15
0
 public void IskljuciPotrosacUBazi(Potrosac potrosac)
 {
     for (int i = 0; i < potrosaci.Count; i++)
     {
         if (potrosac.Ime == potrosaci[i].Ime)
         {
             potrosaci[i] = potrosac;
         }
     }
 }
 public ActionResult Edit([Bind(Include = "id,ime,prezime,brojTelefona,adresa,JMBG,email,password,datumRodjenja")] Potrosac potrosac)
 {
     if (ModelState.IsValid)
     {
         db.Entry(potrosac).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(potrosac));
 }
Ejemplo n.º 17
0
        private bool provjeriPotrosaca(Potrosac p)
        {
            Potrosac pomocni = ePosta.Instanca.dajPotrosaca(p.JMBG);

            if (pomocni == null)
            {
                return(true);
            }
            return(false);
        }
        public JsonResult GetJMBG(string JMBG)
        {
            Potrosac p = db.Potrosac.OfType <Potrosac>().SingleOrDefault(s => s.JMBG == JMBG);

            if (p == null)
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
            return(Json(p, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 19
0
 public void SetUp()
 {
     p1    = new Potrosac("p1", 1.0, false);
     p2    = new Potrosac("p2", 2.0, true);
     p3    = new Potrosac("p3", 3.0, false);
     p4    = new Potrosac("p4", 4.0, true);
     lista = new List <Potrosac>()
     {
         p1, p2, p3, p4
     };
 }
        public JsonResult GetAccount(string email, string password)
        {
            Potrosac p = db.Potrosac.OfType <Potrosac>().SingleOrDefault(s => s.email == email && s.password == password);

            if (p == null)
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }

            return(Json(p, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 21
0
 public void Iskljuci(Potrosac p)
 {
     if (p == null)
     {
         throw new ArgumentNullException("Potrosac je null");
     }
     else
     {
         p.Aktivan = false;
     }
 }
        public ActionResult Create([Bind(Include = "id,ime,prezime,brojTelefona,adresa,JMBG,email,password,datumRodjenja")] Potrosac potrosac)
        {
            if (ModelState.IsValid)
            {
                db.Potrosac.Add(potrosac);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(potrosac));
        }
Ejemplo n.º 23
0
        public void DodajPotrosac(string naziv, double potrosnja)
        {
            if (naziv == null)
            {
                throw new ArgumentNullException("Parametri ne mogu da budu NULL!");
            }

            Potrosac potrosac = new Potrosac(naziv, potrosnja, false);

            repozitorijum.DodajPotrosacaUBazu(potrosac);
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            List <object> parametri = (List <object>)e.Parameter;

            trenutniUposlenik = (Uposlenik)parametri[0];
            trenutni          = (Potrosac)parametri[1];
            foreach (Racun i in trenutni.sviRacuni)
            {
                r.Add(i);
            }
        }
        /*
         * public ObservableCollection<Racun> Racuni
         * {
         *  get
         *  {
         *      return racuni;
         *  }
         *
         *  set
         *  {
         *      racuni = value;
         *      OnPropertyChanged("Racuni");
         *  }
         * }*/

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            List <object> parametri = (List <object>)e.Parameter;

            //trenutni = (Potrosac)e.Parameter;
            trenutni   = (Potrosac)parametri[0];
            navigacija = parametri[1].ToString();

            prvm.Trenutni = trenutni;
            prvm.Racuni   = trenutni.sviRacuni;
        }
Ejemplo n.º 26
0
        public async Task <ActionResult <Potrosac> > addPotrosac(Potrosac potrosac)
        {
            Lokacija l = new Lokacija();

            l.Ulica            = potrosac.Ulica;
            l.Grad             = potrosac.Grad;
            potrosac.Prioritet = getPriority(l);
            _context.Potrosaci.Add(potrosac);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Ejemplo n.º 27
0
        public void UpaliPotrosac(Potrosac p)
        {
            int i = 0;

            foreach (Potrosac potrosac in potrosaci)
            {
                if (potrosac.JedinstvenoIme == p.JedinstvenoIme)
                {
                    potrosac.Upaljen = true;
                    break;
                }
                i++;
            }
        }
        // GET: Potrosacs/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Potrosac potrosac = db.Potrosac.Find(id);

            if (potrosac == null)
            {
                return(HttpNotFound());
            }
            return(View(potrosac));
        }
Ejemplo n.º 29
0
        public void UkloniPotrosaca(Potrosac p)
        {
            int i = 0;

            foreach (Potrosac potrosac in potrosaci)
            {
                if (potrosac.JedinstvenoIme == p.JedinstvenoIme)
                {
                    potrosaci.RemoveAt(i);
                    break;
                }
                i++;
            }
        }
        public void UpaliPotrosac(Potrosac p)
        {
            p.Upaljen = true;
            p.Slika   = MaterialDesignThemes.Wpf.PackIconKind.PowerPlugOutline;
            string query = "UPDATE Potrosaci SET Upaljen=@up  WHERE JedinstvenoIme = '" + p.JedinstvenoIme + "'";

            using (connection = new SqlConnection(connectionString))
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.Add("@up", SqlDbType.Bit).Value = true;
                    connection.Open();
                    command.ExecuteNonQuery();
                }
        }