Example #1
0
        public void Eliminar(int id)
        {
            try
            {
                using (var ctx = new TextContext())
                {
                    ctx.Entry(new Registro {
                        id = id
                    }).State = EntityState.Deleted;

                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
 public void Guardar(Registro reg)
 {
     try
     {
         using (var ctx = new TextContext())
         {
             if (reg.id > 0)
             {
                 ctx.Entry(reg).State = EntityState.Modified;
             }
             else
             {
                 ctx.Entry(reg).State = EntityState.Added;
             }
             ctx.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }