/// <summary>
 /// Deprecated Method for adding a new object to the Settings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSettings(Setting setting)
 {
     base.AddObject("Settings", setting);
 }
 /// <summary>
 /// Create a new Setting object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="gallery">Initial value of the Gallery property.</param>
 /// <param name="votingEnabled">Initial value of the VotingEnabled property.</param>
 /// <param name="uploadEnabled">Initial value of the UploadEnabled property.</param>
 /// <param name="statsEnabled">Initial value of the StatsEnabled property.</param>
 public static Setting CreateSetting(global::System.Int32 id, global::System.String gallery, global::System.Boolean votingEnabled, global::System.Boolean uploadEnabled, global::System.Boolean statsEnabled)
 {
     Setting setting = new Setting();
     setting.Id = id;
     setting.Gallery = gallery;
     setting.VotingEnabled = votingEnabled;
     setting.UploadEnabled = uploadEnabled;
     setting.StatsEnabled = statsEnabled;
     return setting;
 }
示例#3
0
        public void SaveGallerySettings(Setting setting, IPrincipal user)
        {
            if (!IsAdminUser(user))
             {
            throw new SecurityException("Not authorized.");
             }

             if (setting.EntityState == EntityState.Unchanged)
             {
            return;
             }

             var context = new DatabaseEntities();

             try
             {
            if (setting.EntityState == EntityState.Modified)
            {
               var current = (from settings in context.Settings where settings.Id == setting.Id select settings).SingleOrDefault();
               if (current != null)
               {
                  context.Settings.ApplyCurrentValues(setting);
                  setting = current;
               }
            }
            else
            {
               context.Settings.AddObject(setting);
            }

            context.SaveChanges();
             }
             catch (OptimisticConcurrencyException)
             {
            context.Refresh(RefreshMode.ClientWins, setting);
            context.SaveChanges();
             }

             SetLastChange(GetGalleryDirectory(setting.Gallery));
        }