protected void rGrid_Delete(object sender, RowEventArgs e) { Rock.CMS.Block block = _blockService.Get(( int )rGrid.DataKeys[e.RowIndex]["id"]); if (BlockInstance != null) { _blockService.Delete(block, CurrentPersonId); _blockService.Save(block, CurrentPersonId); Rock.Web.Cache.Block.Flush(block.Id); } BindGrid(); }
public void UpdateBlock(string id, Rock.CMS.DTO.Block Block) { var currentUser = Rock.CMS.UserService.GetCurrentUser(); if (currentUser == null) { throw new WebFaultException <string>("Must be logged in", System.Net.HttpStatusCode.Forbidden); } using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope()) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block existingBlock = BlockService.Get(int.Parse(id)); if (existingBlock.Authorized("Edit", currentUser)) { uow.objectContext.Entry(existingBlock).CurrentValues.SetValues(Block); if (existingBlock.IsValid) { BlockService.Save(existingBlock, currentUser.PersonId); } else { throw new WebFaultException <string>(existingBlock.ValidationResults.AsDelimited(", "), System.Net.HttpStatusCode.BadRequest); } } else { throw new WebFaultException <string>("Not Authorized to Edit this Block", System.Net.HttpStatusCode.Forbidden); } } }
public Rock.CMS.DTO.Block ApiGet(string id, string apiKey) { using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope()) { Rock.CMS.UserService userService = new Rock.CMS.UserService(); Rock.CMS.User user = userService.Queryable().Where(u => u.ApiKey == apiKey).FirstOrDefault(); if (user != null) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block Block = BlockService.Get(int.Parse(id)); if (Block.Authorized("View", user)) { return(Block.DataTransferObject); } else { throw new WebFaultException <string>("Not Authorized to View this Block", System.Net.HttpStatusCode.Forbidden); } } else { throw new WebFaultException <string>("Invalid API Key", System.Net.HttpStatusCode.Forbidden); } } }
public void ApiDeleteBlock(string id, string apiKey) { using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope()) { Rock.CMS.UserService userService = new Rock.CMS.UserService(); Rock.CMS.User user = userService.Queryable().Where(u => u.ApiKey == apiKey).FirstOrDefault(); if (user != null) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block Block = BlockService.Get(int.Parse(id)); if (Block.Authorized("Edit", user)) { BlockService.Delete(Block, user.PersonId); BlockService.Save(Block, user.PersonId); } else { throw new WebFaultException <string>("Not Authorized to Edit this Block", System.Net.HttpStatusCode.Forbidden); } } else { throw new WebFaultException <string>("Invalid API Key", System.Net.HttpStatusCode.Forbidden); } } }
public void DeleteBlock(string id) { var currentUser = Rock.CMS.UserService.GetCurrentUser(); if (currentUser == null) { throw new WebFaultException <string>("Must be logged in", System.Net.HttpStatusCode.Forbidden); } using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope()) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block Block = BlockService.Get(int.Parse(id)); if (Block.Authorized("Edit", currentUser)) { BlockService.Delete(Block, currentUser.PersonId); BlockService.Save(Block, currentUser.PersonId); } else { throw new WebFaultException <string>("Not Authorized to Edit this Block", System.Net.HttpStatusCode.Forbidden); } } }
public void ApiDeleteBlock( string id, string apiKey ) { using ( Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope() ) { Rock.CMS.UserService userService = new Rock.CMS.UserService(); Rock.CMS.User user = userService.Queryable().Where( u => u.ApiKey == apiKey ).FirstOrDefault(); if (user != null) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block Block = BlockService.Get( int.Parse( id ) ); if ( Block.Authorized( "Edit", user ) ) { BlockService.Delete( Block, user.PersonId ); BlockService.Save( Block, user.PersonId ); } else throw new WebFaultException<string>( "Not Authorized to Edit this Block", System.Net.HttpStatusCode.Forbidden ); } else throw new WebFaultException<string>( "Invalid API Key", System.Net.HttpStatusCode.Forbidden ); } }
public Rock.CMS.DTO.Block Get(string id) { var currentUser = Rock.CMS.UserService.GetCurrentUser(); if (currentUser == null) { throw new WebFaultException <string>("Must be logged in", System.Net.HttpStatusCode.Forbidden); } using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope()) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block Block = BlockService.Get(int.Parse(id)); if (Block.Authorized("View", currentUser)) { return(Block.DataTransferObject); } else { throw new WebFaultException <string>("Not Authorized to View this Block", System.Net.HttpStatusCode.Forbidden); } } }
public void ApiUpdateBlock(string id, string apiKey, Rock.CMS.DTO.Block Block) { using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope()) { Rock.CMS.UserService userService = new Rock.CMS.UserService(); Rock.CMS.User user = userService.Queryable().Where(u => u.ApiKey == apiKey).FirstOrDefault(); if (user != null) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block existingBlock = BlockService.Get(int.Parse(id)); if (existingBlock.Authorized("Edit", user)) { uow.objectContext.Entry(existingBlock).CurrentValues.SetValues(Block); if (existingBlock.IsValid) { BlockService.Save(existingBlock, user.PersonId); } else { throw new WebFaultException <string>(existingBlock.ValidationResults.AsDelimited(", "), System.Net.HttpStatusCode.BadRequest); } } else { throw new WebFaultException <string>("Not Authorized to Edit this Block", System.Net.HttpStatusCode.Forbidden); } } else { throw new WebFaultException <string>("Invalid API Key", System.Net.HttpStatusCode.Forbidden); } } }
public Rock.CMS.DTO.Block ApiGet( string id, string apiKey ) { using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope()) { Rock.CMS.UserService userService = new Rock.CMS.UserService(); Rock.CMS.User user = userService.Queryable().Where( u => u.ApiKey == apiKey ).FirstOrDefault(); if (user != null) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block Block = BlockService.Get( int.Parse( id ) ); if ( Block.Authorized( "View", user ) ) return Block.DataTransferObject; else throw new WebFaultException<string>( "Not Authorized to View this Block", System.Net.HttpStatusCode.Forbidden ); } else throw new WebFaultException<string>( "Invalid API Key", System.Net.HttpStatusCode.Forbidden ); } }
public void UpdateBlock( string id, Rock.CMS.DTO.Block Block ) { var currentUser = Rock.CMS.UserService.GetCurrentUser(); if ( currentUser == null ) throw new WebFaultException<string>("Must be logged in", System.Net.HttpStatusCode.Forbidden ); using ( Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope() ) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block existingBlock = BlockService.Get( int.Parse( id ) ); if ( existingBlock.Authorized( "Edit", currentUser ) ) { uow.objectContext.Entry(existingBlock).CurrentValues.SetValues(Block); if (existingBlock.IsValid) BlockService.Save( existingBlock, currentUser.PersonId ); else throw new WebFaultException<string>( existingBlock.ValidationResults.AsDelimited(", "), System.Net.HttpStatusCode.BadRequest ); } else throw new WebFaultException<string>( "Not Authorized to Edit this Block", System.Net.HttpStatusCode.Forbidden ); } }
public Rock.CMS.DTO.Block Get( string id ) { var currentUser = Rock.CMS.UserService.GetCurrentUser(); if ( currentUser == null ) throw new WebFaultException<string>("Must be logged in", System.Net.HttpStatusCode.Forbidden ); using (Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope()) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block Block = BlockService.Get( int.Parse( id ) ); if ( Block.Authorized( "View", currentUser ) ) return Block.DataTransferObject; else throw new WebFaultException<string>( "Not Authorized to View this Block", System.Net.HttpStatusCode.Forbidden ); } }
public void DeleteBlock( string id ) { var currentUser = Rock.CMS.UserService.GetCurrentUser(); if ( currentUser == null ) throw new WebFaultException<string>("Must be logged in", System.Net.HttpStatusCode.Forbidden ); using ( Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope() ) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block Block = BlockService.Get( int.Parse( id ) ); if ( Block.Authorized( "Edit", currentUser ) ) { BlockService.Delete( Block, currentUser.PersonId ); BlockService.Save( Block, currentUser.PersonId ); } else throw new WebFaultException<string>( "Not Authorized to Edit this Block", System.Net.HttpStatusCode.Forbidden ); } }
public void ApiUpdateBlock( string id, string apiKey, Rock.CMS.DTO.Block Block ) { using ( Rock.Data.UnitOfWorkScope uow = new Rock.Data.UnitOfWorkScope() ) { Rock.CMS.UserService userService = new Rock.CMS.UserService(); Rock.CMS.User user = userService.Queryable().Where( u => u.ApiKey == apiKey ).FirstOrDefault(); if (user != null) { uow.objectContext.Configuration.ProxyCreationEnabled = false; Rock.CMS.BlockService BlockService = new Rock.CMS.BlockService(); Rock.CMS.Block existingBlock = BlockService.Get( int.Parse( id ) ); if ( existingBlock.Authorized( "Edit", user ) ) { uow.objectContext.Entry(existingBlock).CurrentValues.SetValues(Block); if (existingBlock.IsValid) BlockService.Save( existingBlock, user.PersonId ); else throw new WebFaultException<string>( existingBlock.ValidationResults.AsDelimited(", "), System.Net.HttpStatusCode.BadRequest ); } else throw new WebFaultException<string>( "Not Authorized to Edit this Block", System.Net.HttpStatusCode.Forbidden ); } else throw new WebFaultException<string>( "Invalid API Key", System.Net.HttpStatusCode.Forbidden ); } }