private async void potvrdiButton(object obj)
        {
            if (imeTbx.Length < 2 || prezimeTbx.Length < 3)
            {
                Poruka = new MessageDialog("Unesite sve tražene podatke.");
                await Poruka.ShowAsync();

                return;
            }
            if ((staraLozinka.Length != 0 && staraLozinka != korisnik.Lozinka) || (novaLozinka.Length != 0 && staraLozinka != korisnik.Lozinka))
            {
                Poruka = new MessageDialog("Lozinka nije ispravna.");
                await Poruka.ShowAsync();

                return;
            }

            using (var DB = new PlanBDbContext())
            {
                korisnik.Ime           = imeTbx;
                korisnik.Prezime       = prezimeTbx;
                korisnik.Lozinka       = novaLozinka;
                korisnik.DatumRodjenja = datum;
                DB.Korisnici.Update(korisnik);
                DB.SaveChanges();// DB.Korisnici.Where(x => (x.KorisnickoIme == korisnik.KorisnickoIme)).FirstOrDefault());
                Poruka = new MessageDialog("Podaci uspješno izmijenjeni.");
                await Poruka.ShowAsync();
            }
        }
        private async void prikaziPoruke(object parametar)
        {
            using (var DB = new PlanBDbContext())
            {
                IMobileServiceTable <PorukaAzure> porukeAzure = App.MobileService.GetTable <PorukaAzure>();
                int broj = DB.Poruke.Count();
                List <PorukaAzure> listaPoruke = await porukeAzure.Where(x => x.redniBroj > 0).ToListAsync();

                if (broj < listaPoruke.Count)
                {
                    listaPoruke = await porukeAzure.Where(x => x.redniBroj > broj).ToListAsync();

                    foreach (PorukaAzure o in listaPoruke)
                    {
                        using (var DB1 = new PlanBDbContext())
                        {
                            Poruka poruka = new Poruka(o.tekst, o.datumSlanja, o.posiljaocID, o.primaocID, o.dajStatus());
                            poruka.idAzure = o.id;
                            DB1.Poruke.Add(poruka);
                            DB1.SaveChanges();
                        }
                    }
                }
            }
            ProfilPage.frame.Navigate(typeof(PorukaPage));
        }
        public async void dajKolekcije()
        {
            try
            {
                using (var DB = new PlanBDbContext())
                {
                    foreach (MuzickaKolekcija mk in DB.MuzickaKolekcija)
                    {
                        if (mk.Pjesme.Count == 0)
                        {
                        }
                        if (mk.KorisnikID == TrenutniKorisnik.ID)
                        {
                            foreach (Pjesma p in DB.Pjesme)
                            {
                                if (p.kolekcijaAzure == mk.idAzure && !mk.Pjesme.Contains(p))
                                {
                                    mk.Pjesme.Add(p);
                                }
                            }

                            TrenutniKorisnik.MuzickaKolekcija.Add(mk);
                        }
                    }
                }
                Kolekcija = new ObservableCollection <MuzickaKolekcija>(TrenutniKorisnik.MuzickaKolekcija);
            }
            catch (Exception e)
            {
                Poruka = new MessageDialog(e.Message);
                await Poruka.ShowAsync();
            }
        }
 private void povuciFollowDetalje()
 {
     using (var DB = new PlanBDbContext())
     {
         followLista = DB.Follow.Where(x => (x.KorisnikID == TrenutniKorisnik.idAzure)).ToList();
     }
 }
