public void Add(Key resource) { try { var _context = LPContextFactory.GetContext(); _context.Keys.Add(resource); _context.SaveChanges(); } catch (Exception e) { throw e; } }
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; } }
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; } }
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; } }
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; } }
public List <Usuario> getAll() { var _context = LPContextFactory.GetContext(); return(_context.Usuarios.ToList()); }