Exemplo 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.SizeChart obj = this.SetDAL(this.Context.Context);
             this.Context.Context.DeleteObject(obj);
         }
     }
     else
     {
         IndicoContext        objContext = new IndicoContext();
         Indico.DAL.SizeChart obj        = this.SetDAL(objContext.Context);
         this.Context.Context.DeleteObject(obj);
         objContext.Context.SaveChanges();
         objContext.Dispose();
     }
 }
Exemplo n.º 2
0
        internal void SetBO(System.Data.Objects.DataClasses.EntityObject eObj)
        {
            this._doNotUpdateDALObject = true;

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

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

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

            this.Val = obj.Val;

            this.MeasurementLocation = (obj.MeasurementLocationReference.EntityKey != null && obj.MeasurementLocationReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.MeasurementLocationReference.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.Size = (obj.SizeReference.EntityKey != null && obj.SizeReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.SizeReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;

            this._doNotUpdateDALObject = false;
        }
Exemplo n.º 3
0
        internal Indico.DAL.SizeChart SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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

            obj.Val = this.Val;

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


            this._doNotUpdateDALObject = false;

            return(obj);
        }
Exemplo n.º 4
0
 public void Add()
 {
     if (this.Context != null)
     {
         this.Context.Context.AddToSizeChart(this.ObjDAL);
     }
     else
     {
         IndicoContext        objContext = new IndicoContext();
         Indico.DAL.SizeChart obj        = this.SetDAL(objContext.Context);
         objContext.Context.AddToSizeChart(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Exemplo n.º 5
0
 void SizeChartsWhereThisIsMeasurementLocationList_OnBeforeRemove(object sender, EventArgs e)
 {
     Indico.DAL.SizeChart obj = null;
     if (this.Context != null)
     {
         if (((IndicoList <Indico.BusinessObjects.SizeChartBO>)sender).Count > 0)
         {
             obj = ((IndicoList <Indico.BusinessObjects.SizeChartBO>)sender)[((IndicoList <Indico.BusinessObjects.SizeChartBO>)sender).Count - 1].ObjDAL;
             this.ObjDAL.SizeChartsWhereThisIsMeasurementLocation.Remove(obj);
         }
     }
     else
     {
         IndicoContext objContext = new IndicoContext();
         obj = ((IndicoList <Indico.BusinessObjects.SizeChartBO>)sender)[((IndicoList <Indico.BusinessObjects.SizeChartBO>)sender).Count - 1].SetDAL(objContext.Context);
         this.ObjDAL.SizeChartsWhereThisIsMeasurementLocation.Remove(obj);
         objContext.SaveChanges();
         objContext.Dispose();
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Creates an instance of the SizeChartBO class using the supplied Indico.DAL.SizeChart.
        /// </summary>
        /// <param name="obj">a Indico.DAL.SizeChart whose properties will be used to initialise the SizeChartBO</param>
        internal SizeChartBO(Indico.DAL.SizeChart obj, ref IndicoContext context)
        {
            this._doNotUpdateDALObject = true;

            this.Context = context;

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

            this.MeasurementLocation = (obj.MeasurementLocationReference.EntityKey != null && obj.MeasurementLocationReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.MeasurementLocationReference.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.Size = (obj.SizeReference.EntityKey != null && obj.SizeReference.EntityKey.EntityKeyValues.Count() > 0)
                ? (int)((System.Data.EntityKeyMember)obj.SizeReference.EntityKey.EntityKeyValues.GetValue(0)).Value
                : 0;
            this.Val = obj.Val;

            this._doNotUpdateDALObject = false;
        }