public void SaveRoba(roba roba) { try { var existing = _context.roba.FirstOrDefault(x => x.idbroj == roba.idbroj); if (existing == null) { _context.roba.Add(roba); } else { _context.Entry(existing).CurrentValues.SetValues(roba); } } catch (DbEntityValidationException dbx) { foreach (var er in dbx.EntityValidationErrors) { MessageBox.Show(string.Join(Environment.NewLine, er.ValidationErrors.Select(x => x.PropertyName + ": " + x.ErrorMessage))); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void DeleteRoba(roba roba) { var existing = _context.roba.FirstOrDefault(x => x.idbroj == roba.idbroj); if (existing != null) { _context.roba.Remove(roba); } }
public RobaViewModel(roba k) { _model = k; idbroj = k.idbroj; naziv = k.naziv; jm = k.jm; kol = k.kol; zaliha = k.zaliha; cena = k.cena; Changed = false; }
public RobaViewModel() { _model = new roba(); }