Пример #1
0
 internal int Gravar(Estados e)
 {
     try
     {
         using (academico3Context contexto = new academico3Context())
         {
             contexto.Estados.Add(e);
             return(contexto.SaveChanges());
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Пример #2
0
        //internal List<Questionario> ObterPorUsuario(int id)
        //{
        //    try
        //    {
        //        using (SurveyContext contexto = new SurveyContext())
        //        {
        //            return (from q in contexto.Questionario
        //                    where q.UsuarioId == id
        //                    orderby q.Inicio descending
        //                    select q).ToList();
        //        }
        //    }
        //    catch
        //    {
        //        return null;
        //    }
        //}

        internal int Excluir(int id)
        {
            try
            {
                using (academico3Context contexto = new academico3Context())
                {
                    var estado = contexto.Estados.Where(c => c.Id == id).FirstOrDefault();
                    if (estado != null)
                    {
                        contexto.Estados.Remove(estado);
                        return(contexto.SaveChanges());
                    }
                    else
                    {
                        return(0);
                    }
                }
            }
            catch
            {
                return(-1);
            }
        }