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

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

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

            obj.Name = this.Name;


            if (_companysWhereThisIsDistributorTypeLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.CompanyBO.ToEntityList(this.CompanysWhereThisIsDistributorType, context),
                    obj.CompanysWhereThisIsDistributorType);
            }

            this._doNotUpdateDALObject = false;

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

            this.Context = context;

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

            this.Name = obj.Name;

            this._doNotUpdateDALObject = false;
        }
示例#4
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToDistributorType(this.ObjDAL);
     }
     else
     {
         IndicoContext objContext       = new IndicoContext();
         Indico.DAL.DistributorType obj = this.SetDAL(objContext.Context);
         objContext.Context.AddToDistributorType(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.DistributorType))
            {
                throw new FormatException("Received wrong parameter type...");
            }

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

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

            this.Name = obj.Name;


            this._doNotUpdateDALObject = false;
        }