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

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

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

            obj.Description = this.Description;
            obj.Name        = this.Name;


            if (_productsWhereThisIsColourProfileLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.ProductBO.ToEntityList(this.ProductsWhereThisIsColourProfile, context),
                    obj.ProductsWhereThisIsColourProfile);
            }

            this._doNotUpdateDALObject = false;

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

            this.Context = context;

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

            this.Description = obj.Description;
            this.Name        = obj.Name;

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

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

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

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

            this.Description = obj.Description;
            this.Name        = obj.Name;


            this._doNotUpdateDALObject = false;
        }