Added little note to post / comment form, added some other stuff, which I forgot
This commit is contained in:
parent
bdb2d0a0b5
commit
c04b9ac6f2
8 changed files with 105 additions and 20 deletions
|
@ -16,6 +16,12 @@ public static class UsersRepository
|
|||
return await db.Users.FirstOrDefaultAsync(user => user.UserID == userId);
|
||||
}
|
||||
|
||||
public static async Task<UserData> getUserByIPAsync(string userIp)
|
||||
{
|
||||
await using var db = new AppDBContext();
|
||||
return await db.Users.FirstOrDefaultAsync(user => user.Ipv4Address == userIp);
|
||||
}
|
||||
|
||||
public static async Task<int> createUserAsync(UserData userToCreate)
|
||||
{
|
||||
await using var db = new AppDBContext();
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\dynamic\comment" />
|
||||
<Folder Include="wwwroot\dynamic\op" />
|
||||
<Folder Include="wwwroot\static" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
font-weight: 1000;
|
||||
/*the text have to be in a biger Pixel number I do not know how to do it */
|
||||
}
|
||||
|
||||
.rules_list{
|
||||
text-align:left;
|
||||
display:block;
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
<div class="pd centered">
|
||||
<span>Comment on @post.Title in /@post.Board/</span>
|
||||
|
||||
<FormInfo/>
|
||||
|
||||
<div class="centered formContent">
|
||||
<div>
|
||||
<div class="pd centered marg">
|
||||
|
@ -36,6 +38,7 @@
|
|||
</div>
|
||||
|
||||
<div class="pd centered marg">
|
||||
<FormInfo/>
|
||||
<RadzenButton class="pd" Click="@onPostClick" Text="Comment!"></RadzenButton>
|
||||
</div>
|
||||
|
||||
|
@ -103,7 +106,21 @@
|
|||
Banned = false,
|
||||
lastActionTimeStamp = DateTime.Now.Millisecond
|
||||
};
|
||||
int userID = await UsersRepository.createUserAsync(userToCreate);
|
||||
|
||||
int userID;
|
||||
UserData foundusr = await UsersRepository.getUserByIPAsync(userToCreate.Ipv4Address);
|
||||
if (foundusr == null)
|
||||
{
|
||||
userID = await UsersRepository.createUserAsync(userToCreate);
|
||||
}
|
||||
else
|
||||
{
|
||||
userID = foundusr.UserID;
|
||||
if(foundusr.Banned)
|
||||
return;
|
||||
foundusr.lastActionTimeStamp = DateTime.Now.Millisecond;
|
||||
await UsersRepository.updateUserAsync(foundusr);
|
||||
}
|
||||
|
||||
bool hasImage = image != null;
|
||||
CommentData commentToCreate;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<ul class="notesInfo">
|
||||
<li>The max. image size is 1MB.</li>
|
||||
<li>Supported file types are: jpeg, png & gif</li>
|
||||
<li>Read the rules before posting</li>
|
||||
</ul>
|
|
@ -0,0 +1,8 @@
|
|||
.notesInfo{
|
||||
font-weight: 60;
|
||||
display: block;
|
||||
text-align: center;
|
||||
font-size: 10px;
|
||||
color: #c6cfd0;
|
||||
/*the text sice can stay like it is, if you do not want to change it.*/
|
||||
}
|
|
@ -19,6 +19,18 @@
|
|||
<div class="pd centered">
|
||||
<span>Post to /@board.Tag/ - @board.Topic</span>
|
||||
|
||||
<div class="centered formContent">
|
||||
<div>
|
||||
<div class="pd centered marg">
|
||||
@if (image != null)
|
||||
{
|
||||
<img class="formImage" src="@($"data:image/png;base64,{Convert.ToBase64String(image)}")" alt="No Image"/>
|
||||
}
|
||||
</div>
|
||||
<InputFile OnChange="@SingleUpload" type="file" accept="image/*"/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="pd centered marg">
|
||||
<RadzenTextBox Placeholder="Username (Anonymous)" MaxLength="15" Change=@(args => OnChange(args, "username")) Class="w-100"/>
|
||||
</div>
|
||||
|
@ -30,9 +42,12 @@
|
|||
<div class="pd centered marg">
|
||||
<RadzenTextArea Placeholder="Content..." @bind-Value="@postContent" Cols="30" Rows="6" Change=@(args => OnChange(args, "Content")) Class="w-100"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="pd centered marg">
|
||||
<InputFile OnChange="@SingleUpload" type="file" accept="image/*"/>
|
||||
<FormInfo/>
|
||||
<RadzenButton class="pd" Click="@onPostClick" Text="Post!"></RadzenButton>
|
||||
</div>
|
||||
|
||||
|
@ -100,7 +115,21 @@
|
|||
Banned = false,
|
||||
lastActionTimeStamp = DateTime.Now.Millisecond
|
||||
};
|
||||
int userID = await UsersRepository.createUserAsync(userToCreate);
|
||||
|
||||
int userID;
|
||||
UserData foundusr = await UsersRepository.getUserByIPAsync(userToCreate.Ipv4Address);
|
||||
if (foundusr == null)
|
||||
{
|
||||
userID = await UsersRepository.createUserAsync(userToCreate);
|
||||
}
|
||||
else
|
||||
{
|
||||
userID = foundusr.UserID;
|
||||
if(foundusr.Banned)
|
||||
return;
|
||||
foundusr.lastActionTimeStamp = DateTime.Now.Millisecond;
|
||||
await UsersRepository.updateUserAsync(foundusr);
|
||||
}
|
||||
|
||||
//TODO Add check if data is image
|
||||
|
||||
|
|
|
@ -21,3 +21,20 @@
|
|||
.marg{
|
||||
margin: 2px
|
||||
}
|
||||
|
||||
.formImage{
|
||||
margin: 6px;
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.formImage img{
|
||||
max-width:150px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.formContent{
|
||||
text-align: left;
|
||||
display: flex;
|
||||
}
|
Loading…
Reference in a new issue