Example #1
0
        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);
            }
        }
Example #2
0
        public void DeleteRoba(roba roba)
        {
            var existing = _context.roba.FirstOrDefault(x => x.idbroj == roba.idbroj);

            if (existing != null)
            {
                _context.roba.Remove(roba);
            }
        }
Example #3
0
        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;
        }
Example #4
0
 public RobaViewModel()
 {
     _model = new roba();
 }