/// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            using (var rockContext = new RockContext())
            {
                AssetStorageProvider assetStorageProvider = null;
                var assetStorageProviderService           = new AssetStorageProviderService(rockContext);

                if (AssetStorageProviderId != 0)
                {
                    assetStorageProvider = assetStorageProviderService.Get(AssetStorageProviderId);
                }

                if (assetStorageProvider == null)
                {
                    assetStorageProvider = new Rock.Model.AssetStorageProvider();
                    assetStorageProviderService.Add(assetStorageProvider);
                }

                assetStorageProvider.Name         = tbName.Text;
                assetStorageProvider.IsActive     = cbIsActive.Checked;
                assetStorageProvider.Description  = tbDescription.Text;
                assetStorageProvider.EntityTypeId = cpAssetStorageType.SelectedEntityTypeId;

                rockContext.SaveChanges();

                assetStorageProvider.LoadAttributes(rockContext);
                Rock.Attribute.Helper.GetEditValues(phAttributes, assetStorageProvider);
                assetStorageProvider.SaveAttributeValues(rockContext);
            }

            NavigateToParentPage();
        }
Exemple #2
0
 /// <summary>
 /// Clones this AssetStorageProvider object to a new AssetStorageProvider object
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param>
 /// <returns></returns>
 public static AssetStorageProvider Clone(this AssetStorageProvider source, bool deepCopy)
 {
     if (deepCopy)
     {
         return(source.Clone() as AssetStorageProvider);
     }
     else
     {
         var target = new AssetStorageProvider();
         target.CopyPropertiesFrom(source);
         return(target);
     }
 }
Exemple #3
0
 /// <summary>
 /// Copies the properties from another AssetStorageProvider object to this AssetStorageProvider object
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="source">The source.</param>
 public static void CopyPropertiesFrom(this AssetStorageProvider target, AssetStorageProvider source)
 {
     target.Id                      = source.Id;
     target.Description             = source.Description;
     target.EntityTypeId            = source.EntityTypeId;
     target.ForeignGuid             = source.ForeignGuid;
     target.ForeignKey              = source.ForeignKey;
     target.IsActive                = source.IsActive;
     target.Name                    = source.Name;
     target.Order                   = source.Order;
     target.CreatedDateTime         = source.CreatedDateTime;
     target.ModifiedDateTime        = source.ModifiedDateTime;
     target.CreatedByPersonAliasId  = source.CreatedByPersonAliasId;
     target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     target.Guid                    = source.Guid;
     target.ForeignId               = source.ForeignId;
 }