/// <summary> /// Delete the given BomItem from the database /// </summary> public virtual void Delete(Model.BomItem delBomItem) { try { Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, delBomItem); //Begin Checks if (!Exists(delBomItem)) { throw new BusinessException(string.Format("There is no BomItem with this id. ({0})", delBomItem)); } DataAccess.BomItems bomItems = new DataAccess.BomItems(); bomItems.Delete(delBomItem); } catch (DalForeignKeyException ex_fk) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex_fk, delBomItem); throw new BusinessException(string.Format("The BomItem is still used by {0}", ex_fk.Table), ex_fk); } catch (Exception ex) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, delBomItem); throw; } }
/// <summary> /// Equals function to compare class /// </summary> public virtual bool Exists(Int32 id) { try { DataAccess.BomItems bomItems = new DataAccess.BomItems(); return(bomItems.GetById(id) != null); } catch (Exception ex) { Trace.WriteError("{0}", Trace.GetMethodName(), CLASSNAME, ex, id); throw; } }
/// <summary> /// Get a BomItem by id from the database /// </summary> public virtual Model.BomItem GetById(Int32 id) { try { DataAccess.BomItems bomItems = new DataAccess.BomItems(); Model.BomItem result = bomItems.GetById(id); return(result); } catch (Exception ex) { Trace.WriteError("{0}", Trace.GetMethodName(), CLASSNAME, ex, id); throw; } }
/// <summary> /// Get a BomItem by MaterialId from the database /// </summary> public virtual List <Model.BomItem> GetByMaterialId(Int32 materialId) { try { DataAccess.BomItems bomItems = new DataAccess.BomItems(); List <Model.BomItem> result = bomItems.GetByMaterialId(materialId); return(result); } catch (Exception ex) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, materialId); throw; } }
/// <summary> /// Get all BomItem records from the database /// </summary> public virtual List <Model.BomItem> GetAll() { try { DataAccess.BomItems bomItems = new DataAccess.BomItems(); List <Model.BomItem> result = bomItems.GetAll(); return(result); } catch (Exception ex) { Trace.WriteError("()", Trace.GetMethodName(), CLASSNAME, ex); throw; } }
/// <summary> /// Modify only the specified properties of the BomItem /// 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.BomItems bomItems = new DataAccess.BomItems(); bomItems.Modify( id, propValues); return; } catch (Exception ex) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, id); throw; } }
/// <summary> /// Add a new BomItem to the database /// </summary> public virtual Int32 Add(Model.BomItem newBomItem) { try { Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, newBomItem); CheckConstraints(newBomItem); DataAccess.BomItems bomItems = new DataAccess.BomItems(); return(bomItems.Add(newBomItem)); } catch (DalForeignKeyException ex_fk) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex_fk, newBomItem); 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, newBomItem); throw; } }
/// <summary> /// Modify the given BomItem in the database /// </summary> public virtual void Modify(Model.BomItem modifiedBomItem) { try { Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, modifiedBomItem); //Begin Checks CheckConstraints(modifiedBomItem); if (!Exists(modifiedBomItem)) { throw new BusinessException(string.Format("There is no BomItem with this id. ({0})", modifiedBomItem)); } DataAccess.BomItems bomItems = new DataAccess.BomItems(); bomItems.Modify(modifiedBomItem); } catch (Exception ex) { Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, modifiedBomItem); throw; } }