コード例 #1
0
        public HttpResponseMessage GetMusterija(string username)
        {
            HttpResponseMessage msg;
            MusterijaRepository repo  = new MusterijaRepository();
            AdminRepository     arepo = new AdminRepository();
            VozacRepository     vrepo = new VozacRepository();

            try
            {
                Musterija m = repo.GetOneMusterija(username);
                Admin     a = arepo.GetOneAdmin(username);
                Vozac     v = vrepo.GetOneVozac(username);

                if (m != null)
                {
                    msg = Request.CreateResponse(HttpStatusCode.OK, m);
                }
                else if (a != null)
                {
                    msg = Request.CreateResponse(HttpStatusCode.OK, a);
                }
                else if (v != null)
                {
                    msg = Request.CreateResponse(HttpStatusCode.OK, v);
                }
                else
                {
                    msg = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "User is not registered.");
                }
            }
            catch (Exception e)
            {
                msg = Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"Error - {e.Message}");
            }

            return(msg);
        }
コード例 #2
0
        // GET: Musterija
        public ActionResult Index()
        {
            Musterija musterija = (Musterija)Session["korisnik"];

            return(View("PrikazMusterije", musterija));
        }
コード例 #3
0
        public IHttpActionResult Login(Korisnik prijava)
        {
            int mT = 0;
            int vT = 0;
            int dT = 0;

            foreach (Musterija m in ListaMusterija.Musterije)
            {
                if (m.KorisnickoIme.Equals(prijava.KorisnickoIme))
                {
                    mT = 1;
                }
            }

            foreach (Vozac m in ListaVozaca.Vozaci)
            {
                if (m.KorisnickoIme.Equals(prijava.KorisnickoIme))
                {
                    vT = 1;
                }
            }

            foreach (Dispecer m in ListaDispecera.Dispeceri)
            {
                if (m.KorisnickoIme.Equals(prijava.KorisnickoIme))
                {
                    dT = 1;
                }
            }

            if (mT != 1 && vT != 1 && dT != 1)
            {
                return(BadRequest("Korisnik sa unetim korisnickim imenom ne postoji !!!"));
            }

            if (mT == 1)
            {
                Musterija m1 = ListaMusterija.Musterije.Find(x => x.KorisnickoIme == prijava.KorisnickoIme);
                if (m1.Lozinka != prijava.Lozinka)
                {
                    return(BadRequest("Neispravna lozinka !!!"));
                }

                Temp.M = m1;
                HttpContext.Current.Session["ulogovan"] = Temp.M as Musterija;
                return(Ok(m1));
            }
            else if (dT == 1)
            {
                Dispecer m1 = ListaDispecera.Dispeceri.Find(x => x.KorisnickoIme == prijava.KorisnickoIme);
                if (m1.Lozinka != prijava.Lozinka)
                {
                    return(BadRequest("Neispravna lozinka !!!"));
                }

                Temp.D = m1;
                HttpContext.Current.Session["ulogovan"] = Temp.D as Dispecer;
                return(Ok(m1));
            }
            else
            {
                Vozac m1 = ListaVozaca.Vozaci.Find(x => x.KorisnickoIme == prijava.KorisnickoIme);
                if (m1.Lozinka != prijava.Lozinka)
                {
                    return(BadRequest("Neispravna lozinka !!!"));
                }

                Temp.V = m1;
                HttpContext.Current.Session["ulogovan"] = Temp.V as Vozac;
                return(Ok(m1));
            }
        }
コード例 #4
0
        public HttpResponseMessage Pretrazi()
        {
            var           jToken           = JToken.Parse(Request.RequestUri.ToString().Split('?').Last());
            var           username         = jToken.Value <string>("username");
            var           datumOd          = jToken.Value <string>("datum1");
            var           datumDo          = jToken.Value <string>("datum2");
            var           cenaOd           = jToken.Value <int>("cenaOd");
            var           cenaDo           = jToken.Value <int>("cenaDo");
            var           ocenaOd          = jToken.Value <int>("ocenaOd");
            var           ocenaDo          = jToken.Value <int>("ocenaDo");
            var           flag             = jToken.Value <int>("flag");
            List <Voznja> pretrazene       = new List <Voznja>();
            List <Voznja> rezultatPretrage = new List <Voznja>();
            Korisnik      k = ListeKorisnika.Instanca.NadjiKorisnika(username);

            if (k.Uloga == Enums.Uloga.Musterija)
            {
                Musterija m = ListeKorisnika.Instanca.Musterije.Find(x => x.Username.Equals(username));
                pretrazene = m.Voznje;
            }
            else if (k.Uloga == Enums.Uloga.Vozac)
            {
                Vozac v = ListeKorisnika.Instanca.Vozaci.Find(x => x.Username.Equals(username));
                pretrazene = v.Voznje;
            }
            else
            {
                Dispecer d = ListeKorisnika.Instanca.Dispeceri.Find(x => x.Username.Equals(username));
                if (flag == 0)
                {
                    pretrazene = d.Voznje;
                }
                else
                {
                    pretrazene = ListeKorisnika.Instanca.Voznje;
                }
            }

            if (!datumOd.Equals("") && datumDo.Equals(""))
            {
                foreach (var item in pretrazene)
                {
                    if (item.VremePorudzbine >= DateTime.Parse(datumOd) && item.Iznos >= cenaOd && item.Iznos <= cenaDo && item.Komentar.OcenaVoznje >= ocenaOd && item.Komentar.OcenaVoznje <= ocenaDo)
                    {
                        rezultatPretrage.Add(item);
                    }
                }
            }
            else if (datumOd.Equals("") && !datumDo.Equals(""))
            {
                foreach (var item in pretrazene)
                {
                    if (item.VremePorudzbine <= DateTime.Parse(datumDo).AddHours(23).AddMinutes(59) && item.Iznos >= cenaOd && item.Iznos <= cenaDo && item.Komentar.OcenaVoznje >= ocenaOd && item.Komentar.OcenaVoznje <= ocenaDo)
                    {
                        rezultatPretrage.Add(item);
                    }
                }
            }
            else if (!datumOd.Equals("") && !datumDo.Equals(""))
            {
                foreach (var item in pretrazene)
                {
                    if (item.VremePorudzbine >= DateTime.Parse(datumOd) && item.VremePorudzbine <= DateTime.Parse(datumDo).AddHours(23).AddMinutes(59) && item.Iznos >= cenaOd && item.Iznos <= cenaDo && item.Komentar.OcenaVoznje >= ocenaOd && item.Komentar.OcenaVoznje <= ocenaDo)
                    {
                        rezultatPretrage.Add(item);
                    }
                }
            }

            else
            {
                foreach (var item in pretrazene)
                {
                    if (item.Iznos >= cenaOd && item.Iznos <= cenaDo && item.Komentar.OcenaVoznje >= ocenaOd && item.Komentar.OcenaVoznje <= ocenaDo)
                    {
                        rezultatPretrage.Add(item);
                    }
                }
            }


            if (rezultatPretrage.Count != 0)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, rezultatPretrage));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
コード例 #5
0
        public Korisnik GetUserByUsername(string username)
        {
            string           ss        = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Musterije.xml");
            string           ss1       = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Vozaci.xml");
            string           ss2       = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Dispeceri.xml");
            List <Musterija> users     = xml.ReadUsers(ss);
            List <Vozac>     vozaci    = xml.ReadDrivers(ss1);
            List <Dispecer>  dispeceri = xml.ReadDispecer(ss2);

            foreach (Musterija us in users)
            {
                if (us.KorisnickoIme == username)
                {
                    Musterija kor = new Musterija();
                    kor.KorisnickoIme  = us.KorisnickoIme;
                    kor.Ime            = us.Ime;
                    kor.Prezime        = us.Prezime;
                    kor.Uloga          = us.Uloga;
                    kor.Email          = us.Email;
                    kor.KontaktTelefon = us.KontaktTelefon;
                    kor.Pol            = us.Pol;
                    kor.Lozinka        = null;
                    kor.JMBG           = us.JMBG;


                    return(kor);
                }
            }
            foreach (Dispecer us in dispeceri)
            {
                if (us.KorisnickoIme == username)
                {
                    Dispecer kor = new Dispecer();
                    kor.KorisnickoIme  = us.KorisnickoIme;
                    kor.Ime            = us.Ime;
                    kor.Prezime        = us.Prezime;
                    kor.Uloga          = us.Uloga;
                    kor.Email          = us.Email;
                    kor.KontaktTelefon = us.KontaktTelefon;
                    kor.Pol            = us.Pol;
                    kor.Lozinka        = null;
                    kor.JMBG           = us.JMBG;


                    return(kor);
                }
            }
            foreach (Vozac us in vozaci)
            {
                if (us.KorisnickoIme == username)
                {
                    Vozac kor = new Vozac();
                    kor.KorisnickoIme  = us.KorisnickoIme;
                    kor.Ime            = us.Ime;
                    kor.Prezime        = us.Prezime;
                    kor.Uloga          = us.Uloga;
                    kor.Email          = us.Email;
                    kor.KontaktTelefon = us.KontaktTelefon;
                    kor.Pol            = us.Pol;
                    kor.Lozinka        = null;
                    kor.JMBG           = us.JMBG;


                    return(kor);
                }
            }

            return(null);
        }
コード例 #6
0
        public HttpResponseMessage IzmeniVoznju([FromBody] JToken jToken)
        {
            var ulica              = jToken.Value <string>("Ulica");
            var broj               = jToken.Value <int>("Broj");
            var mesto              = jToken.Value <string>("Grad");
            var pozivniBroj        = jToken.Value <int>("PozivBr");
            var tipVozila          = jToken.Value <string>("TipVozila");
            var idVoznje           = jToken.Value <int>("IndeksVoznje");
            var usernameUlogovanog = jToken.Value <string>("ulogovani");

            string result   = "";
            var    response = new HttpResponseMessage();

            Musterija ulogovan = ListeKorisnika.Instanca.Musterije.Find(x => x.Username.Equals(usernameUlogovanog));

            if (ulogovan != null)
            {
                Voznja v = ulogovan.Voznje.Find(x => x.IDVoznje == idVoznje);
                if (v != null)
                {
                    ulogovan.Voznje.Remove(v);
                    Voznja izmenjeno = new Voznja();
                    izmenjeno.Musterija = ulogovan.Username;
                    izmenjeno.StartLokacija.Adresa.Ulica            = ulica;
                    izmenjeno.StartLokacija.Adresa.Broj             = broj;
                    izmenjeno.StartLokacija.Adresa.NaseljenoMesto   = mesto;
                    izmenjeno.StartLokacija.Adresa.PozivniBrojMesta = pozivniBroj;
                    izmenjeno.IDVoznje             = idVoznje;
                    izmenjeno.VremePorudzbine      = DateTime.Now;
                    izmenjeno.Status               = Enums.StatusVoznje.Kreirana;
                    izmenjeno.ZeljeniTipAutomobila = (Enums.TipAutomobila)System.Enum.Parse(typeof(Enums.TipAutomobila), tipVozila);
                    ulogovan.Voznje.Add(izmenjeno);
                    ListeKorisnika.Instanca.Voznje.Remove(v);
                    ListeKorisnika.Instanca.Voznje.Add(izmenjeno);

                    List <Voznja> voznjeNaCekanju = (List <Voznja>)HttpContext.Current.Application["voznjeNaCekanju"];
                    voznjeNaCekanju.Remove(voznjeNaCekanju.Find(x => x.IDVoznje == idVoznje));
                    voznjeNaCekanju.Add(izmenjeno);
                    HttpContext.Current.Application["voznjeNaCekanju"] = voznjeNaCekanju;

                    result          += "<h4>Uspesno ste izmenili voznju!</h4>";
                    response.Content = new StringContent(result);
                    response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
                    response.StatusCode = HttpStatusCode.OK;
                    return(response);
                }
                else
                {
                    result          += "<h4>Desila se greska prilikom izmene voznje!</h4>";
                    response.Content = new StringContent(result);
                    response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
                    response.StatusCode = HttpStatusCode.OK;
                    return(response);
                }
            }
            else
            {
                result          += "<h4>Desila se greska prilikom izmene voznje!</h4>";
                response.Content = new StringContent(result);
                response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
                response.StatusCode = HttpStatusCode.BadRequest;
                return(response);
            }
        }
