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.PackingListSizeQty obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PackingListSizeQty obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.PackingListSizeQty SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.PackingListSizeQty properties Indico.DAL.PackingListSizeQty obj = new Indico.DAL.PackingListSizeQty(); if (this.ID > 0) { obj = context.PackingListSizeQty.FirstOrDefault <PackingListSizeQty>(o => o.ID == this.ID); } obj.Qty = this.Qty; if (this.PackingList > 0) { obj.PackingList = context.PackingList.FirstOrDefault(o => o.ID == this.PackingList); } if (this.Size > 0) { obj.Size = context.Size.FirstOrDefault(o => o.ID == this.Size); } 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.PackingListSizeQty)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.PackingListSizeQty obj = (Indico.DAL.PackingListSizeQty)eObj; // set the Indico.BusinessObjects.PackingListSizeQtyBO properties this.ID = obj.ID; this.Qty = obj.Qty; this.PackingList = (obj.PackingListReference.EntityKey != null && obj.PackingListReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.PackingListReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Size = (obj.SizeReference.EntityKey != null && obj.SizeReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.SizeReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToPackingListSizeQty(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PackingListSizeQty obj = this.SetDAL(objContext.Context); objContext.Context.AddToPackingListSizeQty(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the PackingListSizeQtyBO class using the supplied Indico.DAL.PackingListSizeQty. /// </summary> /// <param name="obj">a Indico.DAL.PackingListSizeQty whose properties will be used to initialise the PackingListSizeQtyBO</param> internal PackingListSizeQtyBO(Indico.DAL.PackingListSizeQty obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.PackingListSizeQty this.ID = obj.ID; this.PackingList = (obj.PackingListReference.EntityKey != null && obj.PackingListReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.PackingListReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Qty = obj.Qty; this.Size = (obj.SizeReference.EntityKey != null && obj.SizeReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.SizeReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }