public void Delete(int key) { if (key < 1) { throw new ArgumentException("The Key must be greater than 0", "key"); } CancelEventArgsWithOneParameterWithoutResult <int> e = new CancelEventArgsWithOneParameterWithoutResult <int>(key); this.PostDeleting.Raise(this, e); if (e.Cancel) { return; } PostDto post = this.postDataService.GetPostByKey(key); if (post == null) { throw new DexterPostNotFoundException(key); } if (!this.userContext.IsInRole(Constants.AdministratorRole) && post.Author != this.userContext.Username) { throw new DexterSecurityException(string.Format("Only the Administrator or the Author can delete the post (item Key '{0}').", post.Id)); } this.postDataService.Delete(key); this.PostDeleted.Raise(this, new EventArgs()); }
public void SaveOrUpdate(PageDto item) { if (item == null) { throw new DexterPageNotFoundException(); } CancelEventArgsWithOneParameterWithoutResult <PageDto> e = new CancelEventArgsWithOneParameterWithoutResult <PageDto>(item); this.PageSaving.Raise(this, e); if (e.Cancel) { return; } if (item.Id > 0) { var post = this.pageDataService.GetPageByKey(item.Id); if (post == null) { throw new DexterPostNotFoundException(item.Id); } if (!this.userContext.IsInRole(Constants.AdministratorRole) && post.Author != this.userContext.Username) { throw new DexterSecurityException(string.Format("Only the Administrator or the Author can edit the post (item Key '{0}').", post.Id)); } } this.pageDataService.SaveOrUpdate(item); this.PageSaved.Raise(this, new CancelEventArgsWithoutParameterWithResult <PageDto>(item)); }
public void SaveOrUpdate(PostDto item) { if (item == null) { throw new DexterPostNotFoundException(); } CancelEventArgsWithOneParameterWithoutResult <PostDto> e = new CancelEventArgsWithOneParameterWithoutResult <PostDto>(item); this.PostSaving.Raise(this, e); if (e.Cancel) { return; } if (item.Id > 0) { PostDto post = this.postDataService.GetPostByKey(item.Id); if (post == null) { throw new DexterPostNotFoundException(item.Id); } if (!this.userContext.IsInRole(Constants.AdministratorRole) && post.Author != this.userContext.Username) { throw new DexterSecurityException(string.Format("Only the Administrator or the Author can edit the post (item Key '{0}').", post.Id)); } } this.postDataService.SaveOrUpdate(item); if (item.Status == ItemStatus.Published) { this.PostPublished.Raise(this, new CancelEventArgsWithoutParameterWithResult <PostDto>(item)); this.taskExecutor.ExcuteLater(new PublishedBackgroundTask(item)); } this.PostSaved.Raise(this, new CancelEventArgsWithoutParameterWithResult <PostDto>(item)); }
public void Delete(int key) { if (key < 1) { throw new ArgumentException("The Key must be greater than 0", "key"); } CancelEventArgsWithOneParameterWithoutResult<int> e = new CancelEventArgsWithOneParameterWithoutResult<int>(key); this.PageDeleting.Raise(this, e); if (e.Cancel) { return; } var page = this.pageDataService.GetPageByKey(key); if (page == null) { throw new DexterPostNotFoundException(key); } if (!this.userContext.IsInRole(Constants.AdministratorRole) && page.Author != this.userContext.Username) { throw new DexterSecurityException(string.Format("Only the Administrator or the Author can delete the page (item Key '{0}').", page.Id)); } this.pageDataService.Delete(key); this.PageDeleted.Raise(this, new EventArgs()); }
public void SaveOrUpdate(PageDto item) { if (item == null) { throw new DexterPageNotFoundException(); } CancelEventArgsWithOneParameterWithoutResult<PageDto> e = new CancelEventArgsWithOneParameterWithoutResult<PageDto>(item); this.PageSaving.Raise(this, e); if (e.Cancel) { return; } if (item.Id > 0) { var post = this.pageDataService.GetPageByKey(item.Id); if (post == null) { throw new DexterPostNotFoundException(item.Id); } if (!this.userContext.IsInRole(Constants.AdministratorRole) && post.Author != this.userContext.Username) { throw new DexterSecurityException(string.Format("Only the Administrator or the Author can edit the post (item Key '{0}').", post.Id)); } } this.pageDataService.SaveOrUpdate(item); this.PageSaved.Raise(this, new CancelEventArgsWithoutParameterWithResult<PageDto>(item)); }