コード例 #7
0
        public HttpResponseMessage PosaljiZahtev([FromBody] JToken jToken)
        {
            //var vreme = jToken.Value<double>("VremeZahteva");
            var lokacijastart = jToken.Value <string>("StartnaLokacija");
            var broj          = jToken.Value <double>("Broj");
            var mesto         = jToken.Value <string>("Mesto");
            var pozivniBroj   = jToken.Value <double>("PozivniBroj");
            var autoTip       = jToken.Value <string>("ZeljeniAuto");
            var musterija     = jToken.Value <string>("Musterija");

            string result   = "";
            var    response = new HttpResponseMessage();

            if (lokacijastart == "" || autoTip == "" || musterija == "")
            {
                result           = String.Format(@"<label id=""neuspesanZahtev"" class=""labeleGresaka"" hidden>Niste dobro popunili podatke. Molimo Vas pokusajte opet.</label>");
                response.Content = new StringContent(result);
                response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
                response.StatusCode = HttpStatusCode.BadRequest;
                return(response);
            }

            if (lokacijastart == null || autoTip == null || musterija == null)
            {
                result           = String.Format(@"<label id=""neuspesanZahtev"" class=""labeleGresaka"" hidden>Niste dobro popunili podatke. Molimo Vas pokusajte opet.</label>");
                response.Content = new StringContent(result);
                response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
                response.StatusCode = HttpStatusCode.BadRequest;
                return(response);
            }

            Voznja    v = new Voznja();
            Musterija m = ListeKorisnika.Instanca.Musterije.Find(x => x.Username.Equals(musterija));

            v.Musterija                             = m.Username;
            v.VremePorudzbine                       = DateTime.Now;
            v.ZeljeniTipAutomobila                  = (Enums.TipAutomobila)System.Enum.Parse(typeof(Enums.TipAutomobila), autoTip);
            v.StartLokacija.Adresa.Ulica            = lokacijastart;
            v.StartLokacija.Adresa.Broj             = (int)broj;
            v.StartLokacija.Adresa.NaseljenoMesto   = mesto;
            v.StartLokacija.Adresa.PozivniBrojMesta = (int)pozivniBroj;
            v.IDVoznje = ListeKorisnika.Instanca.Voznje.Count + 1;
            v.Status   = Enums.StatusVoznje.Kreirana;
            ListeKorisnika.Instanca.Voznje.Add(v);

            ListeKorisnika.Instanca.Musterije.Remove(m);
            m.Voznje.Add(v);
            ListeKorisnika.Instanca.Musterije.Add(m);
            if (HttpContext.Current.Application["voznjeNaCekanju"] == null)
            {
                HttpContext.Current.Application["voznjeNaCekanju"] = new List <Voznja>();
            }
            List <Voznja> listaVoznji = (List <Voznja>)HttpContext.Current.Application["voznjeNaCekanju"];

            listaVoznji.Add(v);
            HttpContext.Current.Application["voznjeNaCekanju"] = listaVoznji;

            result          += "<h4>Uspesno ste poslali zahtev!</h4>";
            response.Content = new StringContent(result);
            response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/html");
            response.StatusCode = HttpStatusCode.OK;
            return(response);
        }
コード例 #8
0
        public async void glavnaStranica(object o)
        {
            dispecerIzPrijave   = null;
            musterijaIzPrijave  = null;
            supervizorIzPrijave = null;
            kompanijaIzPrijave  = null;



            // sad ovdje treba provjeriti ima li registrovani korisnik sa ovim podacima
            // kompanija, dispecer, regkorisnik, neregkorisnik ili supervizor

            /*
             * List<RegistrovanaMusterija> rms = new List<RegistrovanaMusterija>();
             * rms.Add(new RegistrovanaMusterija()
             * {
             *  KorisnickoIme = "loca",
             *  Password = "******"
             * });
             *
             * List<Supervizor> spr = new List<Supervizor>();
             * spr.Add(new Modeli.Supervizor()
             * {
             *  KorisnickoIme = "ime",
             *  Password = "******"
             * });
             *
             * List<Kompanija> kmp = new List<Kompanija>();
             * kmp.Add(new Kompanija()
             * {
             *  KorisnickoIme = "k",
             *  Sifra = "s"
             * });
             * List<ProjekatTaxiAgencijaMAN.Modeli.Dispecer> dis = new List<ProjekatTaxiAgencijaMAN.Modeli.Dispecer>();
             * dis.Add(new ProjekatTaxiAgencijaMAN.Modeli.Dispecer()
             * {
             *  KorisnickoIme = "d",
             *  Password = "******"
             * });
             *
             * for (int i=0; i<rms.Count; i++)
             * {
             *  if (rms[i].KorisnickoIme == korisnickoime)
             *  {
             *      if (rms[i].Password == sifra)
             *      {
             *          regmusterijaIzPrijave = rms[i];
             *      }
             *  }
             * }
             *
             * for (int i = 0; i < kmp.Count; i++)
             * {
             *  if (kmp[i].KorisnickoIme == korisnickoime)
             *  {
             *      if (kmp[i].Sifra== sifra)
             *      {
             *          kompanijaIzPrijave = kmp[i];
             *      }
             *  }
             * }
             *
             * for (int i = 0; i < spr.Count; i++)
             * {
             *  if (spr[i].KorisnickoIme == korisnickoime)
             *  {
             *      if (spr[i].Password == sifra)
             *      {
             *          supervizorIzPrijave = spr[i];
             *      }
             *  }
             * }
             *
             * for (int i = 0; i < dis.Count; i++)
             * {
             *  if (dis[i].KorisnickoIme == korisnickoime)
             *  {
             *      if (dis[i].Password == sifra)
             *      {
             *          dispecerIzPrijave = dis[i];
             *      }
             *  }
             * }*/

            List <Kompanija> kmp = podaci.kompanije;

            for (int i = 0; i < kmp.Count; i++)
            {
                if (kmp[i].KorisnickoIme == korisnickoime)
                {
                    if (kmp[i].Sifra == sifra)
                    {
                        kompanijaIzPrijave = kmp[i];
                    }
                }
            }
            List <Musterija> rms = podaci.musterije;

            for (int i = 0; i < rms.Count; i++)
            {
                RegistrovanaMusterija rm = (RegistrovanaMusterija)rms[i];
                if (rm.KorisnickoIme == korisnickoime)
                {
                    if (rm.Password == sifra)
                    {
                        regmusterijaIzPrijave = rm;
                    }
                }
            }
            List <Zaposlenik> zap = podaci.zaposlenici;

            for (int i = 0; i < zap.Count; i++)
            {
                if (zap[i] is Modeli.Dispecer)
                {
                    Modeli.Dispecer zap1 = (Modeli.Dispecer)zap[i];
                    if (zap1.KorisnickoIme == korisnickoime)
                    {
                        if (zap1.Password == sifra)
                        {
                            dispecerIzPrijave = zap1;
                        }
                    }
                }
            }


            if (supervizorIzPrijave != null)
            {
                NavigationServis.Navigate(typeof(SupervizorForma), new GlavnaSupervizoraVM(this));
            }
            else if (dispecerIzPrijave != null)
            {
                NavigationServis.Navigate(typeof(ProjekatTaxiAgencijaMAN.forme.Dispecer), new GlavnaDispeceraVM(this));
            }
            else if (regmusterijaIzPrijave != null)
            {
                NavigationServis.Navigate(typeof(ProjekatTaxiAgencijaMAN.forme.RegistrovaniKorisnik), new GlavnaMusterijeVM(this));
            }
            else if (kompanijaIzPrijave != null)
            {
                NavigationServis.Navigate(typeof(ProfilKompanije), new GlavnaKompanijeVM(this));
            }
            else
            {
                // greska
            }
        }
コード例 #9
0
        // GET: api/Musterija/5
        public Musterija Get()
        {
            Musterija k = (Musterija)System.Web.HttpContext.Current.Session["mojaSesija"];

            return(k);
        }
コード例 #10
0
        public IHttpActionResult Post(Musterija korisnik)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            int dPom = 0;
            int vPom = 0;
            int mPom = 0;

            foreach (Dispecer dispecer in Korisnici.Dispeceri)
            {
                if (!dispecer.KorisnickoIme.Equals(korisnik.KorisnickoIme))
                {
                    dPom++;
                }
            }

            foreach (Vozac vozac in Korisnici.Vozaci)
            {
                if (!vozac.KorisnickoIme.Equals(korisnik.KorisnickoIme))
                {
                    vPom++;
                }
            }

            foreach (Musterija musterija in Korisnici.Musterije)
            {
                if (!musterija.KorisnickoIme.Equals(korisnik.KorisnickoIme))
                {
                    mPom++;
                }
            }

            if (Korisnici.Dispeceri.Count == dPom)
            {
                if (Korisnici.Vozaci.Count == vPom)
                {
                    if (Korisnici.Musterije.Count == mPom)
                    {
                        korisnik.Voznje = new List <Voznja>();
                        Korisnici.Musterije.Add(korisnik);

                        string lineSendMusterija = String.Empty;
                        lineSendMusterija = korisnik.KorisnickoIme + "," + korisnik.Lozinka + "," + korisnik.Ime + "," + korisnik.Prezime + "," + korisnik.Pol.ToString() + "," + korisnik.Jmbg + "," + korisnik.KontaktTelefon + "," + korisnik.Email + "," + korisnik.Uloga.ToString() + Environment.NewLine;

                        if (!File.Exists(@"E:\FAX\III godina\2. semestar\Web programiranje [6 ESPB]\projekat\WP1718-PR87-2015\WebAPI_AJAX\WebAPI\WebAPI\bazaKorisnici.txt"))
                        {
                            File.WriteAllText(@"E:\FAX\III godina\2. semestar\Web programiranje [6 ESPB]\projekat\WP1718-PR87-2015\WebAPI_AJAX\WebAPI\WebAPI\bazaKorisnici.txt", lineSendMusterija);
                        }
                        else
                        {
                            File.AppendAllText(@"E:\FAX\III godina\2. semestar\Web programiranje [6 ESPB]\projekat\WP1718-PR87-2015\WebAPI_AJAX\WebAPI\WebAPI\bazaKorisnici.txt", lineSendMusterija);
                        }

                        return(CreatedAtRoute("DefaultApi", new { korisnickoIme = korisnik.KorisnickoIme }, korisnik));
                    }
                    else
                    {
                        return(BadRequest("Korisnik vec postoji"));
                    }
                }
                else
                {
                    return(BadRequest("Korisnik vec postoji"));
                }
            }
            else
            {
                return(BadRequest("Korisnik vec postoji"));
            }
        }
