예제 #1
0
        public void Guardar()
        {
            // var rm = new ResponseModel();

            var alumnos = new TAlumno();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    if (this.id > 0)
                    {
                        ctx.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        ctx.Entry(this).State = EntityState.Added;
                    }
                    //  rm.SetResponse(true);
                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }

            //return rm;
        }
예제 #2
0
 public void Eliminar()
 {
     try
     {
         using (var ctx = new UdemyContext())
         {
             ctx.Entry(this).State = EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     catch (Exception E)
     {
         throw;
     }
 }
예제 #3
0
        public ResponseModel Guardar()
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new UdemyContext())
                {
                    ctx.Entry(this).State = EntityState.Added;

                    rm.SetResponse(true);
                    ctx.SaveChanges();
                }
            }
            catch (Exception E)
            {
                throw;
            }

            return(rm);
        }