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

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

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


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


            this._doNotUpdateDALObject = false;

            return(obj);
        }
Esempio n. 3
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

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

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

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


            this.Accessory = (obj.AccessoryReference.EntityKey != null && obj.AccessoryReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.AccessoryReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.Pattern = (obj.PatternReference.EntityKey != null && obj.PatternReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.PatternReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }
Esempio n. 4
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToPatternAccessory(this.ObjDAL);
     }
     else
     {
         IndicoContext objContext        = new IndicoContext();
         Indico.DAL.PatternAccessory obj = this.SetDAL(objContext.Context);
         objContext.Context.AddToPatternAccessory(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Creates an instance of the PatternAccessoryBO class using the supplied Indico.DAL.PatternAccessory.
        /// </summary>
        /// <param name="obj">a Indico.DAL.PatternAccessory whose properties will be used to initialise the PatternAccessoryBO</param>
        internal PatternAccessoryBO(Indico.DAL.PatternAccessory obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

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

            this.Accessory = (obj.AccessoryReference.EntityKey != null && obj.AccessoryReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.AccessoryReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.Pattern = (obj.PatternReference.EntityKey != null && obj.PatternReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.PatternReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }