Exemplo n.º 1
0
        public async Task ButtonInit()
        {
            Putnici p = await GetPutnik();

            Autobus a = await GetAutobus(id);

            if (_selectedOcjena == null || _komentar == null)
            {
                await Application.Current.MainPage.DisplayAlert(" ", "Molimo unesite ocjenu i komentar!", "OK");
            }
            else
            {
                OcjenaInsertRequest o = new OcjenaInsertRequest()
                {
                    AutobusId = id,
                    PutnikId  = p.PutnikId,
                    Ocjena1   = _selectedOcjena.ocjena,
                    Komentar  = _komentar
                };

                await _Ocjena.Insert <Ocjena>(o);

                await Application.Current.MainPage.DisplayAlert(" ", "Uspješno ste unjeli komentar!", "OK");

                Application.Current.MainPage = new eBus.Mobile.View.MainPage();
            }
        }
Exemplo n.º 2
0
        public async Task Init()
        {
            var lista = await _notifikacijeService.Get <List <Notifikacije> >(null);

            Putnici putnik = await GetPutnik();

            var searchPN = new PutnikNotifikacijeSearchRequest()
            {
                PutnikId = putnik.PutnikId
            };

            var listaPN = await _putnikNotifikacijeService.Get <List <PutnikNotifikacije> >(searchPN);

            NotifikacijeList.Clear();

            foreach (var item in lista)
            {
                foreach (var item2 in listaPN)
                {
                    if (item.NotifikacijeId == item2.NotifikacijeId && !item2.Pregledana)
                    {
                        NotifikacijeList.Add(item);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public async Task InitPreporuka()
        {
            Putnici p = await GetPutnik();

            SistemPreporukeRequest searchS = new SistemPreporukeRequest()
            {
                PutnikId = p.PutnikId
            };
            var preporuka = await _preporuka.Get <SistemPreporuke>(searchS);

            if (VrstaKarteList.Count == 0)
            {
                var listVrsteKarti = await _vKarte.Get <List <VrstaKarte> >(null);

                foreach (var x in listVrsteKarti)
                {
                    VrstaKarteList.Add(x);
                }
            }

            if (SelectedVrstaKarte == null || SelectedVrstaKarte.VrstaKarteId == 1)
            {
                RedVoznjeList.Clear();
                foreach (var item in preporuka.listaPreporuka)
                {
                    if (item.DatumVrijemePolaska > DateTime.Now)
                    {
                        RedVoznjeList.Add(item);
                    }
                }
            }
            else if (SelectedVrstaKarte.VrstaKarteId == 2)
            {
                popust = (decimal?)0.15;

                RedVoznjeList.Clear();
                foreach (var item in preporuka.listaPreporuka)
                {
                    item.Cijena = item.Cijena - (item.Cijena * popust);
                    if (item.DatumVrijemePolaska > DateTime.Now)
                    {
                        RedVoznjeList.Add(item);
                    }
                }
            }
            else if (SelectedVrstaKarte.VrstaKarteId == 3)
            {
                popust = (decimal?)0.10;
                RedVoznjeList.Clear();
                foreach (var item in preporuka.listaPreporuka)
                {
                    item.Cijena = item.Cijena - (item.Cijena * popust);
                    if (item.DatumVrijemePolaska > DateTime.Now)
                    {
                        RedVoznjeList.Add(item);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public async Task Init()
        {
            Putnici p = await GetPutnik();

            RezervacijaSearchRequest searchRez = new RezervacijaSearchRequest()
            {
                PutnikId = p.PutnikId
            };
            var list = await _Rezervacija.Get <List <RezervacijaKarte> >(searchRez);

            Rezervacije.Clear();
            foreach (var item in list)
            {
                Rezervacije.Add(item);
            }
        }
Exemplo n.º 5
0
        public async Task ButtonInit(int id)
        {
            Putnici p = await GetPutnik();


            KartaInsertRequest kInsert = new KartaInsertRequest()
            {
                DatumIzdavanja        = DateTime.Now,
                RezervacijaSjedistaId = 1,
                BrojKarte             = getBrojKarte()
            };

            if (SelectedVrstaKarte == null)
            {
                kInsert.VrstaKarteId = 1;
            }
            else
            {
                kInsert.VrstaKarteId = SelectedVrstaKarte.VrstaKarteId;
            }

            await _Karta.Insert <Karta>(kInsert);

            KartaSearchRequest searchKarta = new KartaSearchRequest()
            {
                BrojKarte = kInsert.BrojKarte
            };

            Karta kGet = await GetKarta(searchKarta);

            RezervacijaInsertRequest rezInsert = new RezervacijaInsertRequest()
            {
                DatumKreiranja = DateTime.Now,
                DatumIsteka    = DateTime.Now.AddDays(7),
                Otkazana       = false,
                Qrcode         = getBrojKarte(),
                PutnikId       = p.PutnikId,
                KartaId        = kGet.KartaId,
                RedVoznjeId    = id
            };

            await _Rezervacija.Insert <RezervacijaKarte>(rezInsert);

            await Application.Current.MainPage.DisplayAlert(" ", "Uspješno ste rezervisali vašu kartu!", "OK");
        }
Exemplo n.º 6
0
        public async Task <Putnici> GetPutnik()
        {
            PutnikSearchRequest searchP = new PutnikSearchRequest()
            {
                userName = APIService.Username
            };
            List <Putnici> p = await _putnikService.Get <List <eBus.Model.Putnici> >(searchP);

            Putnici putn = new Putnici();

            foreach (var item in p)
            {
                if (item.KorisnickoIme == APIService.Username)
                {
                    putn = item;
                }
            }
            return(putn);
        }
Exemplo n.º 7
0
        public async Task Pregled(int novostId)
        {
            var notif = await _notifikacijeService.Get <List <Notifikacije> >(new NotifikacijeSearchRequest()
            {
                NovostId = novostId
            });

            var listaPutnika = await _putnikService.Get <List <Putnici> >(new PutnikSearchRequest()
            {
                userName = APIService.Username
            });

            Putnici putnik = listaPutnika.FirstOrDefault(l => l.KorisnickoIme == APIService.Username);


            var search = new PutnikNotifikacijeSearchRequest()
            {
                PutnikId       = putnik.PutnikId,
                NotifikacijaId = notif[0].NotifikacijeId
            };

            var lista = await _notifikacijePutnikService.Get <List <PutnikNotifikacije> >(search);

            var request = new PutnikNotifikacijeUpsertRequest();

            request.NotifikacijaId = notif[0].NotifikacijeId;
            request.Pregledana     = true;
            request.PutnikId       = putnik.PutnikId;

            // ukoliko je lista prazna tj nema trazenog elementa znaci da putnik nije notificiran
            // pa mu pregled dodajemo preko novosti
            if (lista.Count != 0)
            {
                if (lista[0].Pregledana == false)
                {
                    await _notifikacijePutnikService.Update <PutnikNotifikacije>(lista[0].NotifikacijeId, request);
                }
            }
            else
            {
                await _notifikacijePutnikService.Insert <PutnikNotifikacije>(request);
            }
        }
Exemplo n.º 8
0
        public async Task OznaciProcitano(Notifikacije n)
        {
            try
            {
                var searchPutnik = new PutnikSearchRequest()
                {
                    userName = APIService.Username
                };

                var listaPutnika = await _putnikService.Get <List <Putnici> >(searchPutnik);

                Putnici putnik = null;
                foreach (var item in listaPutnika)
                {
                    if (item.KorisnickoIme == APIService.Username)
                    {
                        putnik = item;
                        break;
                    }
                }

                var searchPN = new PutnikNotifikacijeSearchRequest()
                {
                    PutnikId = putnik.PutnikId
                };

                var listaPN = await _putnikNotifikacijeService.Get <List <PutnikNotifikacije> >(searchPN);

                PutnikNotifikacije pn = null;
                foreach (var item in listaPN)
                {
                    if (item.NotifikacijeId == n.NotifikacijeId && item.PutnikId == putnik.PutnikId)
                    {
                        pn = item;
                        break;
                    }
                }

                if (pn != null)
                {
                    var request = new PutnikNotifikacijeUpsertRequest()
                    {
                        NotifikacijaId = n.NotifikacijeId,
                        PutnikId       = putnik.PutnikId,
                        Pregledana     = true
                    };

                    await _putnikNotifikacijeService.Update <PutnikNotifikacije>(pn.NotifikacijeId, request);

                    if (n != null)
                    {
                        NotifikacijeList.Remove(n);

                        await Application.Current.MainPage.DisplayAlert(" ", "Označili ste notifikaciju pročitanom", "OK");
                    }
                }



                //var updateN = new NotifikacijaUpsertRequest()
                //{
                //    DatumSlanja = n.DatumSlanja,
                //    Naslov = n.Naslov,
                //    NovostId = n.NovostId,
                //    Procitano = true
                //};

                //await _notifikacijeService.Update<Notifikacija>(n.Id, updateN);
            }
            catch (Exception)
            {
                throw;
            }
        }