Exemple #5
0
        private async void zavrsiRegistraciju(object parametar)
        {
            using (var DB = new PlanBDbContext())
            {
                if (rVerifikacijskiKod != VerifikacijskiKod)
                {
                    Poruka = new MessageDialog("Uneseni verifikacijski kod nije tačan.");
                    await Poruka.ShowAsync();

                    return;
                }

                KorisnikAzure obj = new KorisnikAzure();
                obj.ime           = rIme;
                obj.prezime       = rPrezime;
                obj.korisnickoIme = rKorisnickoIme;
                obj.lozinka       = rLozinka;
                obj.email         = rEmail;
                obj.datumRodjenja = rDatumRodjenja;
                IMobileServiceTable <KorisnikAzure> azureKorisnik = App.MobileService.GetTable <KorisnikAzure>();
                List <KorisnikAzure> listaKorisnika = await azureKorisnik.Where(x => x.id != "").ToListAsync();

                obj.redniBroj = listaKorisnika.Count + 1;
                await userTableObj.InsertAsync(obj);

                Korisnik korisnik = new Korisnik(0, rIme, rPrezime, rKorisnickoIme, rLozinka, rDatumRodjenja, rEmail);
                korisnik.idAzure = obj.id;
                DB.Korisnici.Add(korisnik);
                DB.SaveChanges();

                Poruka = new MessageDialog("Uspješno kreiran račun.");
                VerifikacijaPanelVisiblity = false;
                await Poruka.ShowAsync();
            }
        }
Exemple #6
0
        private async void registracijaKorisnika(object parametar)
        {
            using (var DB = new PlanBDbContext())
            {
                if (rIme.Length < 3 || rPrezime.Length < 3 || rKorisnickoIme.Length < 3 || rLozinka.Length < 3)
                {
                    Poruka = new MessageDialog("Unesite sve tražene podatke.");
                    await Poruka.ShowAsync();

                    return;
                }

                if (!validirajMail())
                {
                    Poruka = new MessageDialog("Neispravna mail adresa.");
                    await Poruka.ShowAsync();

                    return;
                }
                if (rLozinka != rLozinkaPotvrda)
                {
                    Poruka = new MessageDialog("Lozinke se ne podudaraju.");
                    await Poruka.ShowAsync();

                    return;
                }
                rDatumRodjenja = rDatumRodjenjaOffset.Date;

                PodaciPanelVisibility      = false;
                VerifikacijaPanelVisiblity = true;
                await Send_Email(rEmail);
            }
        }
        private async void zapratiKorisnika(object parametar)
        {
            using (var DB = new PlanBDbContext())
            {
                if (FollowStatus == "Prati")
                {
                    IMobileServiceTable <FollowAzure> userTableObj = App.MobileService.GetTable <FollowAzure>();
                    FollowAzure poruka = new FollowAzure();
                    poruka.korisnikID           = TrenutniKorisnik.idAzure;
                    poruka.following_KorisnikID = OdabraniKorisnik.idAzure;
                    IMobileServiceTable <FollowAzure> azureObaveze = App.MobileService.GetTable <FollowAzure>();
                    List <FollowAzure> listaAzure = await azureObaveze.Where(x => x.korisnikID != "").ToListAsync();

                    poruka.redniBroj = listaAzure.Count + 1;
                    await userTableObj.InsertAsync(poruka);


                    Follow newFollow = new Follow();
                    newFollow.KorisnikID           = TrenutniKorisnik.idAzure;
                    newFollow.Following_KorisnikID = OdabraniKorisnik.idAzure;
                    FollowStatus = "Pratim";
                    DB.Follow.Add(newFollow);
                    DB.SaveChanges();
                    Poruka = new MessageDialog("Korisnik uspješno zapraćen.\nSada možete zajedno planirati i dijeliti vašu omiljenu muziku. :)");
                    await Poruka.ShowAsync();
                }
                else
                {
                    Poruka = new MessageDialog("Korisnik je već zapraćen.");
                    await Poruka.ShowAsync();
                }
            }
        }
        public async void dodajNovuKolekciju(String NazivNoveKolekcije, Pjesma odabranaPjesma)
        {
            using (var DB = new PlanBDbContext())
            {
                MuzickaKolekcija postojecaKolekcija = DB.MuzickaKolekcija.Where(x => (x.Naziv == NazivNoveKolekcije)).FirstOrDefault();
                if (postojecaKolekcija != null)
                {
                    Poruka = new MessageDialog("Postoji kolekcija sa unesenim imenom.");
                    await Poruka.ShowAsync();

                    return;
                }
                if (NazivNoveKolekcije.Length < 4)
                {
                    Poruka = new MessageDialog("Naziv mora imati bar 4 znaka.");
                    await Poruka.ShowAsync();

                    return;
                }

                Pjesma postojecaPjesma = null; // DB.Pjesme.Where(x => (x.kolekcijaAzure == odabranaPjesma.ID)).FirstOrDefault();
                if (postojecaPjesma != null)
                {
                    Poruka = new MessageDialog("Pjesma vec postoji u kolekciji.");
                    await Poruka.ShowAsync();

                    return;
                }

                IMobileServiceTable <KolekcijaAzure> userTableObj = App.MobileService.GetTable <KolekcijaAzure>();
                KolekcijaAzure novaKolekcija1 = new KolekcijaAzure();
                novaKolekcija1.naziv          = NazivNoveKolekcije;
                novaKolekcija1.datumKreiranja = DateTime.Today;
                novaKolekcija1.korisnikID     = TrenutniKorisnik.idAzure;
                List <KolekcijaAzure> listaAzure = await userTableObj.Where(x => x.id != "").ToListAsync();

                novaKolekcija1.redniBroj = listaAzure.Count + 1;
                await userTableObj.InsertAsync(novaKolekcija1);

                odabranaPjesma.kolekcijaAzure = novaKolekcija1.id;

                MuzickaKolekcija novaKolekcija = new MuzickaKolekcija();
                novaKolekcija.Naziv   = NazivNoveKolekcije;
                novaKolekcija.idAzure = TrenutniKorisnik.idAzure;

                // M A I D DODAO
                novaKolekcija.Pjesme.Add(odabranaPjesma);
                novaKolekcija.DatumKreiranja = DateTime.Today;
                TrenutniKorisnik.MuzickaKolekcija.Add(novaKolekcija);
                novaKolekcija.KorisnikID = TrenutniKorisnik.ID;
                DB.Pjesme.Add(odabranaPjesma);
                DB.MuzickaKolekcija.Add(novaKolekcija);
                DB.SaveChanges();
                Kolekcija.Add(novaKolekcija);
                Poruka = new MessageDialog("Pjesma uspješno dodana u kolekciju " + NazivNoveKolekcije + ".");
                await Poruka.ShowAsync();
            }
        }
