private async void Button_Clicked(object sender, EventArgs e) { if (!Regex.IsMatch(this.Naziv.Text, @"^[a-zA-Z]+$")) { await DisplayAlert("Greška", "Naziv se sastoji samo od slova", "OK"); } else { try { GradInsertRequest req = new GradInsertRequest() { Naziv = this.Naziv.Text, }; await _apiServiceGrad.Update <dynamic>(GradVM.Grad.GradID, req); await DisplayAlert("OK", "Uspješno uneseni podaci", "OK"); // await Navigation.PushAsync(new GradPage()); } catch (Exception err) { throw new Exception(err.Message); } } }
private async void btnSacuvaj_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { var grad = new GradInsertRequest() { Naziv = txtNaziv.Text }; Model.Grad entity = null; if (_id.HasValue) { entity = await _apiservice.Update <Model.Grad>(_id.Value, grad); } else { try { entity = await _apiservice.Insert <Model.Grad>(grad); } catch (Exception) { MessageBox.Show("Niste autorizovani"); } } if (entity != null) { MessageBox.Show("Uspješno izvršeno"); this.Close(); } } }
public Model.Grad Update(int id, GradInsertRequest update) { var entity = _context.Grad.Find(id); _mapper.Map(update, entity); _context.SaveChanges(); return(_mapper.Map <Model.Grad>(entity)); }
public Model.Grad Insert(GradInsertRequest insert) { var entity = _mapper.Map <Database.Grad>(insert); _context.Grad.Add(entity); _context.SaveChanges(); return(_mapper.Map <Model.Grad>(entity)); }
private async void btnSnimi_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { var request = new GradInsertRequest() { Naziv = txtNaziv.Text }; if (_id.HasValue) { await _apiService.Update <Model.Grad>(_id.Value, request); } else { await _apiService.Insert <Model.Grad>(request); } MessageBox.Show("Uspješno sačuvani podaci"); this.Close(); } }
private async void btnSnimi_Click(object sender, EventArgs e) { var grad = new GradInsertRequest(); var idObj = cmbDrzave.SelectedValue; if (int.TryParse(idObj.ToString(), out int id)) { grad.DrzavaId = id; } grad.NazivGrada = txtNaziv.Text; grad.PostanskiBroj = int.Parse(txtPostanskiBroj.Text); if (_id.HasValue) { await _service.Update <Model.Grad>(_id, grad); MessageBox.Show("Uspjesno ste uredili podatke grada "); } else { await _service.Insert <Model.Grad>(grad); MessageBox.Show($"Uspjesno ste dodali grad {grad.NazivGrada}"); } }
public Model.Grad Update(int id, GradInsertRequest request) { return(_service.Update(id, request)); }
public Model.Grad Insert(GradInsertRequest request) { return(_service.Insert(request)); }