コード例 #11
0
        public void UcitajBazu()
        {
            string pom = "";

            string[] ret;

            //ucitavanje korisnika
            if (File.Exists(@"C:\Users\Petar\Desktop\WP1718-PR108-2015\TaxiSluzba\RegistrovaniKorisnici.txt"))
            {
                StreamReader srKorisnici = new StreamReader(@"C:\Users\Petar\Desktop\WP1718-PR108-2015\TaxiSluzba\RegistrovaniKorisnici.txt");
                while ((pom = srKorisnici.ReadLine()) != "")
                {
                    ret = pom.Split('#');
                    Pol gender;

                    if (ret[6] == "MUSKI")
                    {
                        gender = Pol.MUSKI;
                    }
                    else
                    {
                        gender = Pol.ZENSKI;
                    }

                    Uloga uloga;
                    if (ret[8] == "MUSTERIJA")
                    {
                        uloga = Uloga.MUSTERIJA;
                    }
                    else if (ret[8] == "VOZAC")
                    {
                        uloga = Uloga.VOZAC;
                    }
                    else
                    {
                        uloga = Uloga.DISPECER;
                    }

                    Korisnik k = new Korisnik(ret[0], ret[1], ret[2], ret[3], gender, ret[5], ret[7], ret[4]);
                    k.uloga = uloga;

                    if (!Database.registrovaniKorisnici.ContainsKey(ret[0]))
                    {
                        Database.registrovaniKorisnici.Add(k.korisnickoIme, k);
                    }
                }
                srKorisnici.Close();
            }

            //ucitavanje vozaca
            if (File.Exists(@"C:\Users\Petar\Desktop\WP1718-PR108-2015\TaxiSluzba\SviVozaci.txt"))
            {
                StreamReader srVozaci = new StreamReader(@"C:\Users\Petar\Desktop\WP1718-PR108-2015\TaxiSluzba\SviVozaci.txt");
                while ((pom = srVozaci.ReadLine()) != null)
                {
                    ret = pom.Split('#');
                    Pol      gender;
                    string[] auto;
                    string[] lokacija;

                    if (ret[4] == "MUSKI")
                    {
                        gender = Pol.MUSKI;
                    }
                    else
                    {
                        gender = Pol.ZENSKI;
                    }

                    Korisnik k = new Korisnik(ret[0], ret[1], ret[2], ret[3], gender, ret[6], ret[7], ret[5]);
                    k.uloga = Uloga.VOZAC;
                    auto    = ret[8].Split(':');
                    TipAutomobila tipAutomobila;
                    if (auto[3] == "KOMBI")
                    {
                        tipAutomobila = TipAutomobila.KOMBI;
                    }
                    else
                    {
                        tipAutomobila = TipAutomobila.PUTNICKI_AUTOMOBIL;
                    }
                    Automobil a = new Automobil(null, auto[1], auto[2], auto[0], tipAutomobila);
                    lokacija = ret[9].Split(':');
                    Lokacija l = new Lokacija(1, 1, new Adresa(lokacija[0], lokacija[1], lokacija[2], lokacija[3]));
                    Vozac    v = new Vozac(k, l, a);
                    a.vozac = v;

                    if (!Database.vozaci.ContainsKey(v.korisnickoIme))
                    {
                        Database.vozaci.Add(v.korisnickoIme, v);
                    }
                }
                srVozaci.Close();
            }

            //ucitavanje voznji
            if (File.Exists(@"C:\Users\Petar\Desktop\WP1718-PR108-2015\TaxiSluzba\SveVoznje.txt"))
            {
                StreamReader srKorisnici = new StreamReader(@"C:\Users\Petar\Desktop\WP1718-PR108-2015\TaxiSluzba\SveVoznje.txt");
                while ((pom = srKorisnici.ReadLine()) != "")
                {
                    ret = pom.Split('#');
                    DateTime dtVoznje = DateTime.Parse(ret[0]);

                    OcenaVoznje ov;
                    if (ret[4] == "JEDAN")
                    {
                        ov = OcenaVoznje.JEDAN;
                    }
                    else if (ret[4] == "DVA")
                    {
                        ov = OcenaVoznje.DVA;
                    }
                    else if (ret[4] == "TRI")
                    {
                        ov = OcenaVoznje.TRI;
                    }
                    else if (ret[4] == "CETIRI")
                    {
                        ov = OcenaVoznje.CETIRI;
                    }
                    else if (ret[4] == "PET")
                    {
                        ov = OcenaVoznje.PET;
                    }
                    else
                    {
                        ov = OcenaVoznje.NULA;
                    }

                    DateTime dtKomentara = DateTime.Parse(ret[5]);

                    StatusVoznje sv;
                    if (ret[15] == "KREIRANA_NA_CEKANJU")
                    {
                        sv = StatusVoznje.KREIRANA_NA_CEKANJU;
                    }
                    else if (ret[15] == "FORMIRANA")
                    {
                        sv = StatusVoznje.FORMIRANA;
                    }
                    else if (ret[15] == "OBRADJENA")
                    {
                        sv = StatusVoznje.OBRADJENA;
                    }
                    else if (ret[15] == "PRIHVACENA")
                    {
                        sv = StatusVoznje.PRIHVACENA;
                    }
                    else if (ret[15] == "U_TOKU")
                    {
                        sv = StatusVoznje.U_TOKU;
                    }
                    else if (ret[15] == "OTKAZANA")
                    {
                        sv = StatusVoznje.OTKAZANA;
                    }
                    else if (ret[15] == "NEUSPESNA")
                    {
                        sv = StatusVoznje.NEUSPESNA;
                    }
                    else
                    {
                        sv = StatusVoznje.USPESNA;
                    }

                    TipAutomobila ta;
                    if (ret[16] == "KOMBI")
                    {
                        ta = TipAutomobila.KOMBI;
                    }
                    else
                    {
                        ta = TipAutomobila.PUTNICKI_AUTOMOBIL;
                    }

                    Lokacija  l = new Lokacija(1, 1, new Adresa(ret[6], ret[7], ret[8], ret[9]));
                    Musterija m;
                    string    musterija = ret[10];
                    if (ret[10] != "-")
                    {
                        Korisnik kor = Database.registrovaniKorisnici[musterija];
                        m = new Musterija(kor.korisnickoIme, kor.lozinka, kor.ime, kor.prezime, kor.pol, kor.jmbg, kor.telefon, kor.email);
                    }
                    else
                    {
                        m = new Musterija("-", "-", "-", "-", Pol.MUSKI, "-", "-", "-");
                    }
                    //vidi sta treba dodati musteriji da bude sve finoo, gde god cackam database obrati paznju
                    Voznja v = new Voznja(dtVoznje, l, ta, m);
                    v.odrediste = new Lokacija(1, 1, new Adresa(ret[11], ret[12], ret[13], ret[14]));
                    if (ret[1] != "-")
                    {
                        v.dispecer = (Dispecer)Database.registrovaniKorisnici[ret[1]];
                    }
                    else
                    {
                        v.dispecer = new Dispecer("-", "-", "-", "-", Pol.MUSKI, "-", "-", "-");
                    }
                    //obrati paznju na to kad su musterija ili disp nepoznati
                    if (ret[17] != "-")
                    {
                        v.vozac = Database.vozaci[ret[17]];
                    }
                    else
                    {
                        Lokacija lok = new Lokacija(1, 1, new Adresa("-", "-", "-", "-"));
                        v.vozac = new Vozac(new Korisnik("-", "-", "-", "-", Pol.MUSKI, "-", "-", "-"), lok, new Automobil(null, "-", "-", "-", TipAutomobila.KOMBI));
                    }
                    v.iznos    = ret[2];
                    v.komentar = new Komentar(ret[3], dtKomentara, Database.registrovaniKorisnici[musterija], null, ov);
                    //dodaj voznju kad odradis u kontruktor komentara!!!! ***
                    v.statusVoznje    = sv;
                    v.komentar.voznja = v;

                    Database.sveVoznje.Add(v.datumVreme.ToString(), v);

                    if (Database.registrovaniKorisnici.ContainsKey(musterija))
                    {
                        Database.registrovaniKorisnici[musterija].voznje.Add(v);
                    }

                    if (Database.vozaci.ContainsKey(ret[17]))
                    {
                        Database.vozaci[ret[17]].voznje.Add(v);
                    }
                }
                srKorisnici.Close();
            }
        }
コード例 #12
0
        public HttpResponseMessage ChangePass([FromBody] Musterija m)
        {
            Musterija tempM = null;
            Vozac     tempV = null;
            Dispecer  tempD = null;

            foreach (var item in BazaPodataka.Instanca.Musterije)
            {
                if (m.KorisnickoIme.Equals(item.KorisnickoIme))
                {
                    tempM = item;
                }
            }
            if (tempM == null)
            {
                foreach (var item in BazaPodataka.Instanca.Dispeceri)
                {
                    if (m.KorisnickoIme.Equals(item.KorisnickoIme))
                    {
                        tempD = item;
                    }
                }
                if (tempD == null)
                {
                    foreach (var item in BazaPodataka.Instanca.Vozaci)
                    {
                        if (m.KorisnickoIme.Equals(item.KorisnickoIme))
                        {
                            tempV = item;
                        }
                    }
                    if (tempV == null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.BadRequest));
                    }
                    else
                    {
                        if (tempV.Blokiran)
                        {
                            return(Request.CreateResponse(HttpStatusCode.Forbidden, "Blokiran korisnik"));
                        }
                        BazaPodataka.Instanca.Vozaci.Remove(tempV);
                        tempV.Sifra = m.Sifra;
                        BazaPodataka.Instanca.Vozaci.Add(tempV);
                        BazaPodataka.Instanca.UpisiUBazuVozace();
                        return(Request.CreateResponse(HttpStatusCode.OK, m));
                    }
                }
                else
                {
                    BazaPodataka.Instanca.Dispeceri.Remove(tempD);
                    tempD.Sifra = m.Sifra;
                    BazaPodataka.Instanca.Dispeceri.Add(tempD);
                    BazaPodataka.Instanca.UpisiUBazuDispecere();
                    return(Request.CreateResponse(HttpStatusCode.OK, m));
                }
            }
            else
            {
                if (tempM.Blokiran)
                {
                    return(Request.CreateResponse(HttpStatusCode.Forbidden, "Blokiran korisnik"));
                }
                BazaPodataka.Instanca.Musterije.Remove(tempM);
                tempM.Sifra = m.Sifra;
                BazaPodataka.Instanca.Musterije.Add(tempM);
                BazaPodataka.Instanca.UpisiUBazuMusterije();
                return(Request.CreateResponse(HttpStatusCode.OK, m));
            }
        }
コード例 #13
0
        public HttpResponseMessage Edit([FromBody] Musterija musterija)
        {
            if (musterija.Ime == null || musterija.Prezime == null || musterija.KontaktTelefon == null ||
                musterija.JMBG == null || musterija.Sifra == null || musterija.Email == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            if (musterija.Ime == "" || musterija.Prezime == "" || musterija.KontaktTelefon == "" ||
                musterija.JMBG == "" || musterija.Sifra == "" || musterija.Email == "")
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            bool istoKorIme = musterija.KorisnickoIme.Equals(musterija.Sifra);

            var   input   = musterija.KontaktTelefon;
            Regex pattern = new Regex(@"\d{8,10}");
            Match match   = pattern.Match(input);

            if (!match.Success)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            input   = musterija.JMBG;
            pattern = new Regex(@"\d{13}");
            match   = pattern.Match(input);
            if (!match.Success)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            Musterija tempM = null;
            Vozac     tempV = null;
            Dispecer  tempD = null;

            foreach (var item in BazaPodataka.Instanca.Musterije)
            {
                if (istoKorIme && musterija.KorisnickoIme.Equals(item.KorisnickoIme))
                {
                    tempM = item;
                }
                else if (!istoKorIme && musterija.KorisnickoIme.Equals(item.KorisnickoIme))
                {
                    return(Request.CreateResponse(HttpStatusCode.Conflict));
                }
                else if (!istoKorIme && musterija.Sifra.Equals(item.KorisnickoIme))
                {
                    tempM = item;
                }
            }

            if (tempM == null)
            {
                foreach (var item in BazaPodataka.Instanca.Dispeceri)
                {
                    if (istoKorIme && musterija.KorisnickoIme.Equals(item.KorisnickoIme))
                    {
                        tempD = item;
                    }
                    else if (!istoKorIme && musterija.KorisnickoIme.Equals(item.KorisnickoIme))
                    {
                        return(Request.CreateResponse(HttpStatusCode.Conflict));
                    }
                    else if (!istoKorIme && musterija.Sifra.Equals(item.KorisnickoIme))
                    {
                        tempD = item;
                    }
                }
                if (tempD == null)
                {
                    foreach (var item in BazaPodataka.Instanca.Vozaci)
                    {
                        if (istoKorIme && musterija.KorisnickoIme.Equals(item.KorisnickoIme))
                        {
                            tempV = item;
                        }
                        else if (!istoKorIme && musterija.KorisnickoIme.Equals(item.KorisnickoIme))
                        {
                            return(Request.CreateResponse(HttpStatusCode.Conflict));
                        }
                        else if (!istoKorIme && musterija.Sifra.Equals(item.KorisnickoIme))
                        {
                            tempV = item;
                        }
                    }
                    if (tempV == null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.BadRequest));
                    }
                    else
                    {
                        if (tempV.Blokiran)
                        {
                            return(Request.CreateResponse(HttpStatusCode.Forbidden, "Blokiran korisnik"));
                        }
                        BazaPodataka.Instanca.Vozaci.Remove(tempV);
                        tempV.KorisnickoIme  = musterija.KorisnickoIme;
                        tempV.Ime            = musterija.Ime;
                        tempV.Prezime        = musterija.Prezime;
                        tempV.JMBG           = musterija.JMBG;
                        tempV.Email          = musterija.Email;
                        tempV.KontaktTelefon = musterija.KontaktTelefon;
                        BazaPodataka.Instanca.Vozaci.Add(tempV);
                        BazaPodataka.Instanca.UpisiUBazuVozace();
                        return(Request.CreateResponse(HttpStatusCode.OK, tempV));
                    }
                }
                else
                {
                    BazaPodataka.Instanca.Dispeceri.Remove(tempD);
                    tempD.KorisnickoIme  = musterija.KorisnickoIme;
                    tempD.Ime            = musterija.Ime;
                    tempD.Prezime        = musterija.Prezime;
                    tempD.JMBG           = musterija.JMBG;
                    tempD.Email          = musterija.Email;
                    tempD.KontaktTelefon = musterija.KontaktTelefon;
                    BazaPodataka.Instanca.Dispeceri.Add(tempD);
                    BazaPodataka.Instanca.UpisiUBazuDispecere();
                    return(Request.CreateResponse(HttpStatusCode.OK, tempD));
                }
            }
            else
            {
                if (tempM.Blokiran)
                {
                    return(Request.CreateResponse(HttpStatusCode.Forbidden, "Blokiran korisnik"));
                }
                BazaPodataka.Instanca.Musterije.Remove(tempM);
                musterija.Sifra = tempM.Sifra;
                BazaPodataka.Instanca.Musterije.Add(musterija);
                BazaPodataka.Instanca.UpisiUBazuMusterije();

                return(Request.CreateResponse(HttpStatusCode.OK, musterija));
            }
        }
