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

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

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

            obj.Code = this.Code;
            obj.Name = this.Name;


            if (_accessorysWhereThisIsAccessoryCategoryLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.AccessoryBO.ToEntityList(this.AccessorysWhereThisIsAccessoryCategory, context),
                    obj.AccessorysWhereThisIsAccessoryCategory);
            }

            this._doNotUpdateDALObject = false;

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

            this.Context = context;

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

            this.Code = obj.Code;
            this.Name = obj.Name;

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

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

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

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

            this.Code = obj.Code;
            this.Name = obj.Name;


            this._doNotUpdateDALObject = false;
        }