Пример #1
0
 public DnevnikKKViewModel()
 {
     korisnik          = LoginViewModel.korisnik;
     lbxDnevnik        = korisnik.Dnevnik;
     DatumText         = "";
     TextDnevnika      = "";
     DodajDnevnik      = new RelayCommand <object>(dodajDnevnikStavku);
     stavka            = null;
     PregledVisibility = Visibility.Visible;
     UnosVisibility    = Visibility.Collapsed;
     unos    = Visibility.Collapsed;
     pregled = Visibility.Visible;
 }
Пример #2
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);
        }
Пример #3
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       = "";
            }
        }
Пример #4
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();
                        }
                    }
                }
            }
        }