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