Beispiel #1
0
 public static bool Save(Produto obj)
 {
     obj.dataCriacao = DateTime.Now;
     obj.dataEdicao  = DateTime.Now;
     try
     {
         if (obj.ID == 0)
         {
             using (var db = new WebPixContext())
             {
                 db.Produto.Add(obj);
                 db.SaveChanges();
             }
             return(true);
         }
         else
         {
             using (var db = new WebPixContext())
             {
                 db.Produto.Update(obj);
                 db.SaveChanges();
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
 public static int Save(Propiedades obj)
 {
     obj.dataCriacao = DateTime.Now;
     obj.dataEdicao  = DateTime.Now;
     try
     {
         if (obj.ID == 0)
         {
             using (var db = new WebPixContext())
             {
                 db.Propiedades.Add(obj);
                 db.SaveChanges();
             }
             return(obj.ID);
         }
         else
         {
             using (var db = new WebPixContext())
             {
                 db.Propiedades.Update(obj);
                 db.SaveChanges();
                 return(obj.ID);
             }
         }
     }
     catch (Exception e)
     {
         return(0);
     }
 }
Beispiel #3
0
 public static bool Save(UsuarioPermissao obj)
 {
     obj.DataCriacao   = DateTime.Now;
     obj.DateAlteracao = DateTime.Now;
     try
     {
         if (obj.ID == 0)
         {
             using (var db = new WebPixContext())
             {
                 db.UsuarioPermissao.Add(obj);
                 db.SaveChanges();
             }
             return(true);
         }
         else
         {
             using (var db = new WebPixContext())
             {
                 db.UsuarioPermissao.Update(obj);
                 db.SaveChanges();
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Beispiel #4
0
 public static bool Remove(Produto obj)
 {
     try
     {
         using (var db = new WebPixContext())
         {
             db.Produto.Remove(obj);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         ////
         return(false);
     }
 }