コード例 #1
0
        public async Task Registracija()
        {
            GledaociUpsertRequest request = new GledaociUpsertRequest()
            {
                Ime           = Ime,
                Prezime       = Prezime,
                Email         = Email,
                KorisnickoIme = KorisnickoIme,
                DatumRodjenja = DatumRodjenja,
                Sifra         = Sifra,
                SifraPotvrda  = SifraPotvrda,
                Telefon       = Telefon,
                Status        = true
            };

            try
            {
                var result = await _registracija.Insert <Model.Gledaoci>(request);

                Application.Current.MainPage = new LoginPage();
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Niste unijeli ispravne podatke.", "OK");
            }
        }
コード例 #2
0
        public async Task Sacuvaj()
        {
            GledaociSearchRequest request1 = new GledaociSearchRequest()
            {
                Username = APIService.Username
            };
            var gledaoci = await _gledaoci.Get <List <Model.Gledaoci> >(request1);

            GledaociUpsertRequest request2 = new GledaociUpsertRequest()
            {
                Ime           = Ime,
                Prezime       = Prezime,
                DatumRodjenja = DatumRodjenja,
                Email         = Email,
                KorisnickoIme = KorisnickoIme,
                Telefon       = Telefon,
                StaraSifra    = StaraSifra,
                Sifra         = Sifra,
                SifraPotvrda  = SifraPotvrda,
                Status        = true,
                Mobilna       = true
            };

            try {
                var result = await _gledaoci.Update <Model.Gledaoci>(gledaoci[0].GledalacId, request2);

                APIService.Username = request2.KorisnickoIme;
                APIService.Password = request2.Sifra;
                await Application.Current.MainPage.DisplayAlert("Uređivanje podataka", "Uspješno promijenjeno.", "OK");
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Uređivanje podataka", "Niste unijeli ispravne podatke.", "OK");
            }
        }
コード例 #3
0
        private async void btnSacuvaj_Click(object sender, EventArgs e)
        {
            if (ValidateChildren() && txtLozinka_Validating() && await txtKorisnickoIme_Validating() && await txtEmail_Validating())
            {
                GledaociUpsertRequest request = new GledaociUpsertRequest()
                {
                    Ime           = txtIme.Text,
                    Prezime       = txtPrezime.Text,
                    Email         = txtEmail.Text,
                    KorisnickoIme = txtKorIme.Text,
                    Telefon       = txtTelefon.Text,
                    Sifra         = txtSifra.Text,
                    SifraPotvrda  = txtSifraPotvrda.Text,
                    Status        = chbStatus.Checked,
                    DatumRodjenja = dtpRodjenje.Value,
                };
                if (Id == null)
                {
                    try
                    {
                        var result = await _gledaoci.Insert <Model.Gledaoci>(request);

                        if (result != null)
                        {
                            MessageBox.Show(Properties.Resources.UspjesnoDodano);
                        }
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
                else
                {
                    try
                    {
                        var result = await _gledaoci.Update <Model.Gledaoci>(Id, request);

                        if (result != null)
                        {
                            MessageBox.Show(Properties.Resources.UspjesnoPromijenjeno);
                        }
                    }
                    catch (Exception err)
                    {
                        MessageBox.Show(err.Message);
                    }
                }
            }
        }
コード例 #4
0
        public Model.Gledaoci Insert(GledaociUpsertRequest request)
        {
            if (request.Sifra != request.SifraPotvrda)
            {
                throw new Exception("Šifre se ne slažu.");
            }
            var obj = _mapper.Map <Database.Gledaoci>(request);

            obj.LozinkaSalt = GenerateSalt();
            obj.LozinkaHash = GenerateHash(obj.LozinkaSalt, request.Sifra);
            _context.Gledaoci.Add(obj);
            _context.SaveChanges();

            _context.SaveChanges();
            return(_mapper.Map <Model.Gledaoci>(obj));
        }
コード例 #5
0
 public Model.Gledaoci Insert(GledaociUpsertRequest request)
 {
     return(_service.Insert(request));
 }