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