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