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

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

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

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


            if (_itemsWhereThisIsItemTypeLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.ItemBO.ToEntityList(this.ItemsWhereThisIsItemType, context),
                    obj.ItemsWhereThisIsItemType);
            }
            if (_weeklyProductionCapacityDetailssWhereThisIsItemTypeLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.WeeklyProductionCapacityDetailsBO.ToEntityList(this.WeeklyProductionCapacityDetailssWhereThisIsItemType, context),
                    obj.WeeklyProductionCapacityDetailssWhereThisIsItemType);
            }

            this._doNotUpdateDALObject = false;

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

            this.Context = context;

            // set the properties from the Indico.DAL.ItemType
            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.AddToItemType(this.ObjDAL);
     }
     else
     {
         IndicoContext       objContext = new IndicoContext();
         Indico.DAL.ItemType obj        = this.SetDAL(objContext.Context);
         objContext.Context.AddToItemType(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.ItemType))
            {
                throw new FormatException("Received wrong parameter type...");
            }

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

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

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


            this._doNotUpdateDALObject = false;
        }