Exemple #9
0
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     using (var db = new PlanBDbContext())
     {
         db.Database.ApplyMigrations();
     }
 }
 private void povuciFollowingDetalje()
 {
     using (var DB = new PlanBDbContext())
     {
         List <Follow> follow = DB.Follow.Where(x => (x.KorisnikID == OdabraniKorisnik.idAzure)).ToList();
         FollowingNumber = follow.Count();
         follow          = DB.Follow.Where(x => (x.Following_KorisnikID == OdabraniKorisnik.idAzure)).ToList();
         FollowNumber    = follow.Count();
     }
 }
        public void PretraziKorisnike()
        {
            List <Korisnik> korisnici = new List <Korisnik>();

            using (var DB = new PlanBDbContext())
            {
                korisnici = DB.Korisnici.Where(x => (x.Ime.Contains(Pretraga) || x.Prezime.Contains(Pretraga))).ToList();
            }
            RezultatiPretrage = new ObservableCollection <Korisnik>(korisnici);
        }
 private void provjeriFollowStatus()
 {
     using (var DB = new PlanBDbContext())
     {
         Follow followCheck = DB.Follow.Where(x => (x.KorisnikID == TrenutniKorisnik.idAzure && x.Following_KorisnikID == OdabraniKorisnik.idAzure)).FirstOrDefault();
         if (followCheck != null)
         {
             FollowStatus = "Pratim";
         }
         else
         {
             FollowStatus = "Prati";
         }
     }
 }
 private void povuciKolekcije()
 {
     using (var DB = new PlanBDbContext())
     {
         foreach (Follow f in followLista)
         {
             foreach (MuzickaKolekcija mk in DB.MuzickaKolekcija)
             {
                 if (mk.idAzure == f.Following_KorisnikID)
                 {
                     Kolekcije.Add(mk);
                 }
             }
         }
     }
 }
        private async Task pronadjiKorisnika()
        {
            rezultatiPretrage = new ObservableCollection <Korisnik>();
            List <Korisnik> korisnici = new List <Korisnik>();

            using (var DB = new PlanBDbContext())
            {
                korisnici = DB.Korisnici.Where(x => ((x.Ime.ToString() + " " + x.Prezime.ToString()) == Pretraga)).ToList();
            }
            RezultatiPretrage = new ObservableCollection <Korisnik>(korisnici);
            if (rezultatiPretrage.Count == 0)
            {
                //Poruka = new MessageDialog("Ne postoji korisnik sa unesenim podacima.");
                //await Poruka.ShowAsync();
            }
        }
        private async void posaljiPoruku(object parametar)
        {
            if (SadrzajNovePoruke.Length > 0)
            {
                using (var DB = new PlanBDbContext())
                {
                    IMobileServiceTable <PorukaAzure> userTableObj = App.MobileService.GetTable <PorukaAzure>();
                    PorukaAzure poruka = new PorukaAzure();
                    poruka.postaviStatus(StatusPoruke.Neprocitano);
                    poruka.posiljaocID = TrenutniKorisnik.idAzure;
                    poruka.primaocID   = odabranaPoruka.posiljaocAzure;
                    poruka.tekst       = SadrzajNovePoruke;
                    poruka.datumSlanja = DateTime.Today;
                    IMobileServiceTable <PorukaAzure> azureObaveze = App.MobileService.GetTable <PorukaAzure>();
                    List <PorukaAzure> listaAzure = await azureObaveze.Where(x => x.id != "").ToListAsync();

                    poruka.redniBroj = listaAzure.Count + 1;
                    await userTableObj.InsertAsync(poruka);

                    Poruka novaPoruka = new Poruka();
                    novaPoruka.Tekst          = SadrzajNovePoruke;
                    novaPoruka.posiljaocAzure = poruka.posiljaocID;
                    novaPoruka.primaocAzure   = poruka.primaocID;
                    novaPoruka.StatusPoruke   = StatusPoruke.Neprocitano;
                    novaPoruka.DatumSlanja    = DateTime.Today;
                    DB.Poruke.Add(novaPoruka);
                    DB.SaveChanges();


                    Poruka = new MessageDialog("Poruka uspješno poslana.");
                    await Poruka.ShowAsync();

                    UnosPorukeVisibility    = false;
                    PregledPorukeVisibility = true;
                }
            }
            else
            {
                Poruka = new MessageDialog("Ne možete poslati praznu poruku.");
                await Poruka.ShowAsync();

                return;
            }
        }
        public async void dodajUPostojecu(MuzickaKolekcija odabranaKolekcija, Pjesma OdabranaPjesma)
        {
            using (var DB = new PlanBDbContext())
            {
                MuzickaKolekcija muzickaKolekcija = DB.MuzickaKolekcija.Where(x => (x.Naziv == odabranaKolekcija.Naziv && x.KorisnikID == TrenutniKorisnik.ID)).FirstOrDefault();

                foreach (Pjesma p in DB.Pjesme)
                {
                    MuzickaKolekcija muzcikaKolekcija = DB.MuzickaKolekcija.Where(x => (x.idAzure == p.kolekcijaAzure)).FirstOrDefault();
                    if (p.Naziv == OdabranaPjesma.Naziv && odabranaKolekcija.ID == muzcikaKolekcija.ID)
                    {
                        Poruka = new MessageDialog("Pjesma vec postoji u kolekciji.");
                        await Poruka.ShowAsync();

                        return;
                    }
                }

                Pjesma novaPjesma = new Pjesma(OdabranaPjesma.Izvodjac, OdabranaPjesma.Naziv, OdabranaPjesma.Preview, OdabranaPjesma.UrlSlike);
                novaPjesma.kolekcijaAzure = odabranaKolekcija.idAzure;


                IMobileServiceTable <PjesmaAzure> userTableObj = App.MobileService.GetTable <PjesmaAzure>();
                PjesmaAzure pjesmaAzure = new PjesmaAzure();
                pjesmaAzure.naziv              = novaPjesma.Naziv;
                pjesmaAzure.preview            = novaPjesma.Preview;
                pjesmaAzure.urlSlike           = novaPjesma.UrlSlike;
                pjesmaAzure.izvodjac           = novaPjesma.Izvodjac;
                pjesmaAzure.muzickaKolekcijaID = novaPjesma.kolekcijaAzure;
                await userTableObj.InsertAsync(pjesmaAzure);

                List <PjesmaAzure> listaAzure = await userTableObj.Where(x => x.id != "").ToListAsync();

                pjesmaAzure.redniBroj = listaAzure.Count + 1;
                muzickaKolekcija.Pjesme.Add(novaPjesma);
                TrenutniKorisnik.MuzickaKolekcija.Where(x => (x.ID == muzickaKolekcija.ID)).FirstOrDefault().Pjesme.Add(novaPjesma);

                DB.Pjesme.Add(novaPjesma);
                DB.SaveChanges();
                Poruka = new MessageDialog("Pjesma uspješno dodana u kolekciju " + odabranaKolekcija.Naziv + ".");
                await Poruka.ShowAsync();
            }
        }
