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

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

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

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

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

            if (_sizeChartsWhereThisIsMeasurementLocationLoaded)
            {
                BusinessObject.SynchroniseEntityList(
                    Indico.BusinessObjects.SizeChartBO.ToEntityList(this.SizeChartsWhereThisIsMeasurementLocation, context),
                    obj.SizeChartsWhereThisIsMeasurementLocation);
            }

            this._doNotUpdateDALObject = false;

            return(obj);
        }
Ejemplo 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.MeasurementLocation))
            {
                throw new FormatException("Received wrong parameter type...");
            }

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

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

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

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

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

            this.Context = context;

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

            this.IsSend = obj.IsSend;
            this.Item   = (obj.ItemReference.EntityKey != null && obj.ItemReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.ItemReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.Key  = obj.Key;
            this.Name = obj.Name;

            this._doNotUpdateDALObject = false;
        }