Permalink
Browse files

Implemented "Flag as Spam" button.

  • Loading branch information...
william-gross committed Oct 5, 2018
1 parent 482bda8 commit 4c24070ca5fde8a0d0774d87a1958472e3d6b5dc
@@ -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
@@ -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();
@@ -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 ) )
@@ -76,6 +76,7 @@ partial class Info {
var mod = ArticlesModification.CreateForInsert();
mod.AuthorId = AppTools.User.UserId;
mod.IsSpam = false;
return mod;
}

0 comments on commit 4c24070

Please sign in to comment.