public override object IzvrsiKonkretnuSO(OpstiDomenskiObjekat odo)
        {
            Nivo n = new Nivo();

            Broker.ObrisiZaUslovOstalo(n);
            return(Broker.VratiSve(odo).OfType <Nivo>().ToList <Nivo>());
        }
예제 #2
0
        public static Nivo GetNivoById(SqlConnection conn, int id)
        {
            Nivo nivo = null;

            try
            {
                string query = "SELECT id, naziv " +
                               "FROM nivo " +
                               "WHERE id = " + id;
                SqlCommand    cmd = new SqlCommand(query, conn);
                SqlDataReader r   = cmd.ExecuteReader();

                if (r.Read())
                {
                    string naziv = (string)r["naziv"];

                    nivo = new Nivo(id, naziv);
                }
                r.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(nivo);
        }
        public override object IzvrsiKonkretnuSO(OpstiDomenskiObjekat odo)
        {
            int ID;

            try
            {
                ID = Broker.VratiSifru(odo);
            }
            catch (Exception)
            {
                ID = -1;
            }
            Nivo n = new Nivo()
            {
                IDNivo = ID
            };

            if (ID > -1)
            {
                Broker.Sacuvaj(n);
            }
            else
            {
                n = null;
                return(n);
            }
            return(n);
        }
예제 #4
0
        public static bool Update(SqlConnection conn, Nivo nivo)
        {
            bool retVal = false;

            try
            {
                string query = "UPDATE nivo " +
                               "SET naziv=@naziv " +
                               "WHERE id=@id";
                SqlCommand cmd = new SqlCommand(query, conn);

                cmd.Parameters.AddWithValue("@naziv", nivo.Naziv);
                cmd.Parameters.AddWithValue("@id", nivo.Id);

                if (cmd.ExecuteNonQuery() == 1)
                {
                    retVal = true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(retVal);
        }
예제 #5
0
        public static bool Add(SqlConnection conn, Nivo nivo)
        {
            bool retVal = false;

            try
            {
                string query = "INSERT INTO nivo (naziv,id) " +
                               "VALUES (@naziv,@id)";
                SqlCommand cmd = new SqlCommand(query, conn);

                cmd.Parameters.AddWithValue("@naziv", nivo.Naziv);
                cmd.Parameters.AddWithValue("@id", nivo.Id);

                if (cmd.ExecuteNonQuery() == 1)
                {
                    retVal = true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(retVal);
        }
예제 #6
0
        public static void IspisiNivoPoId()
        {
            Console.WriteLine("Upisite id nivoa: ");
            int id = Convert.ToInt32(Console.ReadLine());

            Nivo nivo = NivoDAO.GetNivoById(Program.conn, id);

            Console.WriteLine(nivo.ToString());
        }
        public Object ZapamtiNivo(Nivo n)
        {
            TransferKlasa transfer = new TransferKlasa();

            transfer.Operacija       = Operacije.ZapamtiNivo;
            transfer.TransferObjekat = n;
            formater.Serialize(tok, transfer);

            return(((TransferKlasa)formater.Deserialize(tok)).Rezultat);
        }
예제 #8
0
        public static void UpdatujNivo()
        {
            Console.WriteLine("Upisite id kursa: ");
            int id = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Nov naziv: ");
            string naziv = Console.ReadLine();

            Nivo nivo = new Nivo(id, naziv);

            NivoDAO.Update(Program.conn, nivo);
        }
예제 #9
0
        public static void DodajNivo()
        {
            Console.WriteLine("Upisite id novog kursa: ");
            int id = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Naziv: ");
            string naziv = Console.ReadLine();

            Nivo nivo = new Nivo(id, naziv);

            NivoDAO.Add(Program.conn, nivo);
        }
예제 #10
0
        public void UnesiNivoNeuspesno()
        {
            Nivo          nivo = new Nivo();
            Mock <Broker> mock = new Mock <Broker>();

            mock.Setup(b => b.VratiSifru(null)).Returns(1);
            mock.Setup(b => b.Sacuvaj(nivo));

            UnesiNivo un = new UnesiNivo();

            un.Broker = mock.Object;
            Nivo pov = (Nivo)un.IzvrsiKonkretnuSO(null);

            mock.Verify((b => b.Sacuvaj(nivo)), Times.Never());
        }
        internal static bool UnesiNivo(TextBox iDNivo)
        {
            nivo = (Nivo)komunikacija.UnesiNivo();

            if (nivo == null)
            {
                MessageBox.Show("Sistem ne moze da kreira nivo!");
                return(false);
            }
            else
            {
                MessageBox.Show("Sistem je uspesno kreirao nivo!");
                iDNivo.Text = nivo.IDNivo.ToString();
                return(true);
            }
        }
예제 #12
0
        public void UnesiNivoUspesno()
        {
            Nivo          nivo = new Nivo();
            Mock <Broker> mock = new Mock <Broker>();

            mock.Setup(b => b.VratiSifru(nivo)).Returns(1);
            mock.Setup(b => b.Sacuvaj(nivo));

            UnesiNivo un = new UnesiNivo();

            un.Broker = mock.Object;
            Nivo pov = (Nivo)un.IzvrsiKonkretnuSO(nivo);

            mock.Verify((b => b.VratiSifru(nivo)), Times.Once());
            Assert.IsTrue(pov != null);
            Assert.AreEqual(1, pov.IDNivo);
        }
예제 #13
0
 public Game(Nivo n)
 {
     mapaIgrach = new MapaIgrach();
     mapaBot    = new MapaBot();
     mapaIgrach.napolniSlucajno();
     mapaBot.napolniSlucajno();
     IgracNaRed = true;
     nivo       = n;
     slobodni   = new List <Point>();
     for (int i = 0; i < 10; i++)
     {
         for (int j = 0; j < 10; j++)
         {
             slobodni.Add(new Point(i, j));
         }
     }
     moliv = new Pen(Color.Chocolate);
 }
예제 #14
0
        public void ZapamtiNivoUspesno()
        {
            Nivo nivo = new Nivo
            {
                Naziv = "Eng A1 sept-jan"
            };
            Mock <Broker> mock = new Mock <Broker>();

            mock.Setup(b => b.IzmeniUslovPrimarni(nivo)).Returns(1);

            ZapamtiNivo zn = new ZapamtiNivo();

            zn.Broker = mock.Object;
            int pov = (int)zn.IzvrsiKonkretnuSO(nivo);

            mock.Verify((b => b.IzmeniUslovPrimarni(nivo)), Times.Once);
            Assert.AreEqual(1, pov);
        }
        public void PretraziSveNivoeUspesno()
        {
            Nivo          nivo = new Nivo();
            Mock <Broker> mock = new Mock <Broker>();
            List <OpstiDomenskiObjekat> nivoi = ListaNivoa();

            mock.Setup(b => b.ObrisiZaUslovOstalo(It.IsAny <Nivo>()));
            mock.Setup(b => b.VratiSve(nivo))
            .Returns(nivoi);

            PretraziSveNivoe psn = new PretraziSveNivoe();

            psn.Broker = mock.Object;
            List <Nivo> pov = (List <Nivo>)psn.IzvrsiKonkretnuSO(nivo);

            mock.Verify(b => b.ObrisiZaUslovOstalo(It.IsAny <Nivo>()), Times.Once());
            mock.Verify(b => b.VratiSve(nivo), Times.Once());
            Assert.IsTrue(pov != null);
            for (int i = 0; i < pov.Count; i++)
            {
                Assert.AreEqual(nivoi[i], pov[i]);
            }
        }
예제 #16
0
파일: DBProksi.cs 프로젝트: vodolijabg/LS
        public void ObrisiNivo(Nivo nivo)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                //ovo mora zato sto se ne moze dodati u ovaj DataContext zato sto pripada nekom drugom
                DB.Nivo _nivo = new DB.Nivo
                {
                    NivoID = nivo.NivoID,
                    Sifra = nivo.Sifra,
                    Naziv = nivo.Naziv,
                };

                _baza.Nivos.Attach(_nivo);
                _baza.Nivos.DeleteOnSubmit(_nivo);
                _baza.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #17
0
파일: DBProksi.cs 프로젝트: vodolijabg/LS
        public void UnesiNivo(Nivo nivo)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                _baza.ResetujBrojac("Nivo", "NivoID");

                if (nivo.Sifra == null)
                {
                    nivo.Sifra = _baza.DajSledeciIdentity("Nivo").ToString();
                }

                _baza.Nivos.InsertOnSubmit(nivo);

                _baza.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #18
0
파일: DBProksi.cs 프로젝트: vodolijabg/LS
        public void IzmeniNivo(Nivo nivo, Nivo nivoOrginal)
        {
            try
            {
                LavDataClassesDataContext _baza = new LavDataClassesDataContext(konekcioniString);

                _baza.Nivos.Attach(nivo, nivoOrginal);

                _baza.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }