示例#1
0
        public ElementSifarnika SnimiPodatkeElementa(string idElementa, List <PodatakElementaSifarnika> podaci, UlogovaniKorisnik korisnik)
        {
            using (var context = DmsData.GetContextWithTransaction())
            {
                var noviElement = new ElementSifarnika();

                short?idOkruga = null;
                short?idOrgana = null;
                short?idKlase  = null;
                if (!string.IsNullOrEmpty(idElementa))
                {
                    var kljucevi = idElementa.Split('-');
                    if (kljucevi.Length == 3)
                    {
                        idOkruga = Int16.Parse(kljucevi[0]);
                        idOrgana = Int16.Parse(kljucevi[1]);
                        idKlase  = Int16.Parse(kljucevi[2]);
                    }
                }

                try
                {
                    string naziv           = null;
                    string oznaka          = null;
                    string napomena        = null;
                    var    aktivan         = false;
                    string nadleznost      = null;
                    short? idInspekcije    = null;
                    bool   izuzmiIzProvere = false;

                    foreach (PodatakElementaSifarnika element in podaci)
                    {
                        switch (element.Id)
                        {
                        case 0:
                            naziv = element.Vrednost;
                            break;

                        case 1:
                            oznaka = element.Vrednost;
                            break;

                        case 2:
                            aktivan = bool.Parse(element.Vrednost);
                            break;

                        case 3:
                            napomena = element.Vrednost;
                            break;

                        case 4:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                idInspekcije = short.Parse(element.Vrednost);
                            }
                            break;

                        case 5:
                            idOkruga = short.Parse(element.Vrednost);
                            break;

                        case 6:
                            idOrgana = short.Parse(element.Vrednost);
                            break;

                        case 7:
                            nadleznost = element.Vrednost;
                            break;

                        case 8:
                            izuzmiIzProvere = bool.Parse(element.Vrednost);
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(naziv))
                    {
                        throw new ApplicationException("Naziv klase nije unet.");
                    }

                    if (naziv != null && naziv.Length > 200)
                    {
                        throw new ApplicationException("Naziv klase ima više od 200 karaktera.");
                    }

                    if (string.IsNullOrEmpty(oznaka))
                    {
                        throw new ApplicationException("Oznaka klase nije uneta.");
                    }

                    if (oznaka != null && oznaka.Length > 3)
                    {
                        throw new ApplicationException("Oznaka klase ima više od 3 karaktera.");
                    }

                    if (!string.IsNullOrEmpty(napomena) && napomena.Length > 2000)
                    {
                        throw new ApplicationException("Napomena klase ima više od 2000 karaktera.");
                    }

                    if (!string.IsNullOrEmpty(nadleznost) && nadleznost.Length > 4000)
                    {
                        throw new ApplicationException("Nadležnost klase ima više od 4000 karaktera.");
                    }

                    context.klasa_SnimiKlasu(idOkruga, idOrgana, ref idKlase, Konverzija.KonvertujULatinicu(oznaka).SrediZaSnimanje(3),
                                             Konverzija.KonvertujULatinicu(naziv).SrediZaSnimanje(200), Konverzija.KonvertujULatinicu(napomena).SrediZaSnimanje(2000),
                                             aktivan, korisnik.IdKorisnika, Konverzija.KonvertujULatinicu(nadleznost).SrediZaSnimanje(4000), idInspekcije, izuzmiIzProvere);

                    noviElement.IdElementa            = string.Format(@"{0}-{1}-{2}", idOkruga, idOrgana, idKlase);
                    noviElement.Naziv                 = Konverzija.VratiString(korisnik.Jezik, string.Format(@"{0}-{1}", oznaka, naziv));
                    noviElement.Aktivan               = aktivan;
                    noviElement.DozvoljenoBrisanje    = true;
                    noviElement.DozvoljenoDodavanje   = false;
                    noviElement.DozvoljenaIzmena      = true;
                    noviElement.IdNadredjenogElementa = null;

                    context.Transaction.Commit();
                }
                catch (Exception)
                {
                    context.Transaction.Rollback();
                    throw;
                }
                finally
                {
                    context.Connection.Close();
                }

                return(noviElement);
            }
        }
示例#2
0
        public ElementSifarnika SnimiPodatkeElementa(string idElementa, List <PodatakElementaSifarnika> podaci, UlogovaniKorisnik korisnik)
        {
            using (var context = DmsData.GetContextWithTransaction())
            {
                var noviElement = new ElementSifarnika();

                short?idOkruga  = null;
                short?idOpstine = null;
                int?  idMesta   = null;
                if (!string.IsNullOrEmpty(idElementa))
                {
                    var kljucevi = idElementa.Split('-');
                    if (kljucevi.Length == 3)
                    {
                        idOkruga  = Int16.Parse(kljucevi[0]);
                        idOpstine = Int16.Parse(kljucevi[1]);
                        idMesta   = Int32.Parse(kljucevi[2]);
                    }
                }

                try
                {
                    string naziv   = null;
                    bool   aktivan = false;

                    foreach (var element in podaci)
                    {
                        switch (element.Id)
                        {
                        case 0:
                            naziv = element.Vrednost;
                            break;

                        case 1:
                            aktivan = Boolean.Parse(element.Vrednost);
                            break;

                        case 2:
                            idOkruga = Int16.Parse(element.Vrednost);
                            break;

                        case 3:
                            idOpstine = Int16.Parse(element.Vrednost);
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(naziv))
                    {
                        throw new ApplicationException("Naziv mesta nije unet.");
                    }

                    if (naziv != null && naziv.Length > 200)
                    {
                        throw new ApplicationException("Naziv mesta ima više od 200 karaktera.");
                    }

                    context.mesta_SnimiMesto(idOkruga, idOpstine, ref idMesta,
                                             Konverzija.KonvertujULatinicu(naziv).SrediZaSnimanje(200), aktivan,
                                             korisnik.IdKorisnika);

                    noviElement.IdElementa            = string.Format(@"{0}-{1}-{2}", idOkruga, idOpstine, idMesta);
                    noviElement.Naziv                 = Konverzija.VratiString(korisnik.Jezik, naziv);
                    noviElement.Aktivan               = aktivan;
                    noviElement.DozvoljenoBrisanje    = true;
                    noviElement.DozvoljenoDodavanje   = false;
                    noviElement.DozvoljenaIzmena      = true;
                    noviElement.IdNadredjenogElementa = null;

                    context.Transaction.Commit();
                }
                catch (Exception)
                {
                    context.Transaction.Rollback();
                    throw;
                }
                finally
                {
                    context.Connection.Close();
                }

                return(noviElement);
            }
        }
示例#3
0
        public ElementSifarnika SnimiPodatkeElementa(string idElementa, List <PodatakElementaSifarnika> podaci, UlogovaniKorisnik korisnik)
        {
            var noviElement = new ElementSifarnika();

            short?idInspekcije = null;

            if (!string.IsNullOrEmpty(idElementa))
            {
                idInspekcije = short.Parse(idElementa);
            }

            List <Inspekcija> klaseIJedinice = new List <Inspekcija>();

            string naziv = null;

            foreach (var podatak in podaci)
            {
                switch (podatak.Id)
                {
                case 0:
                    naziv = podatak.Vrednost;
                    break;

                case 4:
                    if (podatak.IzborniPodaci != null && podatak.IzborniPodaci.Count > 0)
                    {
                        foreach (var podaciZaIzbor in podatak.IzborniPodaci)
                        {
                            if (podaciZaIzbor != null && !string.IsNullOrEmpty(podaciZaIzbor.IdPodatka))
                            {
                                var kljucevi = podaciZaIzbor.IdPodatka.Split('-');

                                if (kljucevi.Length == 3)
                                {
                                    if (!string.IsNullOrEmpty(kljucevi[0]) && !string.IsNullOrEmpty(kljucevi[1]))
                                    {
                                        var klasaIJedinica = new Inspekcija
                                        {
                                            IdOrgana   = short.Parse(kljucevi[0]),
                                            IdKlase    = short.Parse(kljucevi[1]),
                                            IdJedinice = string.IsNullOrEmpty(kljucevi[2]) ? (short)0 : short.Parse(kljucevi[2]),
                                        };

                                        klaseIJedinice.Add(klasaIJedinica);
                                    }
                                }
                            }
                        }
                    }
                    break;
                }
            }

            if (string.IsNullOrEmpty(naziv))
            {
                throw new ApplicationException("Naziv inspekcije nije unet.");
            }

            if (naziv != null && naziv.Length > 100)
            {
                throw new ApplicationException("Naziv inspekcije ima više od 100 karaktera.");
            }

            using (var context = DmsData.GetContextWithTransaction())
            {
                try
                {
                    context.inspekcije_SnimiInspekciju(ref idInspekcije, naziv.SrediZaSnimanje(100), korisnik.IdKorisnika, korisnik.IdOkruga);

                    context.inspekcija_ObrisiKlaseIJedinice(idInspekcije, korisnik.IdOkruga, korisnik.IdKorisnika);

                    foreach (var klasaIJedinica in klaseIJedinice.GroupBy(x => new { x.IdOrgana, x.IdKlase, x.IdJedinice }))
                    {
                        context.inspekcija_SacuvajKlasuIJedinicu(idInspekcije, klasaIJedinica.Key.IdOrgana,
                                                                 klasaIJedinica.Key.IdKlase, klasaIJedinica.Key.IdJedinice, korisnik.IdOkruga,
                                                                 korisnik.IdKorisnika);
                    }

                    noviElement.IdElementa            = string.Format(@"{0}", idInspekcije);
                    noviElement.Naziv                 = Konverzija.VratiString(korisnik.Jezik, naziv.SrediZaSnimanje(100));
                    noviElement.Aktivan               = true;
                    noviElement.DozvoljenoBrisanje    = true;
                    noviElement.DozvoljenoDodavanje   = false;
                    noviElement.DozvoljenaIzmena      = true;
                    noviElement.IdNadredjenogElementa = null;

                    context.Transaction.Commit();
                }
                catch (Exception)
                {
                    context.Transaction.Rollback();
                    throw;
                }
                finally
                {
                    context.Connection.Close();
                }

                return(noviElement);
            }
        }
示例#4
0
        public ElementSifarnika SnimiPodatkeElementa(string idElementa, List <PodatakElementaSifarnika> podaci, UlogovaniKorisnik korisnik)
        {
            using (var context = DmsData.GetContextWithTransaction())
            {
                var noviElement = new ElementSifarnika();

                short?idVrstePredmeta = null;
                if (!string.IsNullOrEmpty(idElementa))
                {
                    idVrstePredmeta = Int16.Parse(idElementa);
                }

                try
                {
                    string naziv          = null;
                    string napomena       = null;
                    string oznaka         = null;
                    bool   aktivan        = false;
                    short? rok            = null;
                    string oznakaZaStampu = null;

                    foreach (PodatakElementaSifarnika element in podaci)
                    {
                        switch (element.Id)
                        {
                        case 0:
                            naziv = element.Vrednost;
                            break;

                        case 1:
                            oznaka = element.Vrednost;
                            break;

                        case 2:
                            aktivan = Boolean.Parse(element.Vrednost);
                            break;

                        case 3:
                            napomena = element.Vrednost;
                            break;

                        case 4:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                rok = Int16.Parse(element.Vrednost);
                            }
                            break;

                        case 5:
                            oznakaZaStampu = element.Vrednost;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(naziv))
                    {
                        throw new ApplicationException("Naziv vrste predmeta nije unet.");
                    }

                    if (naziv != null && naziv.Length > 200)
                    {
                        throw new ApplicationException("Naziv vrste predmeta ima više od 200 karaktera.");
                    }

                    if (string.IsNullOrEmpty(oznaka))
                    {
                        throw new ApplicationException("Oznaka vrste predmeta nije uneta.");
                    }

                    if (oznaka != null && oznaka.Length > 3)
                    {
                        throw new ApplicationException("Oznaka vrste predmeta ima više od 3 karaktera.");
                    }

                    if (!string.IsNullOrEmpty(napomena) && napomena.Length > 2000)
                    {
                        throw new ApplicationException("Napomena vrste predmeta ima više od 2000 karaktera.");
                    }

                    if (rok == null)
                    {
                        throw new ApplicationException("Rok vrste predmeta nije unet.");
                    }

                    context.vrsta_pred_SnimiVrstuPredmeta(ref idVrstePredmeta, Konverzija.KonvertujULatinicu(naziv).SrediZaSnimanje(200),
                                                          Konverzija.KonvertujULatinicu(oznaka).SrediZaSnimanje(3), Konverzija.KonvertujULatinicu(napomena).SrediZaSnimanje(2000),
                                                          aktivan, korisnik.IdKorisnika, rok, Konverzija.KonvertujULatinicu(oznakaZaStampu).SrediZaSnimanje(30));

                    noviElement.IdElementa            = string.Format(@"{0}", idVrstePredmeta);
                    noviElement.Naziv                 = Konverzija.VratiString(korisnik.Jezik, naziv);
                    noviElement.Aktivan               = aktivan;
                    noviElement.DozvoljenoBrisanje    = true;
                    noviElement.DozvoljenoDodavanje   = false;
                    noviElement.DozvoljenaIzmena      = true;
                    noviElement.IdNadredjenogElementa = null;

                    context.Transaction.Commit();
                }
                catch (Exception)
                {
                    context.Transaction.Rollback();
                    throw;
                }
                finally
                {
                    context.Connection.Close();
                }

                return(noviElement);
            }
        }
示例#5
0
        public ElementSifarnika SnimiPodatkeElementa(string idElementa, List <PodatakElementaSifarnika> podaci, UlogovaniKorisnik korisnik)
        {
            using (var context = DmsData.GetContextWithTransaction())
            {
                var noviElement = new ElementSifarnika();

                short?idOkruga = null;
                if (!string.IsNullOrEmpty(idElementa))
                {
                    idOkruga = Int16.Parse(idElementa);
                }

                try
                {
                    string naziv    = null;
                    string oznaka   = null;
                    string napomena = null;
                    bool   aktivan  = false;
                    string mesto    = null;

                    foreach (PodatakElementaSifarnika element in podaci)
                    {
                        switch (element.Id)
                        {
                        case 0:
                            naziv = element.Vrednost;
                            break;

                        case 1:
                            oznaka = element.Vrednost;
                            break;

                        case 2:
                            aktivan = Boolean.Parse(element.Vrednost);
                            break;

                        case 3:
                            napomena = element.Vrednost;
                            break;

                        case 5:
                            mesto = element.Vrednost;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(naziv))
                    {
                        throw new ApplicationException("Naziv okruga nije unet.");
                    }

                    if (naziv != null && naziv.Length > 200)
                    {
                        throw new ApplicationException("Naziv okruga ima više od 200 karaktera.");
                    }

                    if (string.IsNullOrEmpty(oznaka))
                    {
                        throw new ApplicationException("Oznaka okruga nije uneta.");
                    }

                    if (oznaka != null && oznaka.Length > 3)
                    {
                        throw new ApplicationException("Oznaka okruga ima više od 3 karaktera.");
                    }

                    if (!string.IsNullOrEmpty(napomena) && napomena.Length > 2000)
                    {
                        throw new ApplicationException("Napomena okruga ima više od 2000 karaktera.");
                    }

                    if (string.IsNullOrEmpty(mesto))
                    {
                        throw new ApplicationException("MEsto okruga nije uneta.");
                    }

                    if (mesto != null && mesto.Length > 200)
                    {
                        throw new ApplicationException("Mesto okruga ima više od 200 karaktera.");
                    }

                    context.okrug_SnimiOkrug(ref idOkruga, Konverzija.KonvertujULatinicu(oznaka).SrediZaSnimanje(3), Konverzija.KonvertujULatinicu(naziv).SrediZaSnimanje(200),
                                             Konverzija.KonvertujULatinicu(mesto).SrediZaSnimanje(200), Konverzija.KonvertujULatinicu(napomena).SrediZaSnimanje(2000), aktivan, korisnik.IdKorisnika);

                    noviElement.IdElementa            = string.Format(@"{0}", idOkruga);
                    noviElement.Naziv                 = Konverzija.VratiString(korisnik.Jezik, string.Format(@"{0}-{1}", oznaka, naziv));
                    noviElement.Aktivan               = aktivan;
                    noviElement.DozvoljenoBrisanje    = true;
                    noviElement.DozvoljenoDodavanje   = false;
                    noviElement.DozvoljenaIzmena      = true;
                    noviElement.IdNadredjenogElementa = null;

                    LogovanjeData.PromeniNapomenuOkrugaUlogovanihKorisnika(napomena);

                    context.Transaction.Commit();
                }
                catch (Exception)
                {
                    context.Transaction.Rollback();
                    throw;
                }
                finally
                {
                    context.Connection.Close();
                }

                return(noviElement);
            }
        }
示例#6
0
        public ElementSifarnika SnimiPodatkeElementa(string idElementa, List <PodatakElementaSifarnika> podaci, UlogovaniKorisnik korisnik)
        {
            using (var context = DmsData.GetContextWithTransaction())
            {
                var noviElement = new ElementSifarnika();

                byte?idPrecice = null;
                if (!string.IsNullOrEmpty(idElementa))
                {
                    idPrecice = Byte.Parse(idElementa);
                }

                try
                {
                    string tekst = null;

                    foreach (PodatakElementaSifarnika element in podaci)
                    {
                        switch (element.Id)
                        {
                        case 0:
                            tekst = element.Vrednost;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(tekst))
                    {
                        throw new ApplicationException("Tekst prečice nije unet.");
                    }

                    if (tekst != null && tekst.Length > 2000)
                    {
                        throw new ApplicationException("Tekst prečice ima više od 2000 karaktera.");
                    }

                    context.precica_SnimiPrecicu(korisnik.IdKorisnika, idPrecice, tekst.SrediZaSnimanje(2000));

                    noviElement.IdElementa            = string.Format(@"{0}", idPrecice);
                    noviElement.Naziv                 = Konverzija.VratiString(korisnik.Jezik, tekst.SrediZaSnimanje(50));
                    noviElement.Aktivan               = true;
                    noviElement.DozvoljenoBrisanje    = false;
                    noviElement.DozvoljenoDodavanje   = false;
                    noviElement.DozvoljenaIzmena      = true;
                    noviElement.IdNadredjenogElementa = null;

                    context.Transaction.Commit();
                }
                catch (Exception)
                {
                    context.Transaction.Rollback();
                    throw;
                }
                finally
                {
                    context.Connection.Close();
                }

                return(noviElement);
            }
        }
示例#7
0
        public ElementSifarnika SnimiPodatkeElementa(string idElementa, List <PodatakElementaSifarnika> podaci, UlogovaniKorisnik korisnik)
        {
            using (var context = DmsData.GetContextWithTransaction())
            {
                var noviElement = new ElementSifarnika();

                short?idKretanjaPredmeta = null;
                if (!string.IsNullOrEmpty(idElementa))
                {
                    idKretanjaPredmeta = Int16.Parse(idElementa);
                }

                try
                {
                    string naziv           = null;
                    string napomena        = null;
                    var    aktivan         = false;
                    char?  status          = null;
                    var    zapisnik        = false;
                    string primedba        = null;
                    var    unosRoka        = false;
                    string oznaka          = null;
                    string nazivZaIstoriju = null;

                    foreach (var element in podaci)
                    {
                        switch (element.Id)
                        {
                        case 0:
                            naziv = element.Vrednost;
                            break;

                        case 1:
                            aktivan = Boolean.Parse(element.Vrednost);
                            break;

                        case 2:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                status = Char.Parse(element.Vrednost);
                            }
                            break;

                        case 3:
                            napomena = element.Vrednost;
                            break;

                        case 4:
                            zapisnik = Boolean.Parse(element.Vrednost);
                            break;

                        case 5:
                            primedba = element.Vrednost;
                            break;

                        case 6:
                            unosRoka = Boolean.Parse(element.Vrednost);
                            break;

                        case 7:
                            oznaka = element.Vrednost;
                            break;

                        case 8:
                            nazivZaIstoriju = element.Vrednost;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(naziv))
                    {
                        throw new ApplicationException("Naziv kretanja predmeta nije unet.");
                    }

                    if (!string.IsNullOrEmpty(naziv) && naziv.Length > 200)
                    {
                        throw new ApplicationException("Naziv kretanja predmeta ima više od 200 karaktera.");
                    }

                    if (string.IsNullOrEmpty(oznaka))
                    {
                        throw new ApplicationException("Oznaka kretanja predmeta nije unet.");
                    }

                    if (!string.IsNullOrEmpty(oznaka) && oznaka.Length > 3)
                    {
                        throw new ApplicationException("Oznaka kretanja predmeta ima više od 3 karaktera.");
                    }

                    if (string.IsNullOrEmpty(nazivZaIstoriju))
                    {
                        throw new ApplicationException("Naziv za istoriju kretanja predmeta nije unet.");
                    }

                    if (!string.IsNullOrEmpty(nazivZaIstoriju) && nazivZaIstoriju.Length > 200)
                    {
                        throw new ApplicationException("Naziv za istoriju kretanja predmeta ima više od 200 karaktera.");
                    }

                    if (!string.IsNullOrEmpty(napomena) && napomena.Length > 2000)
                    {
                        throw new ApplicationException("Napomena kretanja predmeta ima više od 2000 karaktera.");
                    }

                    if (!string.IsNullOrEmpty(primedba) && primedba.Length > 100)
                    {
                        throw new ApplicationException("Primedba kretanja predmeta ima više od 100 karaktera.");
                    }

                    if (status == null)
                    {
                        throw new ApplicationException("Status kretanja predmeta nije izabran.");
                    }

                    context.kret_pred_SnimiKretanjePredmeta(ref idKretanjaPredmeta, Konverzija.KonvertujULatinicu(naziv).SrediZaSnimanje(200),
                                                            Konverzija.KonvertujULatinicu(napomena).SrediZaSnimanje(2000), aktivan, korisnik.IdKorisnika, status, zapisnik,
                                                            primedba.SrediZaSnimanje(100), unosRoka, oznaka, nazivZaIstoriju);

                    noviElement.IdElementa            = string.Format(@"{0}", idKretanjaPredmeta);
                    noviElement.Naziv                 = Konverzija.VratiString(korisnik.Jezik, naziv);
                    noviElement.Aktivan               = aktivan;
                    noviElement.DozvoljenoBrisanje    = true;
                    noviElement.DozvoljenoDodavanje   = false;
                    noviElement.DozvoljenaIzmena      = true;
                    noviElement.IdNadredjenogElementa = null;

                    context.Transaction.Commit();
                }
                catch (Exception)
                {
                    context.Transaction.Rollback();
                    throw;
                }
                finally
                {
                    context.Connection.Close();
                }

                return(noviElement);
            }
        }
示例#8
0
        public ElementSifarnika SnimiPodatkeElementa(string idElementa, List <PodatakElementaSifarnika> podaci, UlogovaniKorisnik korisnik)
        {
            using (var context = DmsData.GetContextWithTransaction())
            {
                var noviElement = new ElementSifarnika();

                int?idKorisnikaZaUnos = null;
                if (!string.IsNullOrEmpty(idElementa))
                {
                    idKorisnikaZaUnos = int.Parse(idElementa);
                }

                try
                {
                    string korisnickoIme       = null;
                    var    inspektor           = false;
                    short? idOkruga            = null;
                    var    unosNovogPredmeta   = false;
                    var    dozvolaRezervisanja = false;
                    var    izmenaPredmeta      = false;
                    var    brisanjePredmeta    = false;
                    var    administracija      = false;
                    var    pregledIzvestaja    = false;
                    string email                        = null;
                    string telefon                      = null;
                    string jmbg                         = null;
                    string imeIPrezime                  = null;
                    string napomena                     = null;
                    var    aktivan                      = true;
                    string lozinka                      = null;
                    string novaLozinka                  = null;
                    var    samoSvojePredmete            = false;
                    short? idOrgana                     = null;
                    short? maksimalniBrojPredmeta       = null;
                    short? maxBrojRezervisanihPredmeta  = null;
                    short? maksimalniBrojPredmetaGodine = null;
                    var    strogoPoverljivi             = false;

                    PodatakElementaSifarnika klase = null;

                    foreach (PodatakElementaSifarnika element in podaci)
                    {
                        switch (element.Id)
                        {
                        case 0:
                            korisnickoIme = element.Vrednost;
                            break;

                        case 1:
                            imeIPrezime = element.Vrednost;
                            break;

                        case 2:
                            email = element.Vrednost;
                            break;

                        case 3:
                            jmbg = element.Vrednost;
                            break;

                        case 4:
                            telefon = element.Vrednost;
                            break;

                        case 5:
                            aktivan = bool.Parse(element.Vrednost);
                            break;

                        case 6:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                idOkruga = short.Parse(element.Vrednost);
                            }
                            break;

                        case 7:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                inspektor = bool.Parse(element.Vrednost);
                            }
                            break;

                        case 8:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                unosNovogPredmeta = bool.Parse(element.Vrednost);
                            }
                            break;

                        case 9:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                dozvolaRezervisanja = bool.Parse(element.Vrednost);
                            }
                            break;

                        case 10:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                izmenaPredmeta = bool.Parse(element.Vrednost);
                            }
                            break;

                        case 11:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                brisanjePredmeta = bool.Parse(element.Vrednost);
                            }
                            break;

                        case 12:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                administracija = bool.Parse(element.Vrednost);
                            }
                            break;

                        case 13:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                pregledIzvestaja = bool.Parse(element.Vrednost);
                            }
                            break;

                        case 14:
                            napomena = element.Vrednost;
                            break;

                        case 15:
                            lozinka = element.Vrednost;
                            break;

                        case 16:
                            novaLozinka = element.Vrednost;
                            break;

                        case 17:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                samoSvojePredmete = bool.Parse(element.Vrednost);
                            }
                            break;

                        case 18:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                idOrgana = short.Parse(element.Vrednost);
                            }
                            break;

                        case 19:
                            klase = element;
                            break;

                        case 20:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                maksimalniBrojPredmeta = short.Parse(element.Vrednost);
                            }
                            break;

                        case 21:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                maxBrojRezervisanihPredmeta = short.Parse(element.Vrednost);
                            }
                            break;

                        case 22:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                maksimalniBrojPredmetaGodine = short.Parse(element.Vrednost);
                            }
                            break;

                        case 23:
                            if (!string.IsNullOrEmpty(element.Vrednost))
                            {
                                strogoPoverljivi = bool.Parse(element.Vrednost);
                            }
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(korisnickoIme))
                    {
                        throw new ApplicationException("Korisničko ime korisnika nije uneto.");
                    }

                    if (!string.IsNullOrEmpty(korisnickoIme) && korisnickoIme.Length > 50)
                    {
                        throw new ApplicationException("Korisničko ime korisnika ima više od 50 karaktera.");
                    }

                    if (string.IsNullOrEmpty(email))
                    {
                        throw new ApplicationException("Email korisnika nije unet.");
                    }

                    if (!string.IsNullOrEmpty(email) && email.Length > 200)
                    {
                        throw new ApplicationException("Email korisnika ima više od 200 karaktera.");
                    }

                    if (string.IsNullOrEmpty(telefon))
                    {
                        throw new ApplicationException("Telefon korisnika nije unet.");
                    }

                    if (!string.IsNullOrEmpty(telefon) && telefon.Length > 200)
                    {
                        throw new ApplicationException("Telefon korisnika ima više od 200 karaktera.");
                    }

                    if (string.IsNullOrEmpty(jmbg))
                    {
                        throw new ApplicationException("JMBG korisnika nije unet.");
                    }

                    if (!string.IsNullOrEmpty(jmbg) && jmbg.Length != 13)
                    {
                        throw new ApplicationException("Jmbg korisnika nema 13 karaktera.");
                    }

                    if (string.IsNullOrEmpty(imeIPrezime))
                    {
                        throw new ApplicationException("Ime i prezime korisnika nisu uneti.");
                    }

                    if (!string.IsNullOrEmpty(imeIPrezime) && imeIPrezime.Length > 200)
                    {
                        throw new ApplicationException("Ime i prezime korisnika ima više od 200 karaktera.");
                    }

                    if (!string.IsNullOrEmpty(napomena) && napomena.Length > 2000)
                    {
                        throw new ApplicationException("Napomena kretanja predmeta ima više od 2000 karaktera.");
                    }

                    if (klase != null && klase.IzborniPodaci != null && idOkruga == null)
                    {
                        throw new ApplicationException("Okrug korisnika nije izabran.");
                    }

                    if (idElementa == null && string.IsNullOrEmpty(lozinka))
                    {
                        throw new ApplicationException("Lozinka korisnika nije uneta.");
                    }

                    if (string.IsNullOrEmpty(idElementa) && !string.IsNullOrEmpty(lozinka))
                    {
                        if (!(lozinka.Any(char.IsUpper) &&
                              lozinka.Any(char.IsLower) &&
                              lozinka.Any(char.IsDigit)))
                        {
                            throw new ApplicationException("Lozinka ne zadovoljava postavljena pravila kreiranja lozinke.<br> Lozinka korisnika mora sadržati bar jedno veliko slovo, jedno malo slovo i jedan broj.");
                        }
                    }

                    if (!string.IsNullOrEmpty(idElementa) && !string.IsNullOrEmpty(novaLozinka))
                    {
                        if (!(novaLozinka.Any(char.IsUpper) &&
                              novaLozinka.Any(char.IsLower) &&
                              novaLozinka.Any(char.IsDigit)))
                        {
                            throw new ApplicationException("Lozinka ne zadovoljava postavljena pravila kreiranja lozinke.<br> Lozinka korisnika mora sadržati bar jedno veliko slovo, jedno malo slovo i jedan broj.");
                        }
                    }

                    byte[] novaLozinkaZaSnimanje = null;
                    byte[] lozinkaZaSnimanje     = null;
                    if (idKorisnikaZaUnos != null)
                    {
                        novaLozinkaZaSnimanje = string.IsNullOrEmpty(novaLozinka) ? null : Konverzija.KonvertujULatinicu(novaLozinka).CalculateMd5Hash();
                    }
                    else
                    {
                        lozinkaZaSnimanje = string.IsNullOrEmpty(lozinka) ? null : Konverzija.KonvertujULatinicu(lozinka).CalculateMd5Hash();
                    }

                    context.korisnik_SnimiKorisnika(ref idKorisnikaZaUnos, Konverzija.KonvertujULatinicu(korisnickoIme).SrediZaSnimanje(50), inspektor, idOkruga, unosNovogPredmeta, dozvolaRezervisanja,
                                                    izmenaPredmeta, brisanjePredmeta, administracija, pregledIzvestaja, Konverzija.KonvertujULatinicu(email).SrediZaSnimanje(200), telefon.SrediZaSnimanje(200), jmbg.SrediZaSnimanje(13),
                                                    Konverzija.KonvertujULatinicu(imeIPrezime).SrediZaSnimanje(200), Konverzija.KonvertujULatinicu(napomena).SrediZaSnimanje(2000), aktivan, korisnik.IdKorisnika,
                                                    lozinkaZaSnimanje, novaLozinkaZaSnimanje, samoSvojePredmete, idOrgana, maksimalniBrojPredmeta, maxBrojRezervisanihPredmeta, maksimalniBrojPredmetaGodine, strogoPoverljivi);
                    noviElement.IdElementa            = string.Format(@"{0}", idKorisnikaZaUnos);
                    noviElement.Naziv                 = Konverzija.VratiString(korisnik.Jezik, korisnickoIme);
                    noviElement.Aktivan               = aktivan;
                    noviElement.DozvoljenoDodavanje   = false;
                    noviElement.DozvoljenaIzmena      = true;
                    noviElement.IdNadredjenogElementa = null;

                    //if (inspektor)
                    //{
                    //    context.klase_insp_ObrisiKlaseInspektora(idKorisnikaZaUnos);

                    //    if (idOkruga != null && idOrgana != null)
                    //    {
                    //        if (klase.Count > 0)
                    //        {
                    //            foreach (var klasaInspektora in klase)
                    //            {
                    //                context.klase_insp_SnimiKlasuInspektora(idKorisnikaZaUnos, idOkruga, idOrgana, Int16.Parse(klasaInspektora.IdPodatka));
                    //            }
                    //        }
                    //    }
                    //}

                    // tipovi dokumenata
                    context.klase_insp_ObrisiKlaseInspektora(idKorisnikaZaUnos);
                    if (klase != null && klase.IzborniPodaci != null)
                    {
                        foreach (var izabran in klase.IzborniPodaci)
                        {
                            if (izabran != null && izabran.Izabran)
                            {
                                var kljucevi = izabran.IdPodatka.Split('-');
                                if (kljucevi.Length == 2)
                                {
                                    var idOrganaKlase     = short.Parse(kljucevi[0]);
                                    var idKlaseZaSnimanje = short.Parse(kljucevi[1]);

                                    context.klase_insp_SnimiKlasuInspektora(idKorisnikaZaUnos, idOkruga, idOrganaKlase, idKlaseZaSnimanje);
                                }
                            }
                        }
                    }

                    context.Transaction.Commit();
                }
                catch (Exception)
                {
                    context.Transaction.Rollback();
                    throw;
                }
                finally
                {
                    context.Connection.Close();
                }

                return(noviElement);
            }
        }