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.PriceRemarks obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PriceRemarks obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.PriceRemarks SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.PriceRemarks properties Indico.DAL.PriceRemarks obj = new Indico.DAL.PriceRemarks(); if (this.ID > 0) { obj = context.PriceRemarks.FirstOrDefault <PriceRemarks>(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.PriceRemarks)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.PriceRemarks obj = (Indico.DAL.PriceRemarks)eObj; // set the Indico.BusinessObjects.PriceRemarksBO 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.AddToPriceRemarks(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PriceRemarks obj = this.SetDAL(objContext.Context); objContext.Context.AddToPriceRemarks(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the PriceRemarksBO class using the supplied Indico.DAL.PriceRemarks. /// </summary> /// <param name="obj">a Indico.DAL.PriceRemarks whose properties will be used to initialise the PriceRemarksBO</param> internal PriceRemarksBO(Indico.DAL.PriceRemarks obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.PriceRemarks 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; }