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