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

            this.Context = context;

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

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

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

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

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

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


            this._doNotUpdateDALObject = false;
        }
예제 #5
0
        internal Indico.DAL.ClientType SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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

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



            this._doNotUpdateDALObject = false;

            return(obj);
        }