Exemplo n.º 1
0
        public ResponseModel Guardar()
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new TextContext())
                {
                    if (this.Id > 0)
                    {
                        ctx.Entry(this).State = EntityState.Modified;
                    }
                    else
                    {
                        ctx.Entry(this).State = EntityState.Added;
                    }
                    rm.SetResponse(true);
                    ctx.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(rm);
        }
Exemplo n.º 2
0
 public void Eliminar()
 {
     try
     {
         using (var ctx = new TextContext())
         {
             ctx.Entry(this).State = EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }
Exemplo n.º 3
0
        public ResponseModel Eliminar()
        {
            var rm = new ResponseModel();

            try
            {
                using (var ctx = new TextContext())
                {
                    ctx.Entry(this).State = EntityState.Deleted;
                    rm.SetResponse(true);
                    ctx.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return(rm);
        }