Example #1
0
        public ProfesorAdmin GetById(int id)
        {
            Profesor t = db.Profesor.Find(id);

            ProfesorAdmin temp = new ProfesorAdmin
            {
                Adresa          = t.Adresa,
                DatumRodjenja   = t.DatumRodjenja,
                DatumZaposlenja = t.DatumZaposlenja,
                Ime             = t.Ime,
                Kancelarija     = t.Kancelarija,
                KorisnickoIme   = t.KorisnickoIme,
                LozinkaHash     = t.LozinkaHash,
                LozinkaSalt     = t.LozinkaSalt,
                Mail            = t.Mail,
                Prezime         = t.Prezime,
                ProfesorId      = t.ProfesorId,
                Slika           = t.Slika,
                Spol            = t.Spol,
                Staz            = t.Staz,
                VrstaUgovora    = t.VrstaUgovora,
                Zvanje          = t.Zvanje
            };

            return(temp);
        }
        public async void LoadData(int _id2, int _role2)
        {
            temp = await _service.GetById <ProfesorAdmin>(_id2);

            ProfID  = _id2;
            Role    = _role;
            _profId = _id2;
            _role   = _role2;
            Temp    = await _service.GetById <ProfesorAdmin>(_id2);

            _profId          = _id2;
            _ime             = Temp.Ime;
            _prezime         = Temp.Prezime;
            _zvanje          = Temp.Zvanje;
            _mail            = Temp.Mail;
            _kancelarija     = Temp.Kancelarija;
            _vrstaUgovora    = Temp.VrstaUgovora;
            _datumRodjenja   = Temp.DatumRodjenja.ToString();
            _datumZaposlenja = Temp.DatumZaposlenja.ToString();
            _korisnickoIme   = Temp.KorisnickoIme;
            _adresa          = Temp.Adresa;
            _spol            = Temp.Spol;
            _staz            = Temp.Staz.ToString();
            _slika           = ImageSource.FromStream(() => new MemoryStream(Temp.Slika));
        }
Example #3
0
 public void Uredi(int id, int role, ProfesorAdmin podaci)
 {
     Prezime = podaci.Prezime;
     Ime     = podaci.Ime;
     Mail    = podaci.Mail;
     Adresa  = podaci.Adresa;
     UserId  = id;
     Role    = role;
 }
Example #4
0
        public async void Snimi(int id, int role, ProfesorAdmin podaci)
        {
            podaci.Ime     = Ime;
            podaci.Prezime = Prezime;
            podaci.Adresa  = Adresa;
            podaci.Mail    = Mail;

            await _service.Update <ProfesorAdmin>(id, podaci);
        }
Example #5
0
        private async void btnSacuvaj_Click(object sender, EventArgs e)
        {
            if (this.ValidateChildren())
            {
                if (txtSifra.Text != txtConfirm.Text)
                {
                    MessageBox.Show("Unesene šifre nisu iste", "Provjera šifri", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                bool t = await service.Check_Username(txtUsername.Text);

                if (t == true)
                {
                    MessageBox.Show("Uneseno korisničko ime već postoji.", "Upozorenje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (t == false)
                {
                    if (txtSifra.Text == txtConfirm.Text)
                    {
                        ProfesorAdmin novi = new ProfesorAdmin()
                        {
                            Adresa          = txtAdresa.Text,
                            DatumRodjenja   = dateRodjenje.Value,
                            DatumZaposlenja = dateZaposlenje.Value,
                            Ime             = txtIme.Text,
                            Kancelarija     = txtKanelarija.Text,
                            KorisnickoIme   = txtUsername.Text,
                            LozinkaHash     = txtSifra.Text,
                            LozinkaSalt     = txtConfirm.Text,
                            Mail            = txtMail.Text,
                            Prezime         = txtPrezime.Text,
                            Staz            = int.Parse(txtStaz.Text),
                            VrstaUgovora    = txtUgovor.Text,
                            Zvanje          = txtZvanje.Text,
                        };

                        if (rbtnM.Checked == true)
                        {
                            novi.Spol = "M";
                        }
                        else if (rbtnZ.Checked == true)
                        {
                            novi.Spol = "Ž";
                        }

                        novi.Slika = imageToByteArray(pictureBox.Image);

                        await service.Insert(novi);

                        MessageBox.Show("Uspješno ste izvršili dodavanje");
                        this.Close();
                    }
                }
            }
        }
Example #6
0
        public ProfesorAdmin Insert(ProfesorAdmin novi)
        {
            var entity = new Profesor
            {
                Adresa          = novi.Adresa,
                DatumRodjenja   = novi.DatumRodjenja,
                DatumZaposlenja = novi.DatumZaposlenja,
                Ime             = novi.Ime,
                Kancelarija     = novi.Kancelarija,
                KorisniciUloge  = null,
                Mail            = novi.Mail,
                Prezime         = novi.Prezime,
                Slika           = novi.Slika,
                Spol            = novi.Spol,
                Staz            = novi.Staz,
                VrstaUgovora    = novi.VrstaUgovora,
                Ispit           = null,
                Predaje         = null,
                Zvanje          = novi.Zvanje,
                KorisnickoIme   = novi.KorisnickoIme
            };

            entity.LozinkaSalt = GenerateSalt();
            entity.LozinkaHash = GenerateHash(entity.LozinkaSalt, novi.LozinkaHash);

            if (entity.Slika == null)
            {
                entity.Slika = Properties.Resources.test2;
            }

            db.Profesor.Add(entity);
            db.SaveChanges();

            var list = db.Profesor.ToList();

            foreach (var x in list)
            {
                if (x.KorisnickoIme == novi.KorisnickoIme && x.Ime == novi.Ime && x.Prezime == novi.Prezime)
                {
                    KorisniciUloge n = new KorisniciUloge
                    {
                        ProfesorId   = x.ProfesorId,
                        DatumIzmjene = DateTime.Now,
                        UlogaId      = 4
                    };

                    db.KorisniciUloge.Add(n);
                    db.SaveChanges();
                }
            }

            return(novi);
        }
        public AdminDodajProfesoraVM(int role, int userId)
        {
            NazadCommand = new Command(async() =>
            {
                List <ProfesorAdmin> lista = await _service.Get <List <ProfesorAdmin> >(null);

                Application.Current.MainPage = new AdminPrikazProfesoraPage(userId, role, lista);
            });

            SnimiCommand = new Command(async() =>
            {
                if (Sifra != SifraPotvrda)
                {
                    await Application.Current.MainPage.DisplayAlert("Poruka", "Unesene šifre se ne podudaraju", "OK");
                }
                else if (Sifra == SifraPotvrda)
                {
                    ProfesorAdmin temp = new ProfesorAdmin
                    {
                        Adresa          = Adresa,
                        DatumRodjenja   = DatumRodjenja,
                        DatumZaposlenja = DatumZaposlenja,
                        Ime             = Ime,
                        Kancelarija     = Kancelarija,
                        KorisnickoIme   = KorisnickoIme,
                        LozinkaHash     = Sifra,
                        LozinkaSalt     = Sifra,
                        Mail            = Mail,
                        Prezime         = Prezime,
                        Slika           = null,
                        Spol            = Spol,
                        Staz            = Staz,
                        VrstaUgovora    = Ugovor,
                        Zvanje          = Zvanje
                    };

                    try
                    {
                        await _service.Insert(temp);
                        Application.Current.MainPage = new AdminPage(role, userId);
                        await Application.Current.MainPage.DisplayAlert("Poruka", "Uspješno ste sačuvali nove podatke", "OK");
                    }
                    catch (Exception e)
                    {
                        await Application.Current.MainPage.DisplayAlert("Poruka", "Uneseni podaci nisu ispravni", "OK");
                    }
                }
            });

            listaSpol.Insert(0, "Žensko");
            listaSpol.Insert(0, "Muško");
        }
Example #8
0
        public MojiPodaciUrediProfVM(int id, int role, ProfesorAdmin podaci)
        {
            Uredi(id, role, podaci);

            SnimiCommand = new Command(() =>
            {
                Snimi(id, role, podaci);
                Application.Current.MainPage = new MojiPodaciProfPage(id, role);
                Application.Current.MainPage.DisplayAlert("Izmjena", "Uspješno ste izvršili izmjene nad svojim podacima", "OK");
            });

            NazadCommad = new Command(() =>
            {
                Nazad(id, role);
            });
        }
Example #9
0
        public AdminDetaljiProfesorVM(int _user, int _role, ProfesorAdmin t)
        {
            NazadCommand = new Command(async() =>
            {
                List <ProfesorAdmin> lista = await _service.Get <List <ProfesorAdmin> >(null);

                Application.Current.MainPage = new AdminPrikazProfesoraPage(_user, _role, lista);
            });

            Ime             = t.Ime;
            Prezime         = t.Prezime;
            Zvanje          = t.Zvanje;
            DatumRodjenja   = t.DatumRodjenja.Value;
            DatumZaposlenja = t.DatumZaposlenja.Value;
            Adresa          = t.Adresa;
            Mail            = t.Mail;
            Spol            = t.Spol;
            Staz            = t.Staz;
            Ugovor          = t.VrstaUgovora;
            Kancelarija     = t.Kancelarija;
            Slika           = ImageSource.FromStream(() => new MemoryStream(t.Slika));
        }
Example #10
0
        public Models.ProfesorAdmin Update(int id, ProfesorAdmin o)
        {
            Profesor temp = db.Profesor.Find(id);

            temp.Slika           = o.Slika;
            temp.Adresa          = o.Adresa;
            temp.DatumRodjenja   = o.DatumRodjenja;
            temp.DatumZaposlenja = o.DatumZaposlenja;
            temp.Ime             = o.Ime;
            temp.Kancelarija     = o.Kancelarija;
            temp.LozinkaHash     = o.LozinkaHash;
            temp.LozinkaSalt     = o.LozinkaSalt;
            temp.Mail            = o.Mail;
            temp.Prezime         = o.Prezime;
            temp.Spol            = o.Spol;
            temp.Staz            = o.Staz;
            temp.Zvanje          = o.Zvanje;
            temp.VrstaUgovora    = o.VrstaUgovora;

            db.SaveChanges();

            return(o);
        }
Example #11
0
        private async void btnProfSačuvaj_Click(object sender, EventArgs e)
        {
            ProfesorAdmin temp = new ProfesorAdmin
            {
                Adresa          = txtProfAdresa.Text,
                DatumRodjenja   = datPickProfRodjenje.Value,
                DatumZaposlenja = datPickProfPosao.Value,
                Ime             = txtProfIme.Text,
                Kancelarija     = txtProfKancelarija.Text,
                Mail            = txtProfMail.Text,
                Prezime         = txtProfPrezime.Text,
                Slika           = imageToByteArray(pictureProfSlika.Image),
                Staz            = int.Parse(txtProfStaz.Text),
                VrstaUgovora    = txtProfUgovor.Text,
                Zvanje          = txtProfZvanje.Text
            };

            if (rProfM.Checked == true)
            {
                temp.Spol = "M";
            }
            if (rProfZ.Checked == true)
            {
                temp.Spol = "Ž";
            }

            var postojeci = await _service.GetById <ProfesorAdmin>(_id);

            temp.LozinkaHash = postojeci.LozinkaHash;
            temp.LozinkaSalt = postojeci.LozinkaSalt;

            await _service.Update <ProfesorAdmin>(_id, temp);

            MessageBox.Show("Uspješno ste izmjenili podatke");
            this.Close();
        }
 public AdminDetaljiProfesorPage(int _user, int _role, ProfesorAdmin t)
 {
     InitializeComponent();
     BindingContext = model = new AdminDetaljiProfesorVM(_user, _role, t);
 }
 public ProfesorAdmin Insert(ProfesorAdmin novi)
 {
     return(_service.Insert(novi));
 }
 public Models.ProfesorAdmin Update(int id, ProfesorAdmin o)
 {
     return(_service.Update(id, o));
 }
Example #15
0
 public MojiPodaciUrediProf(int id, int role, ProfesorAdmin podaci)
 {
     InitializeComponent();
     BindingContext = model = new MojiPodaciUrediProfVM(id, role, podaci);
     model.Uredi(id, role, podaci);
 }
        private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            ProfesorAdmin t = (ProfesorAdmin)e.SelectedItem;

            Application.Current.MainPage = new AdminDetaljiProfesorPage(_user, _role, t);
        }
 public void Uredi(int id, int role, ProfesorAdmin podaci)
 {
     Application.Current.MainPage = new MojiPodaciUrediProf(id, role, podaci);
 }