/// <summary> /// Delete the given MaterialParameter from the database /// </summary> public virtual void Delete(Model.MaterialParameter delMaterialParameter) { try { Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, delMaterialParameter); //Begin Checks if (!Exists(delMaterialParameter)) { throw new BusinessException(string.Format("There is no MaterialParameter with this id. ({0})", delMaterialParameter)); } DataAccess.MaterialParameters materialParameters = new DataAccess.MaterialParameters(); materialParameters.Delete(delMaterialParameter); } catch (DalForeignKeyException ex_fk) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex_fk, delMaterialParameter); throw new BusinessException(string.Format("The MaterialParameter is still used by {0}", ex_fk.Table), ex_fk); } catch (Exception ex) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, delMaterialParameter); throw; } }
/// <summary> /// Equals function to compare class /// </summary> public virtual bool Exists(Int32 id) { try { DataAccess.MaterialParameters materialParameters = new DataAccess.MaterialParameters(); return(materialParameters.GetById(id) != null); } catch (Exception ex) { Trace.WriteError("{0}", Trace.GetMethodName(), CLASSNAME, ex, id); throw; } }
/// <summary> /// Get a MaterialParameter by id from the database /// </summary> public virtual Model.MaterialParameter GetById(Int32 id) { try { DataAccess.MaterialParameters materialParameters = new DataAccess.MaterialParameters(); Model.MaterialParameter result = materialParameters.GetById(id); return(result); } catch (Exception ex) { Trace.WriteError("{0}", Trace.GetMethodName(), CLASSNAME, ex, id); throw; } }
/// <summary> /// Get a MaterialParameter by MaterialGroupId from the database /// </summary> public virtual List <Model.MaterialParameter> GetByMaterialGroupId(Int32 materialGroupId) { try { DataAccess.MaterialParameters materialParameters = new DataAccess.MaterialParameters(); List <Model.MaterialParameter> result = materialParameters.GetByMaterialGroupId(materialGroupId); return(result); } catch (Exception ex) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, materialGroupId); throw; } }
/// <summary> /// Modify only the specified properties of the MaterialParameter /// 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})", Trace.GetMethodName(), CLASSNAME, id, string.Join(",", propValues)); DataAccess.MaterialParameters materialParameters = new DataAccess.MaterialParameters(); materialParameters.Modify( id, propValues); return; } catch (Exception ex) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, id); throw; } }
/// <summary> /// Add a new MaterialParameter to the database /// </summary> public virtual Int32 Add(Model.MaterialParameter newMaterialParameter) { try { Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, newMaterialParameter); CheckConstraints(newMaterialParameter); DataAccess.MaterialParameters materialParameters = new DataAccess.MaterialParameters(); return(materialParameters.Add(newMaterialParameter)); } catch (DalForeignKeyException ex_fk) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex_fk, newMaterialParameter); 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, newMaterialParameter); throw; } }
/// <summary> /// Modify the given MaterialParameter in the database /// </summary> public virtual void Modify(Model.MaterialParameter modifiedMaterialParameter) { try { Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, modifiedMaterialParameter); //Begin Checks CheckConstraints(modifiedMaterialParameter); if (!Exists(modifiedMaterialParameter)) { throw new BusinessException(string.Format("There is no MaterialParameter with this id. ({0})", modifiedMaterialParameter)); } DataAccess.MaterialParameters materialParameters = new DataAccess.MaterialParameters(); materialParameters.Modify(modifiedMaterialParameter); } catch (Exception ex) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, modifiedMaterialParameter); throw; } }