public void Delete() { if (this.Context != null) { if (this.ObjDAL != null && this.ObjDAL.EntityKey != null) { if (this.ObjDAL.EntityState == System.Data.EntityState.Detached) { this.Context.Context.Attach(this.ObjDAL); this.Context.Context.DeleteObject(this.ObjDAL); } else { this.Context.Context.DeleteObject(this.ObjDAL); } } else { Indico.DAL.PatternSupportFabric obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PatternSupportFabric obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.PatternSupportFabric SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.PatternSupportFabric properties Indico.DAL.PatternSupportFabric obj = new Indico.DAL.PatternSupportFabric(); if (this.ID > 0) { obj = context.PatternSupportFabric.FirstOrDefault <PatternSupportFabric>(o => o.ID == this.ID); } obj.FabConstant = this.FabConstant; if (this.CostSheet > 0) { obj.CostSheet = context.CostSheet.FirstOrDefault(o => o.ID == this.CostSheet); } if (this.Fabric > 0) { obj.Fabric = context.FabricCode.FirstOrDefault(o => o.ID == this.Fabric); } this._doNotUpdateDALObject = false; return(obj); }
internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj) { this._doNotUpdateDALObject = true; // Check the received type if (eObj.GetType() != typeof(Indico.DAL.PatternSupportFabric)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.PatternSupportFabric obj = (Indico.DAL.PatternSupportFabric)eObj; // set the Indico.BusinessObjects.PatternSupportFabricBO properties this.ID = obj.ID; this.FabConstant = obj.FabConstant; this.CostSheet = (obj.CostSheetReference.EntityKey != null && obj.CostSheetReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.CostSheetReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Fabric = (obj.FabricReference.EntityKey != null && obj.FabricReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.FabricReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToPatternSupportFabric(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PatternSupportFabric obj = this.SetDAL(objContext.Context); objContext.Context.AddToPatternSupportFabric(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the PatternSupportFabricBO class using the supplied Indico.DAL.PatternSupportFabric. /// </summary> /// <param name="obj">a Indico.DAL.PatternSupportFabric whose properties will be used to initialise the PatternSupportFabricBO</param> internal PatternSupportFabricBO(Indico.DAL.PatternSupportFabric obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.PatternSupportFabric this.ID = obj.ID; this.CostSheet = (obj.CostSheetReference.EntityKey != null && obj.CostSheetReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.CostSheetReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.FabConstant = obj.FabConstant; this.Fabric = (obj.FabricReference.EntityKey != null && obj.FabricReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.FabricReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }