Skip to content

Commit

Permalink
Implemented "Flag as Spam" button.
Browse files Browse the repository at this point in the history
  • Loading branch information
william-gross committed Oct 5, 2018
1 parent 482bda8 commit 4c24070
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
9 changes: 9 additions & 0 deletions Library/Configuration/Database Updates.sql
Expand Up @@ -97,4 +97,13 @@ create table Comments(
CreationDateAndTime datetime2
not null
)
go

alter table Articles add
IsSpam bit
null
go
update Articles set IsSpam = 0
go
alter table Articles alter column IsSpam bit not null
go
2 changes: 1 addition & 1 deletion Library/DataAccess/Retrieval/ArticlesRetrieval.cs
Expand Up @@ -4,7 +4,7 @@ namespace EwlRealWorld.Library.DataAccess.Retrieval {
partial class ArticlesRetrieval {
partial class Row {
public Modification.ArticlesModification ToModification() =>
Modification.ArticlesModification.CreateForSingleRowUpdate( ArticleId, AuthorId, Slug, Title, Description, BodyMarkdown, CreationDateAndTime );
Modification.ArticlesModification.CreateForSingleRowUpdate( ArticleId, AuthorId, Slug, Title, Description, BodyMarkdown, CreationDateAndTime, IsSpam );
}

public static Row GetRowMatchingId( int articleId ) => GetRowsMatchingId( articleId ).Single();
Expand Down
19 changes: 18 additions & 1 deletion Website/Pages/Article.aspx.cs
Expand Up @@ -49,7 +49,24 @@ partial class Info {
icon: new ActionComponentIcon( new FontAwesomeIcon( "fa-trash" ) ) ) )
.Materialize() );
else
EwfUiStatics.SetPageActions( AppStatics.GetFollowAction( info.Article.AuthorId ).ToCollection().Append( getFavoriteAction() ).Materialize() );
EwfUiStatics.SetPageActions(
AppStatics.GetFollowAction( info.Article.AuthorId )
.ToCollection()
.Append( getFavoriteAction() )
.Concat(
!info.Article.IsSpam && AppTools.User != null
? new ButtonSetup(
"Flag as Spam",
behavior: new PostBackBehavior(
postBack: PostBack.CreateFull(
id: "spam",
firstModificationMethod: () => {
var mod = info.Article.ToModification();
mod.IsSpam = true;
mod.Execute();
} ) ) ).ToCollection()
: Enumerable.Empty<ActionComponentSetup>() )
.Materialize() );

ph.AddControlsReturnThis(
AppStatics.GetAuthorDisplay( info.Article, UsersTableRetrieval.GetRowMatchingId( info.Article.AuthorId ) )
Expand Down
1 change: 1 addition & 0 deletions Website/Pages/Editor.aspx.cs
Expand Up @@ -76,6 +76,7 @@ partial class Info {

var mod = ArticlesModification.CreateForInsert();
mod.AuthorId = AppTools.User.UserId;
mod.IsSpam = false;
return mod;
}

Expand Down

0 comments on commit 4c24070

Please sign in to comment.