public BaseTable LoadTable(string file) { DatabaseExceptions.ThrowIfTraceNotEnabled(); var name = Path.GetFileNameWithoutExtension(file); foreach (var source in ServerDbs.ListDbs) { if (String.Compare(source.Filename, name, StringComparison.OrdinalIgnoreCase) == 0 || (source.AlternativeName != null && String.Compare(source.AlternativeName, name, StringComparison.OrdinalIgnoreCase) == 0)) { var adb = AllTables.Values.FirstOrDefault(p => p.DbSource == source); if (adb == null) { break; } var newDb = adb.To <int>().Copy(); newDb.DummyInit(this); newDb.LoadDb(); return(newDb.Table); } } return(_loadClientDb(file)); }
public static List <Project> GetProjectsByClientId(int _clientId) { DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { return(db.Table <Project>().Where(p => p.ClientId == _clientId).ToList()); } }
public static List <Task> GetTasks() { DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { return(db.Table <Task>().ToList()); } }
public static List <Client> GetClients() { // Preconditons: database exists DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { return(db.Table <Client>().ToList()); } }
public static List <Project> GetProjects() { // Preconditon: database exists with Project table DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { return(db.Table <Project>().ToList()); } }
public static void AddClient(Client _newClient) { DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { // Precondition: given client ojbect is not null if (_newClient != null) { db.Insert(_newClient); } } }
public static void DeleteProject(Client _client) { DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { //Preconditon: client to delete must exist if (_client.Exists()) { db.Delete(_client); } } }
public static void DeleteProject(Project _project) { DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { // Precondition: project must already exist if (_project.Exists()) { db.Delete(_project); } } }
public static void AddProject(Project _newProject) { DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { // Precondition: new project must not already exist but provided project must if (GetProjectByName(_newProject.Name) == null && _newProject != null) { db.Insert(_newProject); } } }
public static void DeleteTask(Task _task) { DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { // Precondtion given task is not null if (_task != null) { db.Delete(_task); } } }
public static Client GetClientById(int _clientId) { DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { // Preconditon: database exists with Client table and row with provided client name try { return(db.Table <Client>().Where(c => c.Id == _clientId).First()); } catch { return(null); } } }
public static Project GetProjectById(int _projectId) { // Preconditon: database exists with Project table and row containing given project Id DatabaseExceptions.ValidateConnectionString(_databaseFile); using (var db = new SQLiteConnection(_databaseFile, true)) { try { return(db.Table <Project>().Where(p => p.Id == _projectId).First()); } catch { return(null); } } }