public async Task Registracija()
        {
            var request = new KupciUpsertRequest()
            {
                Ime               = Ime,
                Prezime           = Prezime,
                Email             = Email,
                Telefon           = Telefon,
                KorisnickoIme     = KorisnickoIme,
                Password          = Password,
                PasswordPotvrda   = PasswordPotvrda,
                DatumRegistracije = DateTime.Now,
                Status            = true
            };

            try
            {
                var item = await _kupciService.Insert <Model.Kupci>(request);

                await Application.Current.MainPage.DisplayAlert("Obavjest", "Uspješno ste se registrovali!", "Uredu");

                Application.Current.MainPage = new LoginPage();
            }
            catch (Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert("Obavjest", ex.Message, "Uredu");
            }
        }
コード例 #2
0
        private async void btnSacuvaj_Click(object sender, EventArgs e)
        {
            if (ValidateChildren() && txtLozinka_Validating() && await txtKorisnickoIme_Validating() && await txtEmail_Validating())
            {
                var request = new KupciUpsertRequest()
                {
                    Ime               = txtIme.Text,
                    Prezime           = txtPrezime.Text,
                    Email             = txtEmail.Text,
                    Telefon           = txtTelefon.Text,
                    KorisnickoIme     = txtKorisnickoIme.Text,
                    Password          = txtLozinka.Text,
                    PasswordPotvrda   = txtPotvrdaLozinke.Text,
                    Status            = cbStatus.Checked,
                    DatumRegistracije = DateTime.Now
                };

                Model.Kupci entity = null;
                if (_id.HasValue)
                {
                    entity = await _kupciService.Update <Model.Kupci>(_id.Value, request);
                }
                else
                {
                    entity = await _kupciService.Insert <Model.Kupci>(request);
                }

                if (entity != null)
                {
                    MessageBox.Show("Uspješno izvršeno");
                }
                this.Close();
            }
        }
コード例 #3
0
        public async Task Uredi()
        {
            var kupac = await _kupciServices.Get <List <Model.Kupci> >(new KupciSearchRequest()
            {
                KorisnickoIme = APIService.Username
            });

            if (kupac.Count != 0)
            {
                if (Lozinka.Equals(APIService.Password))
                {
                    try
                    {
                        KupciUpsertRequest request = new KupciUpsertRequest()
                        {
                            Ime               = Ime,
                            Prezime           = Prezime,
                            Status            = true,
                            DatumRegistracije = DateTime.Now,
                            Email             = Email,
                            KorisnickoIme     = KorisnickoIme,
                            Telefon           = Telefon,
                            Password          = NovaLozinka,
                            PasswordPotvrda   = PotvrdaLozinke
                        };

                        var entity = await _kupciServices.Update <Model.Kupci>(kupac[0].KupacId, request);

                        if (entity != null)
                        {
                            await Application.Current.MainPage.DisplayAlert("Obavjest", "Uspješno ste izmijenili lične podatke!", "Uredu");

                            if (!string.IsNullOrWhiteSpace(request.Password))
                            {
                                APIService.Password = request.Password;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        await Application.Current.MainPage.DisplayAlert("Greška", ex.Message, "Uredu");
                    }
                }
                else
                {
                    await Application.Current.MainPage.DisplayAlert("Greška", "Pogrešna lozinka!", "Uredu");
                }
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Greška", "Prijavite se kao kupac!", "Uredu");

                Application.Current.MainPage = new RentACar.Mobile.Views.LogoutPage();
                return;
            }
        }
コード例 #4
0
        public Model.Kupci Insert(KupciUpsertRequest request)
        {
            var kupac = _mapper.Map <Database.Kupci>(request);

            kupac.LozinkaSalt = Util.Helper.GenerateSalt();
            kupac.LozinkaHash = Util.Helper.GenerateHash(kupac.LozinkaSalt, request.Password);

            _context.Kupci.Add(kupac);
            _context.SaveChanges();

            return(_mapper.Map <Model.Kupci>(kupac));
        }
コード例 #5
0
        public Model.Kupci Insert(KupciUpsertRequest request)
        {
            var entity = _mapper.Map <Database.Kupci>(request);

            if (request.Password != request.PasswordPotvrda)
            {
                throw new Exception("Passwordi se ne slažu");
            }

            entity.LozinkaSalt = GenerateSalt();
            entity.LozinkaHash = GenerateHash(entity.LozinkaSalt, request.Password);

            _context.Kupci.Add(entity);
            _context.SaveChanges();

            return(_mapper.Map <Model.Kupci>(entity));
        }
コード例 #6
0
        public Model.Kupci Update(int id, KupciUpsertRequest request)
        {
            var entity = _context.Kupci.Find(id);

            _context.Kupci.Attach(entity);
            _context.Kupci.Update(entity);

            if (!string.IsNullOrWhiteSpace(request.Password))
            {
                entity.LozinkaSalt = Util.Helper.GenerateSalt();
                entity.LozinkaHash = Util.Helper.GenerateHash(entity.LozinkaSalt, request.Password);
            }

            _mapper.Map(request, entity);
            _context.SaveChanges();

            return(_mapper.Map <Model.Kupci>(entity));
        }
コード例 #7
0
        public Model.Kupci Update(int id, KupciUpsertRequest request)
        {
            var entity = _context.Kupci.Find(id);

            _context.Kupci.Attach(entity);
            _context.Kupci.Update(entity);

            if (!string.IsNullOrWhiteSpace(request.Password))
            {
                if (request.Password != request.PasswordPotvrda)
                {
                    throw new Exception("Passwordi se ne slažu");
                }

                entity.LozinkaSalt = GenerateSalt();
                entity.LozinkaHash = GenerateHash(entity.LozinkaSalt, request.Password);
            }
            _mapper.Map(request, entity);

            _context.SaveChanges();

            return(_mapper.Map <Model.Kupci>(entity));
        }
コード例 #8
0
 public Model.Kupci Update(int id, [FromBody] KupciUpsertRequest request)
 {
     return(_service.Update(id, request));
 }
コード例 #9
0
 public Model.Kupci Insert(KupciUpsertRequest request)
 {
     return(_service.Insert(request));
 }