Ejemplo n.º 1
0
 public void Add(Key resource)
 {
     try
     {
         var _context = LPContextFactory.GetContext();
         _context.Keys.Add(resource);
         _context.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 2
0
 public Salt getSaltByKeyId(long keyId)
 {
     try
     {
         var  _context = LPContextFactory.GetContext();
         Salt salt     = _context.Salts.Where(s => s.KeyId == keyId).FirstOrDefault();
         if (salt != null)
         {
             return(salt);
         }
         else
         {
             throw new Exception("Salt não encontrada");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 3
0
 public Usuario getUsuarioByName(string nome)
 {
     try
     {
         var     _context = LPContextFactory.GetContext();
         Usuario usuario  = _context.Usuarios.Where(u => u.Nome == nome).FirstOrDefault();
         if (usuario != null)
         {
             return(usuario);
         }
         else
         {
             throw new Exception("Usuario não localizado");
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 4
0
        public Key getKeyByUsuario(long usuarioId)
        {
            try
            {
                var _context = LPContextFactory.GetContext();

                Key key = _context.Keys.Where(k => k.UsuarioId == usuarioId).FirstOrDefault();
                if (key != null)
                {
                    return(key);
                }
                else
                {
                    throw new Exception("Key não encontrada");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 5
0
        public Usuario get(long Id)
        {
            try
            {
                var _context = LPContextFactory.GetContext();

                Usuario usuario = _context.Usuarios.Where(u => u.Id == Id).FirstOrDefault();
                if (usuario != null)
                {
                    return(usuario);
                }
                else
                {
                    throw new Exception("Usuario não localizado");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 6
0
        public List <Usuario> getAll()
        {
            var _context = LPContextFactory.GetContext();

            return(_context.Usuarios.ToList());
        }