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.PriceMarkupLabel obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PriceMarkupLabel obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the PriceMarkupLabelBO class using the supplied Indico.DAL.PriceMarkupLabel. /// </summary> /// <param name="obj">a Indico.DAL.PriceMarkupLabel whose properties will be used to initialise the PriceMarkupLabelBO</param> internal PriceMarkupLabelBO(Indico.DAL.PriceMarkupLabel obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.PriceMarkupLabel this.ID = obj.ID; this.Name = obj.Name; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToPriceMarkupLabel(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.PriceMarkupLabel obj = this.SetDAL(objContext.Context); objContext.Context.AddToPriceMarkupLabel(obj); objContext.SaveChanges(); objContext.Dispose(); } }
internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj) { this._doNotUpdateDALObject = true; // Check the received type if (eObj.GetType() != typeof(Indico.DAL.PriceMarkupLabel)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.PriceMarkupLabel obj = (Indico.DAL.PriceMarkupLabel)eObj; // set the Indico.BusinessObjects.PriceMarkupLabelBO properties this.ID = obj.ID; this.Name = obj.Name; this._doNotUpdateDALObject = false; }
internal Indico.DAL.PriceMarkupLabel SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.PriceMarkupLabel properties Indico.DAL.PriceMarkupLabel obj = new Indico.DAL.PriceMarkupLabel(); if (this.ID > 0) { obj = context.PriceMarkupLabel.FirstOrDefault <PriceMarkupLabel>(o => o.ID == this.ID); } obj.Name = this.Name; if (_labelPriceLevelCostsWhereThisIsLabelLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.LabelPriceLevelCostBO.ToEntityList(this.LabelPriceLevelCostsWhereThisIsLabel, context), obj.LabelPriceLevelCostsWhereThisIsLabel); } if (_labelPriceListDownloadssWhereThisIsLabelLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.LabelPriceListDownloadsBO.ToEntityList(this.LabelPriceListDownloadssWhereThisIsLabel, context), obj.LabelPriceListDownloadssWhereThisIsLabel); } if (_labelPriceMarkupsWhereThisIsLabelLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.LabelPriceMarkupBO.ToEntityList(this.LabelPriceMarkupsWhereThisIsLabel, context), obj.LabelPriceMarkupsWhereThisIsLabel); } this._doNotUpdateDALObject = false; return(obj); }