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