Beispiel #1
0
 public List <ContatoModel> GetAll()
 {
     using (var db = new INCUBADORAEntities())
     {
         return(db.TB_CONTATO.ToList().ConvertAll(ContatoFactory.ToModel));
     }
 }
Beispiel #2
0
        public ContatoModel GetById(int id)
        {
            using (var db = new INCUBADORAEntities())
            {
                var registro = db.TB_CONTATO.Single(x => x.ID == id);

                return(ContatoFactory.ToModel(registro));
            }
        }
Beispiel #3
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 #4
0
 public List <SexoModel> GetAll()
 {
     using (var db = new INCUBADORAEntities())
     {
         return(db.TB_SEXO.ToList().ConvertAll
                (
                    //Data-Mapper
                    registro => new SexoModel
         {
             Id = registro.ID,
             Sexo = registro.DS_SEXO
         }
                ));
     }
 }
Beispiel #5
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();
            }
        }