/// <summary> /// Delete the given DataSource from the database /// </summary> public virtual void Delete(Model.DataSource delDataSource) { try { Trace.WriteInformation("({0})", "Delete", CLASSNAME, delDataSource); //Begin Checks if (!Exists(delDataSource)) { throw new BusinessException(string.Format("There is no DataSource with this id. ({0})", delDataSource)); } DataAccess.DataSources dataSources = new DataAccess.DataSources(); dataSources.Delete(delDataSource); } catch (DalForeignKeyException ex_fk) { Trace.WriteError("({0})", "Delete", CLASSNAME, ex_fk, delDataSource); throw new BusinessException(string.Format("The DataSource is still used by {0}", ex_fk.Table), ex_fk); } catch (Exception ex) { Trace.WriteError("({0})", "Delete", CLASSNAME, ex, delDataSource); throw; } }
/// <summary> /// Equals function to compare class /// </summary> public virtual bool Exists(Int32 id) { try { DataAccess.DataSources dataSources = new DataAccess.DataSources(); return(dataSources.GetById(id) != null); } catch (Exception ex) { Trace.WriteError("{0}", "Exists", CLASSNAME, ex, id); throw; } }
/// <summary> /// Get a DataSource by id from the database /// </summary> public virtual Model.DataSource GetById(Int32 id) { try { DataAccess.DataSources dataSources = new DataAccess.DataSources(); Model.DataSource result = dataSources.GetById(id); return(result); } catch (Exception ex) { Trace.WriteError("{0}", "GetById", CLASSNAME, ex, id); throw; } }
/// <summary> /// Get all DataSource records from the database /// </summary> public virtual List <Model.DataSource> GetAll() { try { DataAccess.DataSources dataSources = new DataAccess.DataSources(); List <Model.DataSource> result = dataSources.GetAll(); return(result); } catch (Exception ex) { Trace.WriteError("()", "GetAll", CLASSNAME, ex); throw; } }
/// <summary> /// Modify only the specified properties of the DataSource /// specified by: /// </summary> /// <param name="id">PK</param> /// <param name="propValues">Properties to change</param> public virtual void Modify(Int32 id, params KeyValuePair <string, object>[] propValues) { try { Trace.WriteInformation("({0}, {1})", "Modify", CLASSNAME, id, string.Join(",", propValues)); DataAccess.DataSources dataSources = new DataAccess.DataSources(); dataSources.Modify( id, propValues); return; } catch (Exception ex) { Trace.WriteError("({0})", "Modify", CLASSNAME, ex, id); throw; } }
/// <summary> /// Add a new DataSource to the database /// </summary> public virtual Int32 Add(Model.DataSource newDataSource) { try { Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, newDataSource); CheckConstraints(newDataSource); DataAccess.DataSources dataSources = new DataAccess.DataSources(); return(dataSources.Add(newDataSource)); } catch (DalForeignKeyException ex_fk) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex_fk, newDataSource); throw new BusinessException(string.Format("No related object found in {0}", ex_fk.Table), ex_fk); } catch (Exception ex) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, newDataSource); throw; } }
/// <summary> /// Modify the given DataSource in the database /// </summary> public virtual void Modify(Model.DataSource modifiedDataSource) { try { Trace.WriteInformation("({0})", "Modify", CLASSNAME, modifiedDataSource); //Begin Checks CheckConstraints(modifiedDataSource); if (!Exists(modifiedDataSource)) { throw new BusinessException(string.Format("There is no DataSource with this id. ({0})", modifiedDataSource)); } DataAccess.DataSources dataSources = new DataAccess.DataSources(); dataSources.Modify(modifiedDataSource); } catch (Exception ex) { Trace.WriteError("({0})", "Modify", CLASSNAME, ex, modifiedDataSource); throw; } }