コード例 #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.PriceLevel obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext         objContext = new IndicoContext();
         Indico.DAL.PriceLevel obj        = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
コード例 #2
0
        /// <summary>
        /// Creates an instance of the PriceLevelBO class using the supplied Indico.DAL.PriceLevel.
        /// </summary>
        /// <param name="obj">a Indico.DAL.PriceLevel whose properties will be used to initialise the PriceLevelBO</param>
        internal PriceLevelBO(Indico.DAL.PriceLevel obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

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

            this.Name   = obj.Name;
            this.Volume = obj.Volume;

            this._doNotUpdateDALObject = false;
        }
コード例 #3
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToPriceLevel(this.ObjDAL);
     }
     else
     {
         IndicoContext         objContext = new IndicoContext();
         Indico.DAL.PriceLevel obj        = this.SetDAL(objContext.Context);
         objContext.Context.AddToPriceLevel(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
コード例 #4
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

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

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

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

            this.Name   = obj.Name;
            this.Volume = obj.Volume;


            this._doNotUpdateDALObject = false;
        }
コード例 #5
0
        internal Indico.DAL.PriceLevel SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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

            obj.Name   = this.Name;
            obj.Volume = this.Volume;


            if (_distributorPriceMarkupsWhereThisIsPriceLevelLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.DistributorPriceMarkupBO.ToEntityList(this.DistributorPriceMarkupsWhereThisIsPriceLevel, context),
                    obj.DistributorPriceMarkupsWhereThisIsPriceLevel);
            }
            if (_labelPriceMarkupsWhereThisIsPriceLevelLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.LabelPriceMarkupBO.ToEntityList(this.LabelPriceMarkupsWhereThisIsPriceLevel, context),
                    obj.LabelPriceMarkupsWhereThisIsPriceLevel);
            }
            if (_priceLevelCostsWhereThisIsPriceLevelLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.PriceLevelCostBO.ToEntityList(this.PriceLevelCostsWhereThisIsPriceLevel, context),
                    obj.PriceLevelCostsWhereThisIsPriceLevel);
            }

            this._doNotUpdateDALObject = false;

            return(obj);
        }