コード例 #14
0
        public ActionResult Izmena()
        {
            Musterija musterija = (Musterija)Session["korisnik"];

            return(View("Izmena", musterija));
        }
コード例 #15
0
        private void Ucitavanje()
        {
            if (File.Exists(@"C: \Users\Katarina\Desktop\WebAPI\Taxi\WebAPI\WebAPI\korisnici.xml"))
            {
                string        ime        = "";
                string        prezime    = "";
                string        korisnicko = "";
                string        lozinka    = "";
                string        jmbg       = "";
                string        telefon    = "";
                string        mail       = "";
                Pol           pol        = Pol.Muski;
                Uloge         uloga      = Uloge.Dispecer;
                string        x          = "";
                string        y          = "";
                string        brul       = "";
                string        posta      = "";
                string        ulica      = "";
                string        grad       = "";
                string        godiste    = "";
                string        reg        = "";
                TipAutomobila tip        = TipAutomobila.kombi;
                string        taxiBr     = "";

                using (XmlReader reader = XmlReader.Create(@"C:\Users\Katarina\Desktop\WebAPI\Taxi\WebAPI\WebAPI\korisnici.xml"))
                {
                    while (reader.Read())
                    {
                        if (reader.IsStartElement() && reader.Name.Equals("Korisnik"))
                        {
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            ime = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            prezime = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            jmbg = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            korisnicko = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            lozinka = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            switch (reader.Value)
                            {
                            case "Muski":
                                pol = Pol.Muski;
                                break;

                            case "Zenski":
                                pol = Pol.Zenski;
                                break;
                            }
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            mail = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            telefon = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            switch (reader.Value)
                            {
                            case "Dispecer":
                                uloga = Uloge.Dispecer;
                                break;

                            case "Vozac":
                                uloga = Uloge.Vozac;
                                break;

                            case "Musterija":
                                uloga = Uloge.Musterija;
                                break;
                            }

                            if (uloga == Uloge.Musterija)
                            {
                                Musterija m = new Musterija(korisnicko, lozinka, ime, prezime, pol, jmbg, telefon, mail, uloga);
                                PostojeciKorisnici.ListaMusterija.Add(m);
                                Korisnik k = m;
                                PostojeciKorisnici.ListaKorisnika.Add(k);
                            }
                            else if (uloga == Uloge.Dispecer)
                            {
                                Dispecer m = new Dispecer(korisnicko, lozinka, ime, prezime, pol, jmbg, telefon, mail, uloga);
                                PostojeciKorisnici.ListaDispecera.Add(m);
                                Korisnik k = m;
                                PostojeciKorisnici.ListaKorisnika.Add(k);
                            }
                            else if (uloga == Uloge.Vozac)
                            {
                                Vozac v = new Vozac(korisnicko, lozinka, ime, prezime, pol, jmbg, telefon, mail, uloga, ulica, brul, grad, posta);


                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                godiste = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reg = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                taxiBr = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                switch (reader.Value)
                                {
                                case "Putnicko":
                                    tip = TipAutomobila.putnickiAutomobil;
                                    break;

                                case "Kombi":
                                    tip = TipAutomobila.kombi;
                                    break;
                                }
                                Automobil a = new Automobil(v, godiste, reg, taxiBr, tip);

                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                ulica = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                brul = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                grad = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                posta = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                x = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                y = reader.Value;
                                Adresa   adresa = new Adresa(ulica, brul, grad, posta);
                                Lokacija l      = new Lokacija(x, y, adresa);

                                v.Automobil = a;
                                v.Lokacija  = l;

                                PostojeciKorisnici.ListaVozaca.Add(v);
                                Korisnik k = v;
                                PostojeciKorisnici.ListaKorisnika.Add(k);
                            }
                        }
                    }
                }
            }

            if (PostojeciKorisnici.ListaDispecera.Count() == 0)
            {
                string line;
                // Read the file and display it line by line.

                System.IO.StreamReader file =
                    new System.IO.StreamReader(@"C:\Users\Katarina\Desktop\WebAPI\Taxi\WebAPI\WebAPI\dispeceri.txt");

                while ((line = file.ReadLine()) != null)
                {
                    string[] polja = line.Split(':');
                    Dispecer d     = new Dispecer();

                    d.Korisnicko_ime = polja[0];
                    d.Lozinka        = polja[1];
                    d.Ime            = polja[2];
                    d.Prezime        = polja[3];
                    if (polja[4].Equals("Muski"))
                    {
                        d.Pol = Pol.Muski;
                    }
                    else
                    {
                        d.Pol = Pol.Zenski;
                    }
                    d.Jmbg            = polja[5];
                    d.Kontakt_telefon = polja[6];
                    d.Email           = polja[7];
                    d.Uloga           = Uloge.Dispecer;

                    PostojeciKorisnici.ListaKorisnika.Add(d);
                    PostojeciKorisnici.ListaDispecera.Add(d);
                }

                file.Close();

                //string path = @"..\WebAPI\WebAPI\korisnici.xml";

                string    path   = @"C:\Users\Katarina\Desktop\WebAPI\Taxi\WebAPI\WebAPI\korisnici.xml";
                XmlWriter writer = null;
                try
                {
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent             = true;
                    settings.IndentChars        = ("\t");
                    settings.OmitXmlDeclaration = true;

                    writer = XmlWriter.Create(path, settings);
                    writer.WriteStartElement("Ulogovani");
                    foreach (Korisnik m in PostojeciKorisnici.ListaKorisnika)
                    {
                        m.Jmbg.ToString();
                        writer.WriteStartElement("Korisnik");
                        writer.WriteElementString("Ime", m.Ime);
                        writer.WriteElementString("Prezime", m.Prezime);
                        writer.WriteElementString("Jmbg", m.Jmbg.ToString());
                        writer.WriteElementString("KorisnickoIme", m.Korisnicko_ime);
                        writer.WriteElementString("Lozinka", m.Lozinka);
                        writer.WriteElementString("Pol", m.Pol.ToString());
                        writer.WriteElementString("E-Mail", m.Email);
                        writer.WriteElementString("BrojTelefona", m.Kontakt_telefon);
                        writer.WriteElementString("Uloga", m.Uloga.ToString());
                        writer.WriteStartElement("Voznje");
                        int i = 1;
                        foreach (Voznja v in m.listaVoznja)
                        {
                            writer.WriteStartElement("VoznjaBroj" + i.ToString());
                            writer.WriteElementString("DatumPorudzbine", v.Datum_i_vreme.ToString());
                            writer.WriteElementString("PocetnaLokacija", v.LokacijaNaKojuTaksiDolazi.ToString());
                            writer.WriteElementString("KrajnjaLokacija", v.Odrediste.ToString());
                            writer.WriteElementString("TipVozila", v.TipAutomobila.ToString());
                            writer.WriteElementString("MusterijaIme", v.Musterija.Ime);
                            writer.WriteElementString("MusterijaPrezime", v.Musterija.Prezime);
                            writer.WriteElementString("VozacIme", v.Vozac.Ime);
                            writer.WriteElementString("VozacPrezime", v.Vozac.Prezime);
                            writer.WriteElementString("DispecerIme", v.Dispecer.Ime);
                            writer.WriteElementString("DispececrPrezime", v.Dispecer.Prezime);
                            writer.WriteElementString("Iznos", v.Iznos.ToString());
                            writer.WriteEndElement();
                            i++;
                        }
                        writer.WriteEndElement();
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();

                    writer.Flush();
                }
                finally
                {
                    if (writer != null)
                    {
                        writer.Close();
                    }
                }
            }
            else
            {
                UcitajVoznje();
            }
        }
コード例 #16
0
        private void SacuvajVoznju(string datum, string pocetna, string krajnja, TipAutomobila tip, string musterijaI, string musterijaP, string vozacI, string vozacP, string dispecerI, string dispecerP, StatusVoznje status, string komentar, Ocene ocena, string iznos)
        {
            DateTime date = ToDate("27-Aug-2018 14:04:19");

            string[] podela = pocetna.Split(',');
            string[] ulica  = podela[0].Split('_');
            string[] grad   = podela[1].Split('_');

            Adresa   adresa = new Adresa(ulica[0], ulica[1], grad[0], grad[1]);
            Lokacija poc    = new Lokacija("1", "1", adresa);

            podela = krajnja.Split(',');
            ulica  = podela[0].Split('_');
            grad   = podela[1].Split('_');

            Adresa   adresaa = new Adresa(ulica[0], ulica[1], grad[0], grad[1]);
            Lokacija kraj    = new Lokacija("1", "1", adresaa);

            Musterija musterija = new Musterija();
            Vozac     vozac     = new Vozac();
            Dispecer  dispecer  = new Dispecer();

            if (musterijaI != "nema" && musterijaP != "nema")
            {
                foreach (Musterija m in PostojeciKorisnici.ListaMusterija)
                {
                    if (musterijaI == m.Ime && musterijaP == m.Prezime)
                    {
                        musterija = m;
                        break;
                    }
                }
            }
            else
            {
                musterija = new Musterija("nema", "nema", "nema", "nema", Pol.Muski, "000", "nema", "nema", Uloge.Musterija);
            }

            if (vozacI != "nema" && vozacP != "nema")
            {
                foreach (Vozac m in PostojeciKorisnici.ListaVozaca)
                {
                    if (vozacI == m.Ime && vozacP == m.Prezime)
                    {
                        vozac = m;
                        break;
                    }
                }
            }
            else
            {
                vozac = new Vozac("nema", "nema", "nema", "nema", Pol.Muski, "0000", "nema", "nema", Uloge.Vozac, ulica[0], ulica[1], grad[0], grad[1]);
            }

            if (dispecerI != "nema" && dispecerP != "nema")
            {
                foreach (Dispecer m in PostojeciKorisnici.ListaDispecera)
                {
                    if (dispecerI == m.Ime && dispecerP == m.Prezime)
                    {
                        dispecer = m;
                        break;
                    }
                }
            }
            else
            {
                dispecer = new Dispecer("nema", "nema", "nema", "nema", Pol.Muski, "0000", "nema", "nema", Uloge.Dispecer);
            }
            Voznja v = new Voznja();
            //DateTime kom = ToDate(komentarDatum);
            Komentar k = new Komentar();

            if (status == StatusVoznje.Otkazana)
            {
                //k = new Komentar(komentar, kom, v, ocena, musterija);
                k = new Komentar(komentar, v, ocena, musterija);
            }
            else if (status == StatusVoznje.Neuspesna)
            {
                //k = new Komentar(komentar, kom, v, ocena, musterija);
                k = new Komentar(komentar, v, ocena, musterija);
            }
            else if (status == StatusVoznje.Uspesna)
            {
                //k = new Komentar(komentar, kom, v, ocena, musterija);
                k = new Komentar(komentar, v, ocena, musterija);
            }
            else
            {
                k = new Komentar("bez opisa", v, Ocene.neocenjen, new Korisnik("nema", "nema", "nema", "nema", Pol.Muski, "0000", "nema", "nema", Uloge.Dispecer));
            }

            v = new Voznja(date, poc, tip, musterija, kraj, dispecer, vozac, iznos, k, status);

            k.Voznja   = v;
            v.Komentar = k;

            if (musterijaI != "nema" && musterijaP != "nema")
            {
                foreach (Musterija m in PostojeciKorisnici.ListaMusterija)
                {
                    if (m.Korisnicko_ime == musterija.Korisnicko_ime)
                    {
                        m.listaVoznja.Add(v);
                    }
                }
            }


            if (vozacI != "nema" && vozacP != "nema")
            {
                foreach (Vozac m in PostojeciKorisnici.ListaVozaca)
                {
                    if (m.Korisnicko_ime == vozac.Korisnicko_ime)
                    {
                        m.listaVoznja.Add(v);
                    }
                }
            }


            if (dispecerI != "nema" && dispecerP != "nema")
            {
                foreach (Dispecer m in PostojeciKorisnici.ListaDispecera)
                {
                    if (m.Korisnicko_ime == dispecer.Korisnicko_ime)
                    {
                        m.listaVoznja.Add(v);
                    }
                }
            }

            PostojeciKorisnici.ListaSvihVoznji.Add(v);


            foreach (Korisnik kor in PostojeciKorisnici.ListaKorisnika)
            {
                if (kor.Korisnicko_ime == musterija.Korisnicko_ime)
                {
                    kor.listaVoznja = musterija.listaVoznja;
                }
                else if (kor.Korisnicko_ime == vozac.Korisnicko_ime)
                {
                    kor.listaVoznja = vozac.listaVoznja;
                }
                else if (kor.Korisnicko_ime == dispecer.Korisnicko_ime)
                {
                    kor.listaVoznja = dispecer.listaVoznja;
                }
            }
        }
コード例 #17
0
        protected override void Seed(SystemDBContext context)
        {
            Musterija m1 = new Musterija()
            {
                Commented   = false,
                DriveStatus = Enums.DrivingStatus.Created,
                Email       = "*****@*****.**",
                Gender      = Enums.Genders.Male,
                Jmbg        = "4836849785773",
                Lastname    = "Oletic",
                Name        = "Dalibor",
                Password    = "******",
                PhoneNumber = "0602985738",
                Role        = Enums.Roles.Customer,
                Username    = "******"
            };

            Musterija m2 = new Musterija()
            {
                Commented   = false,
                DriveStatus = Enums.DrivingStatus.None,
                Email       = "*****@*****.**",
                Gender      = Enums.Genders.Female,
                Jmbg        = "4833349755743",
                Lastname    = "Anicic",
                Name        = "Ana",
                Password    = "******",
                PhoneNumber = "0605585948",
                Role        = Enums.Roles.Customer,
                Username    = "******"
            };

            Lokacija l = new Lokacija()
            {
                Address     = new Adresa("Partizanska", 19, "Novi Sad", 21000, 838521),
                CoordinateX = 0,
                CoordinateY = 0,
                LocationId  = 1
            };

            context.Lokacije.Add(l);

            Vozac v1 = new Vozac()
            {
                DriveStatus = Enums.DrivingStatus.Failed,
                Email       = "*****@*****.**",
                Gender      = Enums.Genders.Male,
                Jmbg        = "1306996800089",
                Lastname    = "Serbula",
                Name        = "Strahinja",
                Password    = "******",
                PhoneNumber = "0600139609",
                Role        = Enums.Roles.Driver,
                Username    = "******",
                LocationID  = 1,
                Car         = new Automobil()
                {
                    Driver       = "Serlok",
                    Registration = "NS2345PE",
                    Type         = Enums.TypeOfCar.RegularCar,
                    UniqueID     = "459k3j",
                    YearOfCar    = new DateTime(2000, 1, 1)
                }
            };

            context.Vozaci.Add(v1);

            Komentar k1 = new Komentar()
            {
                DriveID     = 2,
                Description = "Default komentar - customer",
                Grade       = 1,
                Id          = 1,
                PostingTime = DateTime.Now,
                UserID      = "Dalibor"
            };

            context.Komentari.Add(k1);

            Komentar k2 = new Komentar()
            {
                DriveID     = 2,
                Description = "Default komentar - driver",
                Grade       = 0,
                Id          = 2,
                PostingTime = DateTime.Now,
                UserID      = "Serlok"
            };

            context.Komentari.Add(k2);

            Lokacija l2 = new Lokacija()
            {
                Address     = new Adresa("Scepanska", 56, "Novi Sad", 21000, 838521),
                CoordinateX = 0,
                CoordinateY = 0,
                LocationId  = 2
            };

            context.Lokacije.Add(l2);

            Voznja voz = new Voznja()
            {
                CommentID         = 1,
                DriverID          = "Serlok",
                Id                = 1,
                StartPointID      = 2,
                Status            = Enums.DrivingStatus.Failed,
                TimeOfReservation = DateTime.Now,
                TypeOfCar         = Enums.TypeOfCar.RegularCar,
                UserCallerID      = "Daca",
            };

            context.Voznje.Add(voz);

            Lokacija l3 = new Lokacija()
            {
                Address     = new Adresa("Novopazarska", 88, "Novi Pazar", 25000, 838234),
                CoordinateX = 0,
                CoordinateY = 0,
                LocationId  = 3
            };

            context.Lokacije.Add(l3);

            Voznja voz2 = new Voznja()
            {
                Id                = 2,
                StartPointID      = 3,
                Status            = Enums.DrivingStatus.Created,
                TimeOfReservation = DateTime.Now,
                TypeOfCar         = Enums.TypeOfCar.RegularCar,
                UserCallerID      = "Daca",
            };

            context.Voznje.Add(voz2);

            context.Musterije.Add(m1);
            context.Musterije.Add(m2);

            base.Seed(context);
        }
コード例 #18
0
        public bool Register([FromBody] MusterijaPomocni k)
        {
            string           ss     = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Musterije.xml");
            string           ss1    = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Vozaci.xml");
            string           ss2    = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Dispeceri.xml");
            List <Musterija> users  = xml.ReadUsers(ss);
            List <Vozac>     vozaci = xml.ReadDrivers(ss1);
            List <Dispecer>  disp   = xml.ReadDispecer(ss2);
            bool             g      = true;

            foreach (Musterija u in users)
            {
                if (u.KorisnickoIme == k.Username)
                {
                    g = false;
                }
            }
            foreach (Vozac u in vozaci)
            {
                if (u.KorisnickoIme == k.Username)
                {
                    g = false;
                }
            }
            foreach (Dispecer u in disp)
            {
                if (u.KorisnickoIme == k.Username)
                {
                    g = false;
                }
            }

            if (g)
            {
                Musterija user = new Musterija();
                user.KorisnickoIme = k.Username;
                user.Lozinka       = k.Password;
                user.Ime           = k.Ime;
                user.Prezime       = k.Prezime;
                if (k.Pol == "Female")
                {
                    user.Pol = Enums.PolKorisnika.Zensko;
                }
                else
                {
                    user.Pol = Enums.PolKorisnika.Musko;
                }
                user.JMBG           = k.Jmbg;
                user.KontaktTelefon = k.Telefon;
                user.Email          = k.Email;
                user.Uloga          = Enums.UlogaKorisnika.Musterija;


                users.Add(user);
                xml.WriteUsers(users, ss);

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #19
0
ファイル: Global.asax.cs プロジェクト: IKatarinaI/TaxiService
        public void UcitajBazu()
        {
            string pom = "";

            string[] ret;

            //ucitavanje korisnika
            if (File.Exists($"{HttpRuntime.AppDomainAppPath}\\App_Data\\RegistrovaniKorisnici.txt"))
            {
                StreamReader srKorisnici = new StreamReader($"{HttpRuntime.AppDomainAppPath}\\App_Data\\RegistrovaniKorisnici.txt");
                int          br          = 0;
                while ((pom = srKorisnici.ReadLine()) != null)
                {
                    br++;
                    ret = pom.Split('#');
                    if (ret.Length == 1)
                    {
                        break;
                    }
                    Enumi.Pol gender;

                    if (ret[6] == "MUSKI")
                    {
                        gender = Enumi.Pol.MUSKI;
                    }
                    else
                    {
                        gender = Enumi.Pol.ZENSKI;
                    }

                    Enumi.Uloga uloga;
                    if (ret[8] == "MUSTERIJA")
                    {
                        uloga = Enumi.Uloga.MUSTERIJA;
                    }
                    else if (ret[8] == "VOZAC")
                    {
                        uloga = Enumi.Uloga.VOZAC;
                    }
                    else
                    {
                        uloga = Enumi.Uloga.DISPECER;
                    }

                    Korisnik k = new Korisnik(ret[0], ret[1], ret[2], ret[3], gender, ret[5], ret[7], ret[4]);
                    k.uloga = uloga;

                    if (!Baza.registrovaniKorisnici.ContainsKey(ret[0]))
                    {
                        Baza.registrovaniKorisnici.Add(k.username, k);
                    }
                }
                srKorisnici.Close();
            }

            //ucitavanje vozaca
            if (File.Exists($"{HttpRuntime.AppDomainAppPath}\\App_Data\\SviVozaci.txt"))
            {
                StreamReader srVozaci = new StreamReader($"{HttpRuntime.AppDomainAppPath}\\App_Data\\SviVozaci.txt");
                while ((pom = srVozaci.ReadLine()) != null)
                {
                    ret = pom.Split('#');
                    if (ret.Length == 1)
                    {
                        break;
                    }
                    Enumi.Pol gender;
                    string[]  auto;
                    string[]  lokacija;

                    if (ret[4] == "MUSKI")
                    {
                        gender = Enumi.Pol.MUSKI;
                    }
                    else
                    {
                        gender = Enumi.Pol.ZENSKI;
                    }

                    Korisnik k = new Korisnik(ret[0], ret[1], ret[2], ret[3], gender, ret[6], ret[7], ret[5]);
                    k.uloga = Enumi.Uloga.VOZAC;
                    auto    = ret[8].Split(':');
                    Enumi.TipAuta tipAuta;
                    if (auto[3] == "KOMBI")
                    {
                        tipAuta = Enumi.TipAuta.KOMBI;
                    }
                    else
                    {
                        tipAuta = Enumi.TipAuta.PUTNICKI_AUTOMOBIL;
                    }
                    Auto a = new Auto(null, auto[1], auto[2], auto[0], tipAuta);
                    lokacija = ret[9].Split(':');
                    Lokacija l = new Lokacija(1, 1, new Adresa(lokacija[0], lokacija[1], lokacija[2], lokacija[3]));
                    Vozac    v = new Vozac(k, l, a);
                    a.vozac = v;

                    if (!Baza.vozaci.ContainsKey(v.username))
                    {
                        Baza.vozaci.Add(v.username, v);
                    }
                }
                srVozaci.Close();
            }

            //ucitavanje voznji
            if (File.Exists($"{HttpRuntime.AppDomainAppPath}\\App_Data\\SveVoznje.txt"))
            {
                StreamReader srKorisnici = new StreamReader($"{HttpRuntime.AppDomainAppPath}\\App_Data\\SveVoznje.txt");
                while ((pom = srKorisnici.ReadLine()) != null)
                {
                    ret = pom.Split('#');
                    if (ret.Length == 1)
                    {
                        break;
                    }
                    DateTime dtVoznje = DateTime.Parse(ret[0]);

                    Enumi.OcenaVoznje ov;
                    if (ret[4] == "JEDAN")
                    {
                        ov = Enumi.OcenaVoznje.JEDAN;
                    }
                    else if (ret[4] == "DVA")
                    {
                        ov = Enumi.OcenaVoznje.DVA;
                    }
                    else if (ret[4] == "TRI")
                    {
                        ov = Enumi.OcenaVoznje.TRI;
                    }
                    else if (ret[4] == "CETIRI")
                    {
                        ov = Enumi.OcenaVoznje.CETIRI;
                    }
                    else if (ret[4] == "PET")
                    {
                        ov = Enumi.OcenaVoznje.PET;
                    }
                    else
                    {
                        ov = Enumi.OcenaVoznje.NULA;
                    }

                    DateTime dtKomentara = DateTime.Parse(ret[5]);

                    Enumi.StatusVoznje sv;
                    if (ret[15] == "KREIRANA_NA_CEKANJU")
                    {
                        sv = Enumi.StatusVoznje.KREIRANA_NA_CEKANJU;
                    }
                    else if (ret[15] == "FORMIRANA")
                    {
                        sv = Enumi.StatusVoznje.FORMIRANA;
                    }
                    else if (ret[15] == "OBRADJENA")
                    {
                        sv = Enumi.StatusVoznje.OBRADJENA;
                    }
                    else if (ret[15] == "PRIHVACENA")
                    {
                        sv = Enumi.StatusVoznje.PRIHVACENA;
                    }
                    else if (ret[15] == "U_TOKU")
                    {
                        sv = Enumi.StatusVoznje.U_TOKU;
                    }
                    else if (ret[15] == "OTKAZANA")
                    {
                        sv = Enumi.StatusVoznje.OTKAZANA;
                    }
                    else if (ret[15] == "NEUSPESNA")
                    {
                        sv = Enumi.StatusVoznje.NEUSPESNA;
                    }
                    else
                    {
                        sv = Enumi.StatusVoznje.USPESNA;
                    }

                    Enumi.TipAuta ta;
                    if (ret[16] == "KOMBI")
                    {
                        ta = Enumi.TipAuta.KOMBI;
                    }
                    else
                    {
                        ta = Enumi.TipAuta.PUTNICKI_AUTOMOBIL;
                    }

                    Lokacija  l         = new Lokacija(1, 1, new Adresa(ret[6], ret[7], ret[8], ret[9]));
                    Musterija m         = new Musterija("-", "-", "-", "-", Enumi.Pol.MUSKI, "-", "-", "-");
                    string    musterija = ret[10];
                    if (ret[10] != "-")
                    {
                        Korisnik kor = Baza.registrovaniKorisnici[musterija];
                        m = new Musterija(kor.username, kor.password, kor.ime, kor.prezime, kor.pol, kor.jmbg, kor.telefon, kor.email);
                    }
                    else
                    {
                        m = new Musterija("-", "-", "-", "-", Enumi.Pol.MUSKI, "-", "-", "-");
                    }
                    //vidi sta treba dodati musteriji da bude sve finoo, gde god cackam database obrati paznju
                    Voznja v = new Voznja(dtVoznje, l, ta, m);
                    v.odrediste = new Lokacija(1, 1, new Adresa(ret[11], ret[12], ret[13], ret[14]));
                    if (ret[1] != "-")
                    {
                        v.dispecer = (Dispecer)Baza.registrovaniKorisnici[ret[1]];
                    }
                    else
                    {
                        v.dispecer = new Dispecer("-", "-", "-", "-", Enumi.Pol.MUSKI, "-", "-", "-");
                    }
                    //obrati paznju na to kad su musterija ili disp nepoznati
                    if (ret[17] != "-")
                    {
                        v.vozac = Baza.vozaci[ret[17]];
                    }
                    else
                    {
                        Lokacija lok = new Lokacija(1, 1, new Adresa("-", "-", "-", "-"));
                        v.vozac = new Vozac(new Korisnik("-", "-", "-", "-", Enumi.Pol.MUSKI, "-", "-", "-"), lok, new Auto(null, "-", "-", "-", Enumi.TipAuta.KOMBI));
                    }
                    v.iznos = ret[2];
                    if (musterija == "-")
                    {
                        v.komentar = new Komentar(ret[3], dtKomentara, m, null, ov);
                    }
                    else
                    {
                        v.komentar = new Komentar(ret[3], dtKomentara, Baza.registrovaniKorisnici[musterija], null, ov);
                    }
                    //dodaj voznju kad odradis u kontruktor komentara!!!! ***
                    v.statusVoznje    = sv;
                    v.komentar.voznja = v;

                    Baza.sveVoznje.Add(v.datum.ToString(), v);

                    if (Baza.registrovaniKorisnici.ContainsKey(musterija))
                    {
                        Baza.registrovaniKorisnici[musterija].voznje.Add(v);
                    }

                    if (Baza.vozaci.ContainsKey(ret[17]))
                    {
                        Baza.vozaci[ret[17]].voznje.Add(v);
                    }
                }
                srKorisnici.Close();
            }
        }
コード例 #20
0
        public HttpResponseMessage IzmeniProfil([FromBody] Musterija musterija)
        {
            if (musterija.Username == null || musterija.Ime == null || musterija.Prezime == null || musterija.Jmbg == null || musterija.Email == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            if (musterija.Username == "" || musterija.Ime == "" || musterija.Prezime == "" || musterija.Jmbg == "" || musterija.Email == "")
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            var   input   = musterija.Telefon;
            Regex pattern = new Regex(@"\d{8,10}");
            Match match   = pattern.Match(input);

            if (!match.Success)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            input   = musterija.Jmbg;
            pattern = new Regex(@"\d{13}");
            match   = pattern.Match(input);
            if (!match.Success)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            Musterija tempM = null;
            Korisnik  k     = null;

            k = ListeKorisnika.Instanca.NadjiKorisnika(musterija.Username);
            bool istoKorIme = musterija.Username.Equals(musterija.Password);

            if (!istoKorIme)
            {
                if (k == null)
                {
                    tempM = (Musterija)(k);
                    ListeKorisnika.Instanca.Musterije.Remove(tempM);
                    tempM.Username = musterija.Username;
                    tempM.Ime      = musterija.Ime;
                    tempM.Prezime  = musterija.Prezime;
                    tempM.Jmbg     = musterija.Jmbg;
                    tempM.Telefon  = musterija.Telefon;
                    tempM.Email    = musterija.Email;
                    ListeKorisnika.Instanca.Musterije.Add(tempM);
                    ListeKorisnika.Instanca.UpisiUBazuMusterije();
                    return(Request.CreateResponse(HttpStatusCode.OK, tempM));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.Conflict));
                }
            }
            else
            {
                tempM = (Musterija)(k);
                ListeKorisnika.Instanca.Musterije.Remove(tempM);
                tempM.Username = musterija.Username;
                tempM.Ime      = musterija.Ime;
                tempM.Prezime  = musterija.Prezime;
                tempM.Jmbg     = musterija.Jmbg;
                tempM.Telefon  = musterija.Telefon;
                tempM.Email    = musterija.Email;
                ListeKorisnika.Instanca.Musterije.Add(tempM);
                ListeKorisnika.Instanca.UpisiUBazuMusterije();
                return(Request.CreateResponse(HttpStatusCode.OK, tempM));
            }
        }
コード例 #21
0
        private void Ucitavanje()
        {
            if (File.Exists(@"D:\fakultet\III godina\WEB\Projekat\WP1718-PR142-2015\WebProjekat\WebProjekat\korisnici.xml"))
            {
                string    ime        = "";
                string    prezime    = "";
                string    korisnicko = "";
                string    lozinka    = "";
                long      jmbg       = 0;
                string    telefon    = "";
                string    mail       = "";
                Pol       pol        = Pol.Muski;
                Uloga     uloga      = Uloga.Dispecer;
                int       x          = 0;
                int       y          = 0;
                int       brul       = 0;
                int       posta      = 0;
                string    ulica      = "";
                string    grad       = "";
                int       godiste    = 0;
                string    reg        = "";
                TipVozila tip        = TipVozila.Kombi;
                int       taxiBr     = 0;

                using (XmlReader reader = XmlReader.Create(@"D:\fakultet\III godina\WEB\Projekat\WP1718-PR142-2015\WebProjekat\WebProjekat\korisnici.xml"))
                {
                    while (reader.Read())
                    {
                        if (reader.IsStartElement() && reader.Name.Equals("Korisnik"))
                        {
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            ime = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            prezime = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            jmbg = long.Parse(reader.Value);
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            korisnicko = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            lozinka = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            switch (reader.Value)
                            {
                            case "Muski":
                                pol = Pol.Muski;
                                break;

                            case "Zenski":
                                pol = Pol.Zenski;
                                break;
                            }
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            mail = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            telefon = reader.Value;
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            reader.Read();
                            switch (reader.Value)
                            {
                            case "Dispecer":
                                uloga = Uloga.Dispecer;
                                break;

                            case "Vozac":
                                uloga = Uloga.Vozac;
                                break;

                            case "Musterija":
                                uloga = Uloga.Musterija;
                                break;
                            }

                            if (uloga == Uloga.Musterija)
                            {
                                Musterija m = new Musterija(korisnicko, lozinka, ime, prezime, pol, jmbg, telefon, mail, uloga);
                                Registrovani.Musterije.Add(m);
                                Korisnik k = m;
                                Registrovani.SviZajedno.Add(k);
                            }
                            else if (uloga == Uloga.Dispecer)
                            {
                                Dispecer m = new Dispecer(korisnicko, lozinka, ime, prezime, pol, jmbg, telefon, mail, uloga);
                                Registrovani.Dispeceri.Add(m);
                                Korisnik k = m;
                                Registrovani.SviZajedno.Add(k);
                            }
                            else if (uloga == Uloga.Vozac)
                            {
                                Vozac v = new Vozac(korisnicko, lozinka, ime, prezime, pol, jmbg, telefon, mail, uloga);


                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                godiste = int.Parse(reader.Value);
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reg = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                taxiBr = int.Parse(reader.Value);
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                switch (reader.Value)
                                {
                                case "Putnicko":
                                    tip = TipVozila.Putnicko;
                                    break;

                                case "Kombi":
                                    tip = TipVozila.Kombi;
                                    break;
                                }
                                Automobil a = new Automobil(v, godiste, reg, taxiBr, tip);

                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                ulica = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                brul = int.Parse(reader.Value);
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                grad = reader.Value;
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                posta = int.Parse(reader.Value);
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                x = int.Parse(reader.Value);
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                reader.Read();
                                y = int.Parse(reader.Value);
                                Adresa   adresa = new Adresa(ulica, brul, grad, posta);
                                Lokacija l      = new Lokacija(x, y, adresa);

                                v.Automobil = a;
                                v.Lokacija  = l;

                                Registrovani.Vozaci.Add(v);
                                Korisnik k = v;
                                Registrovani.SviZajedno.Add(k);
                            }
                        }
                    }
                }
            }


            string line;

            if (Registrovani.Dispeceri.Count == 0)
            {
                System.IO.StreamReader file = new System.IO.StreamReader(@"D:\fakultet\III godina\WEB\Projekat\WP1718-PR142-2015\WebProjekat\WebProjekat\dispeceri.txt");
                while ((line = file.ReadLine()) != null)
                {
                    Dispecer d     = new Dispecer();
                    string[] words = line.Split(',');

                    d.KorisnickoIme = words[0];
                    d.Lozinka       = words[1];
                    d.Ime           = words[2];
                    d.Prezime       = words[3];

                    if (words[4] == "Muski")
                    {
                        d.Pol = Pol.Muski;
                    }
                    else if (words[4] == "Zenski")
                    {
                        d.Pol = Pol.Zenski;
                    }

                    d.Jmbg       = long.Parse(words[5]);
                    d.BrTelefona = words[6];
                    d.Mail       = words[7];

                    switch (words[8])
                    {
                    case "Dispecer":
                        d.Uloga = Uloga.Dispecer;
                        break;

                    case "Musterija":
                        d.Uloga = Uloga.Musterija;
                        break;

                    case "Vozac":
                        d.Uloga = Uloga.Vozac;
                        break;
                    }

                    Registrovani.Dispeceri.Add(d);
                    Registrovani.SviZajedno.Add(d);
                }

                file.Close();

                string    filename = @"D:\fakultet\III godina\WEB\Projekat\WP1718-PR142-2015\WebProjekat\WebProjekat\korisnici.xml";
                XmlWriter writer   = null;
                try
                {
                    XmlWriterSettings settings = new XmlWriterSettings();
                    settings.Indent             = true;
                    settings.IndentChars        = ("\t");
                    settings.OmitXmlDeclaration = true;

                    writer = XmlWriter.Create(filename, settings);
                    writer.WriteStartElement("Ulogovani");
                    foreach (Korisnik m in Registrovani.SviZajedno)
                    {
                        m.Jmbg.ToString();
                        writer.WriteStartElement("Korisnik");
                        writer.WriteElementString("Ime", m.Ime);
                        writer.WriteElementString("Prezime", m.Prezime);
                        writer.WriteElementString("Jmbg", m.Jmbg.ToString());
                        writer.WriteElementString("KorisnickoIme", m.KorisnickoIme);
                        writer.WriteElementString("Lozinka", m.Lozinka);
                        writer.WriteElementString("Pol", m.Pol.ToString());
                        writer.WriteElementString("E-Mail", m.Mail);
                        writer.WriteElementString("BrojTelefona", m.BrTelefona);
                        writer.WriteElementString("Uloga", m.Uloga.ToString());
                        writer.WriteStartElement("Voznje");
                        int i = 1;
                        foreach (Voznja v in m.Voznja)
                        {
                            writer.WriteStartElement("VoznjaBroj" + i.ToString());
                            writer.WriteElementString("DatumPorudzbine", v.DatumIVremePorudzbine.ToString());
                            writer.WriteElementString("PocetnaLokacija", v.PocetnaLokacija.ToString());
                            writer.WriteElementString("KrajnjaLokacija", v.Odrediste.ToString());
                            writer.WriteElementString("TipVozila", v.Tip.ToString());
                            writer.WriteElementString("MusterijaIme", v.Musterija.Ime);
                            writer.WriteElementString("MusterijaPrezime", v.Musterija.Prezime);
                            writer.WriteElementString("VozacIme", v.Vozac.Ime);
                            writer.WriteElementString("VozacPrezime", v.Vozac.Prezime);
                            writer.WriteElementString("DispecerIme", v.Dispecer.Ime);
                            writer.WriteElementString("DispececrPrezime", v.Dispecer.Prezime);
                            writer.WriteElementString("Iznos", v.Iznos.ToString());
                            writer.WriteEndElement();
                            i++;
                        }
                        writer.WriteEndElement();
                        writer.WriteEndElement();
                    }
                    writer.WriteEndElement();

                    writer.Flush();
                }
                finally
                {
                    if (writer != null)
                    {
                        writer.Close();
                    }
                }
            }
            else
            {
                UcitajVoznje();
            }
        }
コード例 #22
0
        public int Edit([FromBody] EditModel k)
        {
            string ss     = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Musterije.xml");
            string adm    = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Dispeceri.xml");
            string drv    = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Vozaci.xml");
            string voznje = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Voznje.xml");
            string auta   = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/Automobili.xml");

            List <Musterija> users   = xml.ReadUsers(ss);
            List <Dispecer>  admins  = xml.ReadDispecer(adm);
            List <Vozac>     drivers = xml.ReadDrivers(drv);
            List <Voznja>    lv      = xml.ReadDrives(voznje);
            List <Automobil> la      = xml.ReadAuto(auta);

            Vozac     vv = new Vozac();
            Musterija mm = new Musterija();
            Dispecer  dd = new Dispecer();

            bool g = true;
            int  q = 3;

            if (k.OldUsername != k.Username)
            {
                foreach (Musterija u in users)
                {
                    if (u.KorisnickoIme == k.Username)
                    {
                        g = false;
                    }
                }

                foreach (Dispecer ad in admins)
                {
                    if (ad.KorisnickoIme == k.Username)
                    {
                        g = false;
                    }
                }

                foreach (Vozac dr in drivers)
                {
                    if (dr.KorisnickoIme == k.Username)
                    {
                        g = false;
                    }
                }
            }
            if (g)
            {
                foreach (Musterija u in users)
                {
                    if (u.KorisnickoIme == k.OldUsername)
                    {
                        u.KorisnickoIme = k.Username;
                        if (k.Password != null)
                        {
                            u.Lozinka = k.Password;
                        }

                        u.Ime     = k.Ime;
                        u.Prezime = k.Prezime;
                        if (k.Pol == "1")
                        {
                            u.Pol = Enums.PolKorisnika.Zensko;
                        }
                        else
                        {
                            u.Pol = Enums.PolKorisnika.Musko;
                        }
                        u.JMBG           = k.Jmbg;
                        u.KontaktTelefon = k.Telefon;
                        u.Email          = k.Email;

                        // users.ad(user);

                        q  = 0;
                        mm = u;
                        break;
                    }
                }

                foreach (Dispecer u in admins)
                {
                    if (u.KorisnickoIme == k.OldUsername)
                    {
                        u.KorisnickoIme = k.Username;
                        if (k.Password != null)
                        {
                            u.Lozinka = k.Password;
                        }

                        u.Ime     = k.Ime;
                        u.Prezime = k.Prezime;
                        if (k.Pol == "Zensko" || k.Pol == "1")
                        {
                            u.Pol = Enums.PolKorisnika.Zensko;
                        }
                        else
                        {
                            u.Pol = Enums.PolKorisnika.Musko;
                        }
                        u.JMBG           = k.Jmbg;
                        u.KontaktTelefon = k.Telefon;
                        u.Email          = k.Email;


                        q  = 1;
                        dd = u;
                        break;
                    }
                }
                foreach (Vozac u in drivers)
                {
                    if (u.KorisnickoIme == k.OldUsername)
                    {
                        u.KorisnickoIme = k.Username;
                        if (k.Password != null)
                        {
                            u.Lozinka = k.Password;
                        }
                        u.Ime     = k.Ime;
                        u.Prezime = k.Prezime;
                        if (k.Pol == "1")
                        {
                            u.Pol = Enums.PolKorisnika.Zensko;
                        }
                        else
                        {
                            u.Pol = Enums.PolKorisnika.Musko;
                        }
                        u.JMBG           = k.Jmbg;
                        u.KontaktTelefon = k.Telefon;
                        u.Email          = k.Email;

                        u.Auto.UsernameVozaca = k.Username;

                        q  = 2;
                        vv = u;
                        break;
                    }
                }
                if (q == 0)
                {
                    xml.WriteUsers(users, ss);

                    foreach (Voznja v in lv)
                    {
                        if (v.Mus.KorisnickoIme == k.OldUsername)
                        {
                            v.Mus.KorisnickoIme  = mm.KorisnickoIme;
                            v.Mus.Lozinka        = mm.Lozinka;
                            v.Mus.Ime            = mm.Ime;
                            v.Mus.Prezime        = mm.Prezime;
                            v.Mus.Pol            = mm.Pol;
                            v.Mus.Uloga          = mm.Uloga;
                            v.Mus.JMBG           = mm.JMBG;
                            v.Mus.KontaktTelefon = mm.KontaktTelefon;
                            v.Mus.Email          = mm.Email;
                        }
                    }
                }
                if (q == 1)
                {
                    xml.WriteDispecer(admins, adm);
                    // return 2;
                    foreach (Voznja v in lv)
                    {
                        if (v.Disp.KorisnickoIme == k.OldUsername)
                        {
                            v.Disp.KorisnickoIme  = dd.KorisnickoIme;
                            v.Disp.Lozinka        = dd.Lozinka;
                            v.Disp.Ime            = dd.Ime;
                            v.Disp.Prezime        = dd.Prezime;
                            v.Disp.Pol            = dd.Pol;
                            v.Disp.Uloga          = dd.Uloga;
                            v.Disp.JMBG           = dd.JMBG;
                            v.Disp.KontaktTelefon = dd.KontaktTelefon;
                            v.Disp.Email          = dd.Email;
                        }
                    }
                }
                if (q == 2)
                {
                    xml.WriteDrivers(drivers, drv);
                    //return 3;
                    foreach (Voznja v in lv)
                    {
                        if (v.Voz.KorisnickoIme == k.OldUsername)
                        {
                            v.Voz.KorisnickoIme       = vv.KorisnickoIme;
                            v.Voz.Lozinka             = vv.Lozinka;
                            v.Voz.Ime                 = vv.Ime;
                            v.Voz.Prezime             = vv.Prezime;
                            v.Voz.Pol                 = vv.Pol;
                            v.Voz.Uloga               = vv.Uloga;
                            v.Voz.JMBG                = vv.JMBG;
                            v.Voz.KontaktTelefon      = vv.KontaktTelefon;
                            v.Voz.Email               = vv.Email;
                            v.Voz.Auto.UsernameVozaca = vv.KorisnickoIme;
                        }
                    }
                    foreach (Automobil a in la)
                    {
                        if (a.UsernameVozaca == k.OldUsername)
                        {
                            a.UsernameVozaca = vv.KorisnickoIme;
                        }
                    }
                }
                xml.WriteAuta(la, auta);
                xml.WriteDrives(lv, voznje);
                return(q);
            }
            else
            {
                return(q);
            }
        }
コード例 #23
0
        private void SacuvajVoznju(string datum, string pocetna, string krajnja, TipVozila tip, string musterijaI, string musterijaP, string vozacI, string vozacP, string dispecerI, string dispecerP, StatusVoznje status, string komentar, string komentarDatum, Ocena ocena, int iznos)
        {
            DateTime date = ToDate(datum);

            string[] podela = pocetna.Split(',');
            string[] ulica  = podela[0].Split('_');
            string[] grad   = podela[1].Split('_');

            Adresa   adresa = new Adresa(ulica[0], int.Parse(ulica[1]), grad[0], int.Parse(grad[1]));
            Lokacija poc    = new Lokacija(1, 1, adresa);

            podela = krajnja.Split(',');
            ulica  = podela[0].Split('_');
            grad   = podela[1].Split('_');

            Adresa   adresaa = new Adresa(ulica[0], int.Parse(ulica[1]), grad[0], int.Parse(grad[1]));
            Lokacija kraj    = new Lokacija(1, 1, adresaa);

            Musterija musterija = new Musterija();
            Vozac     vozac     = new Vozac();
            Dispecer  dispecer  = new Dispecer();

            if (musterijaI != "nema" && musterijaP != "nema")
            {
                foreach (Musterija m in Registrovani.Musterije)
                {
                    if (musterijaI == m.Ime && musterijaP == m.Prezime)
                    {
                        musterija = m;
                        break;
                    }
                }
            }
            else
            {
                musterija = new Musterija("nema", "nema", "nema", "nema", Pol.Muski, 0000000000, "nema", "nema", Uloga.Musterija);
            }

            if (vozacI != "nema" && vozacP != "nema")
            {
                foreach (Vozac m in Registrovani.Vozaci)
                {
                    if (vozacI == m.Ime && vozacP == m.Prezime)
                    {
                        vozac = m;
                        break;
                    }
                }
            }
            else
            {
                vozac = new Vozac("nema", "nema", "nema", "nema", Pol.Muski, 0000000000, "nema", "nema", Uloga.Vozac);
            }

            if (dispecerI != "nema" && dispecerP != "nema")
            {
                foreach (Dispecer m in Registrovani.Dispeceri)
                {
                    if (dispecerI == m.Ime && dispecerP == m.Prezime)
                    {
                        dispecer = m;
                        break;
                    }
                }
            }
            else
            {
                dispecer = new Dispecer("nema", "nema", "nema", "nema", Pol.Muski, 0000000000, "nema", "nema", Uloga.Dispecer);
            }
            Voznja   v   = new Voznja();
            DateTime kom = ToDate(komentarDatum);
            Komentar k   = new Komentar();

            if (status == StatusVoznje.Otkazana)
            {
                k = new Komentar(komentar, kom, musterija, v, ocena);
            }
            else if (status == StatusVoznje.Neuspesna)
            {
                k = new Komentar(komentar, kom, vozac, v, ocena);
            }
            else if (status == StatusVoznje.Uspesna)
            {
                k = new Komentar(komentar, kom, musterija, v, ocena);
            }
            else
            {
                k = new Komentar("bez opisa", kom, new Korisnik("nema", "nema", "nema", "nema", Pol.Muski, 0000000000, "nema", "nema", Uloga.Dispecer), v, Ocena.neocenjen);
            }

            v = new Voznja(date, poc, tip, musterija, kraj, dispecer, vozac, iznos, k, status);

            k.Voznja   = v;
            v.Komentar = k;

            if (musterijaI != "nema" && musterijaP != "nema")
            {
                foreach (Musterija m in Registrovani.Musterije)
                {
                    if (m.KorisnickoIme == musterija.KorisnickoIme)
                    {
                        m.Voznja.Add(v);
                    }
                }
            }


            if (vozacI != "nema" && vozacP != "nema")
            {
                foreach (Vozac m in Registrovani.Vozaci)
                {
                    if (m.KorisnickoIme == vozac.KorisnickoIme)
                    {
                        m.Voznja.Add(v);
                    }
                }
            }


            if (dispecerI != "nema" && dispecerP != "nema")
            {
                foreach (Dispecer m in Registrovani.Dispeceri)
                {
                    if (m.KorisnickoIme == dispecer.KorisnickoIme)
                    {
                        m.Voznja.Add(v);
                    }
                }
            }

            Voznje.SveVoznje.Add(v);

            foreach (Korisnik kor in Registrovani.SviZajedno)
            {
                if (kor.KorisnickoIme == musterija.KorisnickoIme)
                {
                    kor.Voznja = musterija.Voznja;
                }
                else if (kor.KorisnickoIme == vozac.KorisnickoIme)
                {
                    kor.Voznja = vozac.Voznja;
                }
                else if (kor.KorisnickoIme == dispecer.KorisnickoIme)
                {
                    kor.Voznja = dispecer.Voznja;
                }
            }
        }
コード例 #24
0
        public HttpResponseMessage Filtriraj(string usernameIstatusIflag)
        {
            string[]      splitovano = usernameIstatusIflag.Split('_');
            string        username   = splitovano[0];
            string        status     = splitovano[1];
            int           flag       = Int32.Parse(splitovano[2]);
            List <Voznja> filtrirane = new List <Voznja>();
            Korisnik      k          = ListeKorisnika.Instanca.NadjiKorisnika(username);
            List <Voznja> sveVoznje  = new List <Voznja>();

            if (k.Uloga == Enums.Uloga.Musterija)
            {
                Musterija m = ListeKorisnika.Instanca.Musterije.Find(x => x.Username.Equals(username));
                sveVoznje = m.Voznje;
            }
            else if (k.Uloga == Enums.Uloga.Vozac)
            {
                Vozac v = ListeKorisnika.Instanca.Vozaci.Find(x => x.Username.Equals(username));
                sveVoznje = v.Voznje;
            }
            else
            {
                Dispecer d = ListeKorisnika.Instanca.Dispeceri.Find(x => x.Username.Equals(username));

                if (flag == 0)
                {
                    sveVoznje = d.Voznje;
                }
                else
                {
                    sveVoznje = ListeKorisnika.Instanca.Voznje;
                }
            }

            if (sveVoznje.Count != 0)
            {
                if (status.Equals("Kreirana"))
                {
                    foreach (var item in sveVoznje)
                    {
                        if (item.Status == Enums.StatusVoznje.Kreirana)
                        {
                            filtrirane.Add(item);
                        }
                    }
                }
                else if (status.Equals("Obradjena"))
                {
                    foreach (var item in sveVoznje)
                    {
                        if (item.Status == Enums.StatusVoznje.Obradjena)
                        {
                            filtrirane.Add(item);
                        }
                    }
                }
                else if (status.Equals("Formirana"))
                {
                    foreach (var item in sveVoznje)
                    {
                        if (item.Status == Enums.StatusVoznje.Formirana)
                        {
                            filtrirane.Add(item);
                        }
                    }
                }
                else if (status.Equals("Prihvacena"))
                {
                    foreach (var item in sveVoznje)
                    {
                        if (item.Status == Enums.StatusVoznje.Prihvacena)
                        {
                            filtrirane.Add(item);
                        }
                    }
                }
                else if (status.Equals("Otkazana"))
                {
                    foreach (var item in sveVoznje)
                    {
                        if (item.Status == Enums.StatusVoznje.Otkazana)
                        {
                            filtrirane.Add(item);
                        }
                    }
                }
                else if (status.Equals("Neuspesna"))
                {
                    foreach (var item in sveVoznje)
                    {
                        if (item.Status == Enums.StatusVoznje.Neuspesna)
                        {
                            filtrirane.Add(item);
                        }
                    }
                }
                else if (status.Equals("Uspesna"))
                {
                    foreach (var item in sveVoznje)
                    {
                        if (item.Status == Enums.StatusVoznje.Uspesna)
                        {
                            filtrirane.Add(item);
                        }
                    }
                }
                else
                {
                    filtrirane = sveVoznje;
                }

                if (filtrirane.Count != 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, filtrirane));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest));
                }
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
コード例 #25
0
        public void UpdateMusterija(Musterija musterija)
        {
            IzmeniMusterijuSO so = new IzmeniMusterijuSO();

            so.ExecuteTemplate(musterija);
        }
