Beispiel #1
0
        public bool Delete(int id)
        {
            using (var db = new INCUBADORAEntities())
            {
                var registro = db.TB_CONTATO.Single(x => x.ID == id);

                db.TB_CONTATO.Remove(registro);

                var qtde = db.SaveChanges();

                return(qtde > 0);
            }
        }
Beispiel #2
0
        public void Save(ContatoModel contato)
        {
            using (var db = new INCUBADORAEntities())
            {
                if (contato.Id == 0)
                {
                    db.TB_CONTATO.Add(ContatoFactory.ToEntity(contato));
                }
                else
                {
                    var registro = db.TB_CONTATO.Single(x => x.ID == contato.Id);

                    ContatoFactory.ToEntity(contato, registro);
                }

                db.SaveChanges();
            }
        }