コード例 #1
0
        public void onDodajServis(object parameter)
        {
            bool error = false;

            S.Validate();

            if (SelektovaniServiser == null)
            {
                ServiserError = "Polje ne moze biti prazno!";
                error         = true;
            }
            else
            {
                ServiserError = "";
            }

            if (SelektovanoVozilo == null)
            {
                VoziloError = "Polje ne moze biti prazno!";
                error       = true;
            }
            else
            {
                VoziloError = "";
            }

            Servis servisIzBaze = unitOfWork.Servisi.Get(S.Id);

            if (servisIzBaze == null)
            {
                IdPostoji = "";
                if (!error && S.IsValid)
                {
                    Servis servis = new Servis();
                    servis.Id           = S.Id;
                    servis.Cena         = S.Cena;
                    servis.Komentar     = S.Komentar;
                    servis.ServiserJmbg = SelektovaniServiser.Jmbg;
                    servis.VoziloId     = SelektovanoVozilo.Id;
                    servis.Datum        = DateTime.Now;

                    unitOfWork.Servisi.Add(servis);

                    if (unitOfWork.Complete() > 0)
                    {
                        Uspesno = "Uspesno ste dodali servis u bazu!";
                        S       = new AppServis();
                    }
                }
            }
            else
            {
                IdPostoji = "Id je zauzet!";
                Uspesno   = "";
            }
        }
コード例 #2
0
        public DodajIzmeniServisViewModel(Servis servis = null)
        {
            vozilaLista = unitOfWork.Vozila.GetAll();
            Vozila      = new BindingList <Vozilo>();

            foreach (var vozilo in vozilaLista)
            {
                Vozila.Add(vozilo);
            }

            serviseriLista = unitOfWork.Serviseri.GetAll();
            Serviseri      = new BindingList <Serviser>();

            foreach (var serviser in serviseriLista)
            {
                Serviseri.Add(serviser);
            }

            if (servis == null)
            {
                TextBoxEnabled           = true;
                TitleContent             = "Dodaj servis";
                ButtonContent            = "Dodaj";
                DodajIzmeniServisCommand = new MyICommand(onDodajServis);
            }

            else
            {
                TextBoxEnabled = false;
                s                        = new AppServis(servis);
                TitleContent             = "Izmeni servis";
                ButtonContent            = "Izmeni";
                SelektovaniServiser      = unitOfWork.Serviseri.GetServiserByJmbg(servis.ServiserJmbg);
                SelektovanoVozilo        = unitOfWork.Vozila.Get(servis.VoziloId);
                DodajIzmeniServisCommand = new MyICommand(onIzmeniServis);
            }
        }