Exemple #17
0
        public DnevnikViewModel(string id = "")
        {
            this.id       = id;
            korisnik      = LoginViewModel.korisnik;
            lbxDnevnik    = korisnik.Dnevnik;
            DatumText     = "";
            TextDnevnika  = "";
            NaslovTextBox = "";

            stavka              = null;
            PregledVisibility   = true;
            UnosVisibility      = false;
            UnosDnevnikaTextBox = "";
            lbxItems            = new List <StavkaDnevnika>();
            lbxDnevnik          = new List <StavkaDnevnika>();
            vidljivost          = Vidljivost.Nista;

            AddButtonClicked = new RelayCommand <object>(addButtonClicked);
            if (id == "")
            {
                korisnik     = LoginViewModel.korisnik;
                DodajDnevnik = new RelayCommand <object>(dodajDnevnikStavku);
            }
            else
            {
                using (var DB = new PlanBDbContext())
                {
                    korisnik = DB.Korisnici.Where(x => (x.idAzure == id)).FirstOrDefault();
                    //korisnik.Obaveze = DB.Obaveze.Where(x => (x.KreatorID == id)).ToList();
                    foreach (StavkaDnevnika sd in DB.Dnevnik)
                    {
                        if (sd.kreatorAzure == id)
                        {
                            korisnik.Dnevnik.Add(sd);
                        }
                    }
                }
            }
            Dnevnik = new ObservableCollection <StavkaDnevnika>();
            popuniListu();
            //Dnevnik = new ObservableCollection<StavkaDnevnika>(lbxDnevnik);
        }
        private async void povuciPoruke()
        {
            /*using (var DB = new PlanBDbContext())
             * {
             *  IMobileServiceTable<PorukaAzure> porukeAzure = App.MobileService.GetTable<PorukaAzure>();
             *  int broj1 = DB.Poruke.Count();
             *  List<PorukaAzure> listaPoruke = await porukeAzure.Where(x => x.redniBroj > 0).ToListAsync();
             *  if (broj1 < listaPoruke.Count)
             *  {
             *      listaPoruke = await porukeAzure.Where(x => x.redniBroj > broj1).ToListAsync();
             *
             *      foreach (PorukaAzure o in listaPoruke)
             *      {
             *
             *          using (var DB1 = new PlanBDbContext())
             *          {
             *              Poruka poruka = new Poruka(o.tekst, o.datumSlanja, o.posiljaocID, o.primaocID, o.dajStatus());
             *              poruka.idAzure = o.id;
             *              DB1.Poruke.Add(poruka);
             *              DB1.SaveChanges();
             *          }
             *      }
             *  }
             * }*/

            List <Poruka> poruke = new List <Poruka>();
            int           broj   = 0;

            using (var DB = new PlanBDbContext())
            {
                String pomocna = TrenutniKorisnik.idAzure;
                poruke            = DB.Poruke.Where(x => (x.primaocAzure == pomocna)).ToList();
                NeprocitanePoruke = DB.Poruke.Where(x => (x.primaocAzure == TrenutniKorisnik.idAzure && x.StatusPoruke == StatusPoruke.Neprocitano)).ToList();

                broj = DB.Poruke.Count();
            }

            poruke.Sort((x, y) => DateTime.Compare(x.DatumSlanja, y.DatumSlanja));
            Poruke          = new ObservableCollection <Poruka>(poruke);
            BrojNovihPoruka = NeprocitanePoruke.Count;
        }
        private async void spremiButton(object obj)
        {
            using (var DB = new PlanBDbContext())
            {
                if (TextObaveze.Length < 3 || vidljivost == Vidljivost.Nista)
                {
                    Poruka = new MessageDialog("Unesite sve tražene podatke.");
                    await Poruka.ShowAsync();

                    return;
                }

                else
                {
                    // DateTime d = DateTime.ParseExact(DatumText, "dd.mm.yyyy.", System.Globalization.CultureInfo.InvariantCulture);
                    //new DateTime(int.Parse(String.Concat(DatumText[6] + DatumText[7] + DatumText[8] + DatumText[9])), int.Parse(String.Concat(DatumText[3] + DatumText[4])), int.Parse(String.Concat(DatumText[0] + DatumText[1])))

                    ObavezaAzure obavezaAzure = new ObavezaAzure();
                    obavezaAzure.datum     = datum;
                    obavezaAzure.kreatorID = korisnik.idAzure;
                    obavezaAzure.postaviVidljivost(vidljivost);
                    obavezaAzure.sadrzaj   = TextObaveze;
                    obavezaAzure.prioritet = int.Parse(sliderVrijednost);
                    IMobileServiceTable <ObavezaAzure> azureObaveze = App.MobileService.GetTable <ObavezaAzure>();
                    List <ObavezaAzure> listaAzure = await azureObaveze.Where(x => x.id != "").ToListAsync();

                    obavezaAzure.redniBroj = listaAzure.Count + 1;
                    await userTableObj.InsertAsync(obavezaAzure);

                    Obaveza obaveza = new Obaveza(0, datum, TextObaveze, vidljivost, int.Parse(sliderVrijednost), korisnik.idAzure);
                    obaveza.kreatorAzure = korisnik.idAzure; // M A I D DODAO
                    korisnik.Obaveze.Add(obaveza);
                    DB.Obaveze.Add(obaveza);
                    DB.SaveChanges();
                    Poruka = new MessageDialog("Uspješno pohranjena obaveza.");
                    await Poruka.ShowAsync();
                }
            }
        }
 private void povuciStavke()
 {
     using (var DB = new PlanBDbContext())
     {
         foreach (Follow f in followLista)
         {
             foreach (Obaveza o in DB.Obaveze)
             {
                 if (o.kreatorAzure == f.Following_KorisnikID)
                 {
                     Stavke.Add(o);
                 }
             }
             foreach (StavkaDnevnika sd in DB.Dnevnik)
             {
                 if (sd.kreatorAzure == f.Following_KorisnikID)
                 {
                     Stavke.Add(sd);
                 }
             }
         }
     }
 }
