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

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

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

            obj.Key  = this.Key;
            obj.Name = this.Name;


            if (_quotesWhereThisIsStatusLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.QuoteBO.ToEntityList(this.QuotesWhereThisIsStatus, context),
                    obj.QuotesWhereThisIsStatus);
            }

            this._doNotUpdateDALObject = false;

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

            this.Context = context;

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

            this.Key  = obj.Key;
            this.Name = obj.Name;

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

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

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

            this.Key  = obj.Key;
            this.Name = obj.Name;


            this._doNotUpdateDALObject = false;
        }