Exemple #1
0
 public List <T> GetAll <T>() where T : class
 {
     using (var contexto = new LocadoraContext())
     {
         try
         {
             return(contexto.Set <T>().ToList());
         }
         catch (Exception ex)
         {
             string err = ex.Message;
         }
         return(null);
     }
 }
Exemple #2
0
        public T GetRegistroPorCodigo <T>(int idClasse, string idBuscado) where T : class
        {
            if (idBuscado != "")
            {
                using (var contexto = new LocadoraContext())
                {
                    int id = Convert.ToInt32(idBuscado);

                    var retornoId = contexto.Set <T>()
                                    .Where(c => idClasse == id)
                                    .Single();
                    return(retornoId);
                }
            }
            return(null);
        }
Exemple #3
0
        public bool DbAdd <T>(T registro) where T : class
        {
            bool retorno = false;

            using (var contexto = new LocadoraContext())
            {
                try
                {
                    contexto.Set <T>().Add(registro);
                    contexto.SaveChanges();
                    retorno = true;
                }
                catch (Exception ex)
                {
                    string err = ex.Message;
                }
                return(retorno);
            }
        }