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

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

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

            obj.Extension  = this.Extension;
            obj.Filename   = this.Filename;
            obj.ImageOrder = this.ImageOrder;
            obj.IsHero     = this.IsHero;
            obj.Size       = this.Size;

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


            this._doNotUpdateDALObject = false;

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

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

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

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

            this.Extension  = obj.Extension;
            this.Filename   = obj.Filename;
            this.ImageOrder = obj.ImageOrder;
            this.IsHero     = obj.IsHero;
            this.Size       = obj.Size;

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

            this.Context = context;

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

            this.Extension  = obj.Extension;
            this.Filename   = obj.Filename;
            this.ImageOrder = obj.ImageOrder;
            this.IsHero     = obj.IsHero;
            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.Size;

            this._doNotUpdateDALObject = false;
        }