コード例 #26
0
        public JsonResult Post(string token, string pocetnaLokacijaJSON, string tipAutomobila, int musterijaId = -1, int dispecerId = -1, int vozacId = -1)
        {
            if (Authorize.IsAllowedToAccess(token, TipNaloga.Dispecer | TipNaloga.Musterija))
            {
                if (pocetnaLokacijaJSON == null || pocetnaLokacijaJSON.Trim() == "")
                {
                    return(Json("ERROR_LOCATIONS_ARE_NULL_OR_EMPTY"));
                }

                Lokacija pocetak;
                Lokacija kraj = null;

                try {
                    pocetak = JsonConvert.DeserializeObject <Lokacija>(pocetnaLokacijaJSON);
                } catch {
                    return(Json("ERROR_JSON_STRING_LOCATION_FORMAT_NOT_CORRECT"));
                }

                if (musterijaId > 0 && MainStorage.Instanca.NadjiKorisnikaPoId(musterijaId) == null)
                {
                    return(Json("ERROR_CUSTOMER_ID_NOT_VALID"));
                }

                if (vozacId > 0 && MainStorage.Instanca.NadjiKorisnikaPoId(vozacId) == null)
                {
                    return(Json("ERROR_DRIVER_ID_NOT_VALID"));
                }

                if (dispecerId > 0 && MainStorage.Instanca.NadjiKorisnikaPoId(dispecerId) == null)
                {
                    return(Json("ERROR_DISPATCHER_ID_NOT_VALID"));
                }

                var       statusVoznje = ProjekatWEB.StatusVoznje.Kreirana;
                TipNaloga tipNaloga    = Korisnik.GetTypeFromToken(token);
                if (tipNaloga == TipNaloga.Dispecer)
                {
                    statusVoznje = StatusVoznje.Formirana;
                }

                TipAutomobila tipAuta = TipAutomobila.PutnickiAuto;
                try {
                    tipAuta = Helper.TipAutomobilaFromString(tipAutomobila);
                } catch {
                }

                Vozac tmpVozac = MainStorage.Instanca.Vozaci.FirstOrDefault(x => x.ID == vozacId);
                if (tmpVozac == null && vozacId != -1)
                {
                    return(Json("ERROR_DRIVER_DOES_NOT_EXIST"));
                }

                Musterija tmpMust = MainStorage.Instanca.Musterije.FirstOrDefault(x => x.ID == musterijaId);
                if (tmpMust == null && musterijaId != -1)
                {
                    return(Json("ERROR_CUSTOMER_DOES_NOT_EXIST"));
                }

                Dispecer tmpDisp = MainStorage.Instanca.Dispeceri.FirstOrDefault(x => x.ID == dispecerId);
                if (tmpDisp == null && dispecerId != -1)
                {
                    return(Json("ERROR_DISPATCHER_DOES_NOT_EXIST"));
                }

                Voznja v = new Voznja(postaviDatum: true)
                {
                    KomentarID      = new List <int>(),
                    VozacID         = vozacId,
                    MusterijaID     = musterijaId,
                    DispecerID      = dispecerId,
                    Status          = statusVoznje,
                    PocetnaLokacija = pocetak,
                    Odrediste       = kraj,
                    TipAutomobila   = tipAuta,
                    Iznos           = (kraj != null) ? Helper.IzracunajCenuVoznje(pocetak, kraj) : -1
                };

                MainStorage.Instanca.Voznje.Add(v);

                return(Json("OK_" + v.ID.ToString()));
            }
            else
            {
                return(Helper.ForbidenAccessJson());
            }
        }
