Exemple #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.QuoteChangeEmailList obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext objContext            = new IndicoContext();
         Indico.DAL.QuoteChangeEmailList obj = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
Exemple #2
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToQuoteChangeEmailList(this.ObjDAL);
     }
     else
     {
         IndicoContext objContext            = new IndicoContext();
         Indico.DAL.QuoteChangeEmailList obj = this.SetDAL(objContext.Context);
         objContext.Context.AddToQuoteChangeEmailList(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Exemple #3
0
        /// <summary>
        /// Creates an instance of the QuoteChangeEmailListBO class using the supplied Indico.DAL.QuoteChangeEmailList.
        /// </summary>
        /// <param name="obj">a Indico.DAL.QuoteChangeEmailList whose properties will be used to initialise the QuoteChangeEmailListBO</param>
        internal QuoteChangeEmailListBO(Indico.DAL.QuoteChangeEmailList obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

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

            this.IsCC = obj.IsCC;
            this.User = (obj.UserReference.EntityKey != null && obj.UserReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.UserReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }
Exemple #4
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

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

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

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

            this.IsCC = obj.IsCC;

            this.User = (obj.UserReference.EntityKey != null && obj.UserReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.UserReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

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

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

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

            obj.IsCC = this.IsCC;

            if (this.User != null && this.User > 0)
            {
                obj.User = context.User.FirstOrDefault(o => o.ID == this.User);
            }


            this._doNotUpdateDALObject = false;

            return(obj);
        }