Exemple #21
0
        public PregledObavezaViewModel(String id = "")
        {
            //jeLiMojProfil = _jeLiMojProfil;
            this.id            = id;
            DnevnikButtonClick = new RelayCommand <object>(dnevnikButtonClick);
            ObavezaButtonClick = new RelayCommand <object>(obavezaButtonClick);
            OdabranDatum       = new RelayCommand <object>(odabranDatum);

            if (id != "")
            {
                using (var DB = new PlanBDbContext())
                {
                    korisnik = DB.Korisnici.Where(x => (x.idAzure == id)).FirstOrDefault();
                    //korisnik.Obaveze = DB.Obaveze.Where(x => (x.KreatorID == id)).ToList();
                    foreach (Obaveza o in DB.Obaveze)
                    {
                        if (o.kreatorAzure == id)
                        {
                            korisnik.Obaveze.Add(o);
                        }
                    }
                }
            }
            else
            {
                korisnik = LoginViewModel.korisnik;
            }

            lbxItems = new ObservableCollection <Obaveza>();
            datum    = DateTime.Now;
            popuniListu();

            /*for (int i=0; i<korisnik.Obaveze.Count(); i++)
             *  if(korisnik.Obaveze[i].Datum.Date == datum.Date)
             *      lbxItems.Add(korisnik.Obaveze[i]);*/
        }
