public DBWindowsServer GetWindowsServerSync(Guid id, bool withcreds = false) { var dbReq = TblWindowsServer.Where(s => s.Id == id); if (!withcreds) { // Don't extract credentials from DB ! dbReq = dbReq.Select(s => new DBWindowsServer { Id = s.Id, Name = s.Name, Ip = s.Ip, Port = s.Port, Type = s.Type }); } var server = dbReq.FirstOrDefault().Execute(); if (withcreds) { if (PasswordsKey == null) { throw new ArgumentNullException(nameof(PasswordsKey)); } if (string.IsNullOrWhiteSpace(server.Password)) { throw new MissingMemberException("Password in DB is empry", nameof(server.Password)); } server.Password = encrypt.DecryptSync(server.Password); } return(server); }
public async Task <IEnumerable <DBWindowsServer> > GetWindowsServers() { return(await TblWindowsServer .Where(s => s.Type == ServerType.Windows) // Don't extract credentials from DB ! .Select(server => new DBWindowsServer { Id = server.Id, Name = server.Name, Ip = server.Ip, Port = server.Port, Type = server.Type }) .ExecuteAsync().ConfigureAwait(false)); }
public async Task DeleteServer(Guid server) { await TblWindowsServer.Where(s => s.Id == server).Delete().ExecuteAsync().ConfigureAwait(false); }
public async Task <ServerType> GetServerType(Guid id) { return(await TblWindowsServer.Where(s => s.Id == id).Select(s => s.Type).FirstOrDefault().ExecuteAsync().ConfigureAwait(false)); }