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.DefaultValuesPriceList obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.DefaultValuesPriceList obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.DefaultValuesPriceList SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.DefaultValuesPriceList properties Indico.DAL.DefaultValuesPriceList obj = new Indico.DAL.DefaultValuesPriceList(); if (this.ID > 0) { obj = context.DefaultValuesPriceList.FirstOrDefault <DefaultValuesPriceList>(o => o.ID == this.ID); } obj.CreatedDate = this.CreatedDate; obj.CreativeDesign = this.CreativeDesign; obj.ModifiedDate = this.ModifiedDate; obj.Position1 = this.Position1; obj.Position2 = this.Position2; obj.Position3 = this.Position3; obj.StudioDesign = this.StudioDesign; obj.ThirdPartyDesign = this.ThirdPartyDesign; if (this.Creator > 0) { obj.Creator = context.User.FirstOrDefault(o => o.ID == this.Creator); } if (this.Modifier > 0) { obj.Modifier = context.User.FirstOrDefault(o => o.ID == this.Modifier); } 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.DefaultValuesPriceList)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.DefaultValuesPriceList obj = (Indico.DAL.DefaultValuesPriceList)eObj; // set the Indico.BusinessObjects.DefaultValuesPriceListBO properties this.ID = obj.ID; this.CreatedDate = obj.CreatedDate; this.CreativeDesign = obj.CreativeDesign; this.ModifiedDate = obj.ModifiedDate; this.Position1 = obj.Position1; this.Position2 = obj.Position2; this.Position3 = obj.Position3; this.StudioDesign = obj.StudioDesign; this.ThirdPartyDesign = obj.ThirdPartyDesign; this.Creator = (obj.CreatorReference.EntityKey != null && obj.CreatorReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.CreatorReference.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._doNotUpdateDALObject = false; }
/// <summary> /// Creates an instance of the DefaultValuesPriceListBO class using the supplied Indico.DAL.DefaultValuesPriceList. /// </summary> /// <param name="obj">a Indico.DAL.DefaultValuesPriceList whose properties will be used to initialise the DefaultValuesPriceListBO</param> internal DefaultValuesPriceListBO(Indico.DAL.DefaultValuesPriceList obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.DefaultValuesPriceList this.ID = obj.ID; this.CreatedDate = obj.CreatedDate; this.CreativeDesign = obj.CreativeDesign; this.Creator = (obj.CreatorReference.EntityKey != null && obj.CreatorReference.EntityKey.EntityKeyValues.Count() > 0) ? (int)((System.Data.EntityKeyMember)obj.CreatorReference.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.Position1 = obj.Position1; this.Position2 = obj.Position2; this.Position3 = obj.Position3; this.StudioDesign = obj.StudioDesign; this.ThirdPartyDesign = obj.ThirdPartyDesign; this._doNotUpdateDALObject = false; }
public void Add() { if (this.Context != null) { this.Context.Context.AddToDefaultValuesPriceList(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.DefaultValuesPriceList obj = this.SetDAL(objContext.Context); objContext.Context.AddToDefaultValuesPriceList(obj); objContext.SaveChanges(); objContext.Dispose(); } }