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