private void btnSnimi_Click_1(object sender, EventArgs e) { if (ValidateChildren()) { var request = new KlijentiInsertRequest { Email = txtEmail.Text, Ime = txtIme.Text, KorisnickoIme = txtKorisnickoIme.Text, Password = txtPassword.Text, PasswordPotvrda = txtPotvrda.Text, Prezime = txtPrezime.Text, Telefon = txtTelefon.Text }; if (!_id.HasValue) { _service.Insert <Model.Models.Klijenti>(request); MessageBox.Show("Uspješno dodan klijent"); } else { _service.Update <Model.Models.Klijenti>(_id.Value, request); MessageBox.Show("Uspješno izmjenjeni podaci o klijentu"); } } }
public void Insert(KlijentiInsertRequest request) { Model.Database.Klijenti entity = _mapper.Map <Model.Database.Klijenti>(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.Klijenti.Add(entity); _context.SaveChanges(); _context.SaveChanges(); }
public async Task Registracija() { KlijentiInsertRequest request = new KlijentiInsertRequest(); request.DatumRegistracije = DateTime.Now; request.Email = Email; request.Ime = Ime; request.Prezime = Prezime; request.KorisnickoIme = KorisnickoIme; request.Telefon = Telefon; request.Password = Password; request.PasswordPotvrda = Potvrda; await _service.Insert <Model.Models.Klijenti>(request); await Application.Current.MainPage.Navigation.PopAsync(); await Application.Current.MainPage.DisplayAlert("Uspjeh", "Uspjesno ste se registrovali", "OK"); }
public void Update(int id, KlijentiInsertRequest request) { var entity = _context.Klijenti.Find(id); _context.Klijenti.Attach(entity); _context.Klijenti.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(); }
public void Update(int id, [FromBody] KlijentiInsertRequest request) { _service.Update(id, request); }
public void Insert(KlijentiInsertRequest request) { _service.Insert(request); }