Exemple #22
0
        private async void loginKorisnika(object parametar)
        {
            using (var DB = new PlanBDbContext())
            {
                korisnik = DB.Korisnici.Where(x => (x.KorisnickoIme == KorisnickoIme && x.Lozinka == Lozinka)).FirstOrDefault();
                if (korisnik == null)
                {
                    Poruka = new MessageDialog("Ne postoji korisnik sa unesenim korisničkim imenom i lozinkom.");
                    await Poruka.ShowAsync();
                }

                else
                {
                    korisnik.Obaveze = new List <Obaveza>();
                    korisnik.Dnevnik = new List <StavkaDnevnika>();

                    foreach (Obaveza o in DB.Obaveze)
                    {
                        if (o.kreatorAzure == korisnik.idAzure)
                        {
                            korisnik.Obaveze.Add(o);
                        }
                    }

                    foreach (StavkaDnevnika o in DB.Dnevnik)
                    {
                        if (o.kreatorAzure == korisnik.idAzure)
                        {
                            korisnik.Dnevnik.Add(o);
                        }
                    }

                    ((Frame)Window.Current.Content).Navigate(typeof(ProfilPage));
                }
            }
        }
Exemple #23
0
        private async void addButtonClicked(object obj)
        {
            using (var DB = new PlanBDbContext())
            {
                if (UnosDnevnikaTextBox.Length < 3)
                {
                    Poruka = new MessageDialog("Unesite tekst.");
                    await Poruka.ShowAsync();

                    return;
                }

                if (NaslovTextBox.Length < 3)
                {
                    Poruka = new MessageDialog("Unesite naslov.");
                    await Poruka.ShowAsync();

                    return;
                }

                if (vidljivost == Vidljivost.Nista)
                {
                    Poruka = new MessageDialog("Unesite vidljivost.");
                    await Poruka.ShowAsync();

                    return;
                }

                //new DateTime(int.Parse(String.Concat(DatumText[6] + DatumText[7] + DatumText[8] + DatumText[9])), int.Parse(String.Concat(DatumText[3] + DatumText[4])), int.Parse(String.Concat(DatumText[0] + DatumText[1])))

                StavkaDnevnikAzure stavka = new StavkaDnevnikAzure();
                stavka.datum     = DateTime.Now;
                stavka.kreatorID = korisnik.idAzure;
                stavka.naslov    = NaslovTextBox;
                stavka.sadrzaj   = UnosDnevnikaTextBox;
                stavka.postaviVidljivost(vidljivost);
                IMobileServiceTable <StavkaDnevnikAzure> azureObaveze = App.MobileService.GetTable <StavkaDnevnikAzure>();
                List <StavkaDnevnikAzure> listaAzure = await azureObaveze.Where(x => x.id != "").ToListAsync();

                stavka.redniBroj = listaAzure.Count + 1;
                await userTableObj.InsertAsync(stavka);

                StavkaDnevnika sd = new StavkaDnevnika(0, DateTime.Now, UnosDnevnikaTextBox, vidljivost, NaslovTextBox, korisnik.idAzure);
                sd.kreatorAzure = korisnik.idAzure; // M A I D DODAO
                korisnik.Dnevnik.Add(sd);
                DB.Dnevnik.Add(sd);
                DB.SaveChanges();
                lbxItems.Add(sd);
                Poruka = new MessageDialog("Uspješno pohranjeno.");
                await Poruka.ShowAsync();


                TextDnevnika = sd.ToString();
                String datum = sd.Datum.Date.ToString("dd.mm.yyyy.");
                DatumText           = datum;
                PregledVisibility   = true;
                UnosVisibility      = false;
                javnoChecked        = false;
                privatnoChecked     = false;
                UnosDnevnikaTextBox = "";
                NaslovTextBox       = "";
            }
        }
