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

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

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

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


            if (_patternsWhereThisIsProductionLineLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.PatternBO.ToEntityList(this.PatternsWhereThisIsProductionLine, context),
                    obj.PatternsWhereThisIsProductionLine);
            }
            if (_productionPlanningsWhereThisIsProductionLineLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.ProductionPlanningBO.ToEntityList(this.ProductionPlanningsWhereThisIsProductionLine, context),
                    obj.ProductionPlanningsWhereThisIsProductionLine);
            }

            this._doNotUpdateDALObject = false;

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

            this.Context = context;

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

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

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

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

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

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

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


            this._doNotUpdateDALObject = false;
        }