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.DistributorPriceLevelCost obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.DistributorPriceLevelCost 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.DistributorPriceLevelCost)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.DistributorPriceLevelCost obj = (Indico.DAL.DistributorPriceLevelCost)eObj; // set the Indico.BusinessObjects.DistributorPriceLevelCostBO properties this.ID = obj.ID; this.IndicoCost = obj.IndicoCost; this.ModifiedDate = obj.ModifiedDate; this.Distributor = (obj.DistributorReference.EntityKey != null && obj.DistributorReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.DistributorReference.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 DistributorPriceLevelCostBO class using the supplied Indico.DAL.DistributorPriceLevelCost. /// </summary> /// <param name="obj">a Indico.DAL.DistributorPriceLevelCost whose properties will be used to initialise the DistributorPriceLevelCostBO</param> internal DistributorPriceLevelCostBO(Indico.DAL.DistributorPriceLevelCost obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.DistributorPriceLevelCost this.ID = obj.ID; this.Distributor = (obj.DistributorReference.EntityKey != null && obj.DistributorReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.DistributorReference.EntityKey.EntityKeyValues.GetValue(0)).Value : 0; this.IndicoCost = obj.IndicoCost; 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.AddToDistributorPriceLevelCost(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.DistributorPriceLevelCost obj = this.SetDAL(objContext.Context); objContext.Context.AddToDistributorPriceLevelCost(obj); objContext.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.DistributorPriceLevelCost SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.DistributorPriceLevelCost properties Indico.DAL.DistributorPriceLevelCost obj = new Indico.DAL.DistributorPriceLevelCost(); if (this.ID > 0) { obj = context.DistributorPriceLevelCost.FirstOrDefault <DistributorPriceLevelCost>(o => o.ID == this.ID); } obj.IndicoCost = this.IndicoCost; obj.ModifiedDate = this.ModifiedDate; if (this.Distributor != null && this.Distributor > 0) { obj.Distributor = context.Company.FirstOrDefault(o => o.ID == this.Distributor); } 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); }