Exemple #24
0
        async void UcitajPodate()
        {
            using (var DB = new PlanBDbContext())
            {
                IMobileServiceTable <KorisnikAzure> azureKorisnik = App.MobileService.GetTable <KorisnikAzure>();

                int broj1 = DB.Korisnici.Count();
                List <KorisnikAzure> listaKorisnika = await azureKorisnik.Where(x => x.id != "").ToListAsync();

                if (broj1 < listaKorisnika.Count)
                {
                    listaKorisnika = await azureKorisnik.Where(x => x.redniBroj > broj1).ToListAsync();

                    foreach (KorisnikAzure o in listaKorisnika)
                    {
                        using (var DB1 = new PlanBDbContext())
                        {
                            Korisnik kk = new Korisnik(0, o.ime, o.prezime, o.korisnickoIme, o.lozinka, o.datumRodjenja, o.email);
                            kk.idAzure = o.id;
                            DB1.Korisnici.Add(kk);
                            DB1.SaveChanges();
                        }
                    }
                }


                IMobileServiceTable <ObavezaAzure> azureObaveze = App.MobileService.GetTable <ObavezaAzure>();

                int broj = DB.Obaveze.Count();
                List <ObavezaAzure> listaAzure = await azureObaveze.Where(x => x.id != "").ToListAsync();

                if (broj < listaAzure.Count)
                {
                    listaAzure = await azureObaveze.Where(x => x.redniBroj > broj).ToListAsync();

                    foreach (ObavezaAzure o in listaAzure)
                    {
                        using (var DB1 = new PlanBDbContext())
                        {
                            Obaveza obaveza = new Obaveza(0, o.datum, o.sadrzaj, o.dajVidljivost(), o.prioritet, o.kreatorID);
                            DB1.Obaveze.Add(obaveza);
                            DB1.SaveChanges();
                        }
                    }
                }

                IMobileServiceTable <StavkaDnevnikAzure> azureDnevnik = App.MobileService.GetTable <StavkaDnevnikAzure>();

                broj = DB.Dnevnik.Count();
                List <StavkaDnevnikAzure> listaDnevnik = await azureDnevnik.Where(x => x.id != "").ToListAsync();

                if (broj < listaAzure.Count)
                {
                    listaAzure = await azureObaveze.Where(x => x.redniBroj > broj).ToListAsync();

                    foreach (StavkaDnevnikAzure o in listaDnevnik)
                    {
                        using (var DB1 = new PlanBDbContext())
                        {
                            StavkaDnevnika sd = new StavkaDnevnika(0, DateTime.Now, o.sadrzaj, o.dajVidljivost(), o.naslov, o.kreatorID);
                            DB1.Dnevnik.Add(sd);
                            DB1.SaveChanges();
                        }
                    }
                }

                IMobileServiceTable <PorukaAzure> porukeAzure = App.MobileService.GetTable <PorukaAzure>();
                broj = DB.Poruke.Count();
                List <PorukaAzure> listaPoruke = await porukeAzure.Where(x => x.redniBroj > 0).ToListAsync();

                if (broj < listaPoruke.Count)
                {
                    listaPoruke = await porukeAzure.Where(x => x.redniBroj > broj).ToListAsync();

                    foreach (PorukaAzure o in listaPoruke)
                    {
                        using (var DB1 = new PlanBDbContext())
                        {
                            Poruka poruka = new Poruka(o.tekst, o.datumSlanja, o.posiljaocID, o.primaocID, o.dajStatus());
                            poruka.idAzure = o.id;
                            DB1.Poruke.Add(poruka);
                            DB1.SaveChanges();
                        }
                    }
                }

                IMobileServiceTable <FollowAzure> followAzure = App.MobileService.GetTable <FollowAzure>();
                broj = DB.Follow.Count();
                List <FollowAzure> listaFollow = await followAzure.Where(x => x.redniBroj > 0).ToListAsync();

                if (broj < listaFollow.Count)
                {
                    listaFollow = await followAzure.Where(x => x.redniBroj > broj).ToListAsync();

                    foreach (FollowAzure o in listaFollow)
                    {
                        using (var DB1 = new PlanBDbContext())
                        {
                            Follow poruka = new Follow();
                            poruka.KorisnikID           = o.korisnikID;
                            poruka.Following_KorisnikID = o.following_KorisnikID;
                            DB1.Follow.Add(poruka);
                            DB1.SaveChanges();
                        }
                    }
                }
            }
        }