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

            this.Context = context;

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

            this.Key   = obj.Key;
            this.Name  = obj.Name;
            this.Value = obj.Value;

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

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

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

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

            this.Key   = obj.Key;
            this.Name  = obj.Name;
            this.Value = obj.Value;


            this._doNotUpdateDALObject = false;
        }
Esempio n. 5
0
        internal Indico.DAL.Settings SetDAL(IndicoEntities context)
        {
            this._doNotUpdateDALObject = true;

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

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

            obj.Key   = this.Key;
            obj.Name  = this.Name;
            obj.Value = this.Value;



            this._doNotUpdateDALObject = false;

            return(obj);
        }