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