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