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.Page obj = this.SetDAL(this.Context.Context); this.Context.Context.DeleteObject(obj); } } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.Page obj = this.SetDAL(objContext.Context); this.Context.Context.DeleteObject(obj); objContext.Context.SaveChanges(); objContext.Dispose(); } }
internal Indico.DAL.Page SetDAL(IndicoEntities context) { this._doNotUpdateDALObject = true; // set the Indico.DAL.Page properties Indico.DAL.Page obj = new Indico.DAL.Page(); if (this.ID > 0) { obj = context.Page.FirstOrDefault <Page>(o => o.ID == this.ID); } obj.Heading = this.Heading; obj.Name = this.Name; obj.Title = this.Title; if (_menuItemsWhereThisIsPageLoaded) { BusinessObject.SynchroniseEntityList( Indico.BusinessObjects.MenuItemBO.ToEntityList(this.MenuItemsWhereThisIsPage, context), obj.MenuItemsWhereThisIsPage); } this._doNotUpdateDALObject = false; return(obj); }
public void Add() { if (this.Context != null) { this.Context.Context.AddToPage(this.ObjDAL); } else { IndicoContext objContext = new IndicoContext(); Indico.DAL.Page obj = this.SetDAL(objContext.Context); objContext.Context.AddToPage(obj); objContext.SaveChanges(); objContext.Dispose(); } }
/// <summary> /// Creates an instance of the PageBO class using the supplied Indico.DAL.Page. /// </summary> /// <param name="obj">a Indico.DAL.Page whose properties will be used to initialise the PageBO</param> internal PageBO(Indico.DAL.Page obj, ref IndicoContext context) { this._doNotUpdateDALObject = true; this.Context = context; // set the properties from the Indico.DAL.Page this.ID = obj.ID; this.Heading = obj.Heading; this.Name = obj.Name; this.Title = obj.Title; this._doNotUpdateDALObject = false; }
internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj) { this._doNotUpdateDALObject = true; // Check the received type if (eObj.GetType() != typeof(Indico.DAL.Page)) { throw new FormatException("Received wrong parameter type..."); } Indico.DAL.Page obj = (Indico.DAL.Page)eObj; // set the Indico.BusinessObjects.PageBO properties this.ID = obj.ID; this.Heading = obj.Heading; this.Name = obj.Name; this.Title = obj.Title; this._doNotUpdateDALObject = false; }