コード例 #27
0
        public void SaveMusterija(Musterija musterija)
        {
            ZapamtiMusterijuSO so = new ZapamtiMusterijuSO();

            so.ExecuteTemplate(musterija);
        }
コード例 #28
0
        public JsonResult Post(string username, string password, string ime, string prezime, string pol, string email, string telefon, string jmbg, string tipNaloga_str, string token)
        {
            if (!Validator.StringValidator(username, null, null, false, 4, 20))
            {
                return(Json("ERROR_USERNAME_NOT_CORRECT"));
            }

            if (!Validator.StringValidator(password, null, null, false, 4, 35))
            {
                return(Json("ERROR_PASSWORD_NOT_CORRECT"));
            }

            if (!Validator.StringValidator(ime, null, null, false, 2, 25))
            {
                return(Json("ERROR_IME_NOT_CORRECT"));
            }

            if (!Validator.StringValidator(prezime, null, null, false, 2, 25))
            {
                return(Json("ERROR_PREZIME_NOT_CORRECT"));
            }

            if (!Validator.StringValidator(pol, null, null, false, 1, 1))
            {
                return(Json("ERROR_POL_NOT_CORRECT"));
            }

            if (!Validator.StringValidator(email, new string[] { "@", "." }, null, false, 5, 50))
            {
                return(Json("ERROR_EMAIL_NOT_CORRECT"));
            }

            telefon = telefon.Replace("+", "");
            telefon = telefon.Replace("-", "");
            telefon = telefon.Replace("/", "");
            telefon = telefon.Replace("  ", "");
            telefon = telefon.Replace(" ", "");
            if (!Validator.StringValidator(telefon, null, null, true, 5, 13))
            {
                return(Json("ERROR_PHONE_NOT_CORRECT"));
            }

            if (!Validator.StringValidator(jmbg, null, null, true, 13, 13))
            {
                return(Json("ERROR_JMBG_NOT_CORRECT"));
            }

            if (!Korisnik.UsernameIsFree(username))
            {
                return(Json("ERROR_USERNAME_ALREADY_IN_USE"));
            }

            TipNaloga tipNaloga = Helper.TipNalogaFromString(tipNaloga_str);

            switch (tipNaloga)
            {
            case TipNaloga.Musterija:
                Musterija m = new Musterija()
                {
                    Username = username,
                    Password = password,
                    Ime      = ime,
                    Prezime  = prezime,
                    Email    = email,
                    JMBG     = jmbg,
                    Telefon  = telefon,
                    Pol      = (pol == "M") ? PolOsobe.Musko : PolOsobe.Zensko
                };
                ms.Musterije.Add(m);

                return(Json("OK"));

            case TipNaloga.Dispecer:
                if (Authorize.IsAllowedToAccess(token, TipNaloga.Dispecer))
                {
                    Dispecer d = new Dispecer()
                    {
                        Username = username,
                        Password = password,
                        Ime      = ime,
                        Prezime  = prezime,
                        Email    = email,
                        JMBG     = jmbg,
                        Telefon  = telefon,
                        Pol      = (pol == "M") ? PolOsobe.Musko : PolOsobe.Zensko
                    };
                    ms.Dispeceri.Add(d);
                    return(Json("OK"));
                }
                else
                {
                    return(Json("ERROR_NOT_ALLOWED"));
                }

            case TipNaloga.Vozac:
                if (Authorize.IsAllowedToAccess(token, TipNaloga.Dispecer))
                {
                    Vozac v = new Vozac()
                    {
                        Username = username,
                        Password = password,
                        Ime      = ime,
                        Prezime  = prezime,
                        Email    = email,
                        JMBG     = jmbg,
                        Telefon  = telefon,
                        Pol      = (pol == "M") ? PolOsobe.Musko : PolOsobe.Zensko
                    };
                    ms.Vozaci.Add(v);
                    return(Json("OK"));
                }
                else
                {
                    return(Json("ERROR_NOT_ALLOWED"));
                }

            case TipNaloga.Greska:
                return(Json("ERROR_ACC_TYPE_NOT_VALID"));

            default:
                return(Json("ERROR_ACC_TYPE_NOT_VALID"));
            }
        }
コード例 #29
0
        private void nemateRacun(object sender)
        {
            Musterija = new Musterija();

            navigationService.Navigate(typeof(Registracija), this);
        }