/// <summary>
        /// Delete the given ApplicationSetting from the database
        /// </summary>
        public virtual void Delete(Model.ApplicationSetting delApplicationSetting)
        {
            try
            {
                Trace.WriteInformation("({0})", "Delete", CLASSNAME, delApplicationSetting);

                //Begin Checks
                if (!Exists(delApplicationSetting))
                {
                    throw new BusinessException(string.Format("There is no ApplicationSetting with this id. ({0})", delApplicationSetting));
                }

                DataAccess.ApplicationSettings applicationSettings = new DataAccess.ApplicationSettings();
                applicationSettings.Delete(delApplicationSetting);
            }
            catch (DalForeignKeyException ex_fk)
            {
                Trace.WriteError("({0})", "Delete", CLASSNAME, ex_fk, delApplicationSetting);
                throw new BusinessException(string.Format("The ApplicationSetting is still used by {0}", ex_fk.Table), ex_fk);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", "Delete", CLASSNAME, ex, delApplicationSetting);
                throw;
            }
        }
 /// <summary>
 /// Equals function to compare class
 /// </summary>
 public bool Exists(String applicationSettingName)
 {
     try
     {
         DataAccess.ApplicationSettings applicationSettings = new DataAccess.ApplicationSettings();
         return(applicationSettings.GetAll().Find(x => x.Name.Equals(applicationSettingName, StringComparison.InvariantCultureIgnoreCase)) != null);
     }
     catch (Exception ex)
     {
         Trace.WriteError("{0}", Trace.GetMethodName(), CLASSNAME, ex, applicationSettingName);
         throw;
     }
 }
 /// <summary>
 /// Equals function to compare class
 /// </summary>
 public virtual bool Exists(Int32 applicationSettingId)
 {
     try
     {
         DataAccess.ApplicationSettings applicationSettings = new DataAccess.ApplicationSettings();
         return(applicationSettings.GetById(applicationSettingId) != null);
     }
     catch (Exception ex)
     {
         Trace.WriteError("{0}", "Exists", CLASSNAME, ex, applicationSettingId);
         throw;
     }
 }
 /// <summary>
 /// Get a ApplicationSetting by id from the database
 /// </summary>
 public virtual Model.ApplicationSetting GetById(Int32 applicationSettingId)
 {
     try
     {
         DataAccess.ApplicationSettings applicationSettings = new DataAccess.ApplicationSettings();
         Model.ApplicationSetting       result = applicationSettings.GetById(applicationSettingId);
         return(result);
     }
     catch (Exception ex)
     {
         Trace.WriteError("{0}", "GetById", CLASSNAME, ex, applicationSettingId);
         throw;
     }
 }
        /// <summary>
        /// Get a ApplicationSetting by ListId from the database
        /// </summary>
        public virtual List <Model.ApplicationSetting> GetByListId(Int32 listId)
        {
            try
            {
                DataAccess.ApplicationSettings  applicationSettings = new DataAccess.ApplicationSettings();
                List <Model.ApplicationSetting> result = applicationSettings.GetByListId(listId);

                return(result);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", "GetByListId", CLASSNAME, ex, listId);
                throw;
            }
        }
        /// <summary>
        /// Get all ApplicationSetting records from the database
        /// </summary>
        public virtual List <Model.ApplicationSetting> GetAll()
        {
            try
            {
                DataAccess.ApplicationSettings  applicationSettings = new DataAccess.ApplicationSettings();
                List <Model.ApplicationSetting> result = applicationSettings.GetAll();

                return(result);
            }
            catch (Exception ex)
            {
                Trace.WriteError("()", "GetAll", CLASSNAME, ex);
                throw;
            }
        }
        /// <summary>
        /// Modify only the specified properties of the ApplicationSetting
        /// specified by:
        /// </summary>
        /// <param name="applicationSettingId">PK</param>
        /// <param name="propValues">Properties to change</param>
        public virtual void Modify(Int32 applicationSettingId, params KeyValuePair <string, object>[] propValues)
        {
            try
            {
                Trace.WriteInformation("({0}, {1})", "Modify", CLASSNAME, applicationSettingId, string.Join(",", propValues));

                DataAccess.ApplicationSettings applicationSettings = new DataAccess.ApplicationSettings();
                applicationSettings.Modify(
                    applicationSettingId,
                    propValues);
                return;
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", "Modify", CLASSNAME, ex, applicationSettingId);
                throw;
            }
        }
        /// <summary>
        /// Add a new ApplicationSetting to the database
        /// </summary>
        public virtual void Add(Model.ApplicationSetting newApplicationSetting)
        {
            try
            {
                Trace.WriteInformation("({0})", Trace.GetMethodName(), CLASSNAME, newApplicationSetting);

                CheckConstraints(newApplicationSetting);
                DataAccess.ApplicationSettings applicationSettings = new DataAccess.ApplicationSettings();

                applicationSettings.Add(newApplicationSetting);
            }
            catch (DalForeignKeyException ex_fk)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex_fk, newApplicationSetting);
                throw new BusinessException(string.Format("No related object found in {0}", ex_fk.Table), ex_fk);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", Trace.GetMethodName(), CLASSNAME, ex, newApplicationSetting);
                throw;
            }
        }
        /// <summary>
        /// Modify the given ApplicationSetting in the database
        /// </summary>
        public virtual void Modify(Model.ApplicationSetting modifiedApplicationSetting)
        {
            try
            {
                Trace.WriteInformation("({0})", "Modify", CLASSNAME, modifiedApplicationSetting);

                //Begin Checks
                CheckConstraints(modifiedApplicationSetting);

                if (!Exists(modifiedApplicationSetting))
                {
                    throw new BusinessException(string.Format("There is no ApplicationSetting with this id. ({0})", modifiedApplicationSetting));
                }

                DataAccess.ApplicationSettings applicationSettings = new DataAccess.ApplicationSettings();
                applicationSettings.Modify(modifiedApplicationSetting);
            }
            catch (Exception ex)
            {
                Trace.WriteError("({0})", "Modify", CLASSNAME, ex, modifiedApplicationSetting);
                throw;
            }
        }