Beispiel #1
0
 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.PocketType obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext         objContext = new IndicoContext();
         Indico.DAL.PocketType obj        = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
Beispiel #2
0
        internal Indico.DAL.PocketType SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

            // set the Indico.DAL.PocketType properties
            Indico.DAL.PocketType obj = new Indico.DAL.PocketType();

            if (this.ID > 0)
            {
                obj = context.PocketType.FirstOrDefault <PocketType>(o => o.ID == this.ID);
            }

            obj.Key  = this.Key;
            obj.Name = this.Name;


            if (_artWorksWhereThisIsPocketTypeLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.ArtWorkBO.ToEntityList(this.ArtWorksWhereThisIsPocketType, context),
                    obj.ArtWorksWhereThisIsPocketType);
            }
            if (_visualLayoutsWhereThisIsPocketTypeLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.VisualLayoutBO.ToEntityList(this.VisualLayoutsWhereThisIsPocketType, context),
                    obj.VisualLayoutsWhereThisIsPocketType);
            }

            this._doNotUpdateDALObject = false;

            return(obj);
        }
Beispiel #3
0
        /// <summary>
        /// Creates an instance of the PocketTypeBO class using the supplied Indico.DAL.PocketType.
        /// </summary>
        /// <param name="obj">a Indico.DAL.PocketType whose properties will be used to initialise the PocketTypeBO</param>
        internal PocketTypeBO(Indico.DAL.PocketType obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

            // set the properties from the Indico.DAL.PocketType
            this.ID = obj.ID;

            this.Key  = obj.Key;
            this.Name = obj.Name;

            this._doNotUpdateDALObject = false;
        }
Beispiel #4
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToPocketType(this.ObjDAL);
     }
     else
     {
         IndicoContext         objContext = new IndicoContext();
         Indico.DAL.PocketType obj        = this.SetDAL(objContext.Context);
         objContext.Context.AddToPocketType(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Beispiel #5
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

            // Check the received type
            if (eObj.GetType() != typeof(Indico.DAL.PocketType))
            {
                throw new FormatException("Received wrong parameter type...");
            }

            Indico.DAL.PocketType obj = (Indico.DAL.PocketType)eObj;

            // set the Indico.BusinessObjects.PocketTypeBO properties
            this.ID = obj.ID;

            this.Key  = obj.Key;
            this.Name = obj.Name;


            this._doNotUpdateDALObject = false;
        }