Example #1
0
 public static UsuarioXPerfil SaveUsuarioXPerfil(UsuarioXPerfil obj)
 {
     obj.DataCriacao = DateTime.Now;
     obj.DataEdicao  = DateTime.Now;
     try
     {
         if (obj.Id == 0)
         {
             using (var db = new WebPixContext())
             {
                 db.UsuarioXPerfil.Add(obj);
                 db.SaveChanges();
             }
             return(obj);
         }
         else
         {
             using (var db = new WebPixContext())
             {
                 db.UsuarioXPerfil.Update(obj);
                 db.SaveChanges();
                 return(obj);
             }
         }
     }
     catch (Exception e)
     {
         return(new UsuarioXPerfil());
     }
 }
Example #2
0
 public static bool Save(Perfil obj)
 {
     obj.DataCriacao   = DateTime.Now;
     obj.DateAlteracao = DateTime.Now;
     try
     {
         if (obj.ID == 0)
         {
             using (var db = new WebPixContext())
             {
                 db.Perfil.Add(obj);
                 db.SaveChanges();
             }
             return(true);
         }
         else
         {
             using (var db = new WebPixContext())
             {
                 db.Perfil.Update(obj);
                 db.SaveChanges();
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Example #3
0
 public static Usuario Save(Usuario obj)
 {
     obj.DataCriacao   = DateTime.Now;
     obj.DateAlteracao = DateTime.Now;
     try
     {
         if (obj.ID == 0)
         {
             using (var db = new WebPixContext())
             {
                 db.Usuario.Add(obj);
                 db.SaveChanges();
                 return(obj);
             }
         }
         else
         {
             obj.DateAlteracao = DateTime.Now;
             using (var db = new WebPixContext())
             {
                 db.Usuario.Update(obj);
                 db.SaveChanges();
                 return(obj);
             }
         }
     }
     catch (Exception e)
     {
         return(new Usuario());
     }
 }
Example #4
0
 public static bool Remove(Perfil obj)
 {
     try
     {
         using (var db = new WebPixContext())
         {
             db.Perfil.Remove(obj);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         ////
         return(false);
     }
 }