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.LabelPriceLevelCost obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.LabelPriceLevelCost obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.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.LabelPriceLevelCost)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.LabelPriceLevelCost obj = (Indico.DAL.LabelPriceLevelCost)eObj; // set the Indico.BusinessObjects.LabelPriceLevelCostBO properties this.ID = obj.ID; this.IndicoCost = obj.IndicoCost; this.ModifiedDate = obj.ModifiedDate; this.Label = (obj.LabelReference.EntityKey != null && obj.LabelReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.LabelReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.Modifier = (obj.ModifierReference.EntityKey != null && obj.ModifierReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.ModifierReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.PriceLevelCost = (obj.PriceLevelCostReference.EntityKey != null && obj.PriceLevelCostReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.PriceLevelCostReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.PriceTerm = (obj.PriceTermReference.EntityKey != null && obj.PriceTermReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.PriceTermReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }
/// <summary> /// Creates an instance of the LabelPriceLevelCostBO class using the supplied Indico.DAL.LabelPriceLevelCost. /// </summary> /// <param name="obj">a Indico.DAL.LabelPriceLevelCost whose properties will be used to initialise the LabelPriceLevelCostBO</param> internal LabelPriceLevelCostBO(Indico.DAL.LabelPriceLevelCost obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.LabelPriceLevelCost this.ID = obj.ID; this.IndicoCost = obj.IndicoCost; this.Label = (obj.LabelReference.EntityKey != null && obj.LabelReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.LabelReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.ModifiedDate = obj.ModifiedDate; this.Modifier = (obj.ModifierReference.EntityKey != null && obj.ModifierReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.ModifierReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.PriceLevelCost = (obj.PriceLevelCostReference.EntityKey != null && obj.PriceLevelCostReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.PriceLevelCostReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.PriceTerm = (obj.PriceTermReference.EntityKey != null && obj.PriceTermReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.PriceTermReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToLabelPriceLevelCost(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.LabelPriceLevelCost obj = this.SetDAL(objContext.Context); objContext.Context.AddToLabelPriceLevelCost(obj); objContext.SaveChanges(); objContext.Dispose(); } }
void LabelPriceLevelCostsWhereThisIsLabelList_OnBeforeRemove(object sender, EventArgs e) { Indico.DAL.LabelPriceLevelCost obj = null; if (this.Context != null) { if (((IndicoList <Indico.BusinessObjects.LabelPriceLevelCostBO>)sender).Count > 0) { obj = ((IndicoList <Indico.BusinessObjects.LabelPriceLevelCostBO>)sender)[((IndicoList <Indico.BusinessObjects.LabelPriceLevelCostBO>)sender).Count - 1].ObjDAL; this.ObjDAL.LabelPriceLevelCostsWhereThisIsLabel.Remove(obj); } } else { IndicoContext objContext = new IndicoContext(); obj = ((IndicoList <Indico.BusinessObjects.LabelPriceLevelCostBO>)sender)[((IndicoList <Indico.BusinessObjects.LabelPriceLevelCostBO>)sender).Count - 1].SetDAL(objContext.Context); this.ObjDAL.LabelPriceLevelCostsWhereThisIsLabel.Remove(obj); objContext.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.LabelPriceLevelCost SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.LabelPriceLevelCost properties Indico.DAL.LabelPriceLevelCost obj = new Indico.DAL.LabelPriceLevelCost(); if (this.ID > 0) { obj = context.LabelPriceLevelCost.FirstOrDefault <LabelPriceLevelCost>(o => o.ID == this.ID); } obj.IndicoCost = this.IndicoCost; obj.ModifiedDate = this.ModifiedDate; if (this.Label != null && this.Label > 0) { obj.Label = context.PriceMarkupLabel.FirstOrDefault(o => o.ID == this.Label); } if (this.Modifier > 0) { obj.Modifier = context.User.FirstOrDefault(o => o.ID == this.Modifier); } if (this.PriceLevelCost > 0) { obj.PriceLevelCost = context.PriceLevelCost.FirstOrDefault(o => o.ID == this.PriceLevelCost); } if (this.PriceTerm != null && this.PriceTerm > 0) { obj.PriceTerm = context.PriceTerm.FirstOrDefault(o => o.ID == this.PriceTerm); } this._doNotUpdateDALObject = false; return(obj); }