summaryrefslogtreecommitdiff
path: root/backend/Elements.Backend/Controllers/SuggestionController.cs
diff options
context:
space:
mode:
authorPaweł Bernaciak <pawelbernaciak@zohomail.eu>2024-01-20 11:03:44 +0100
committerPaweł Bernaciak <pawelbernaciak@zohomail.eu>2024-01-20 11:03:44 +0100
commit363936641a31b0b508197d41bea1ce116931b5d4 (patch)
treeff5faa88b40b79b71ce32e648ac0a1dcfeffb91c /backend/Elements.Backend/Controllers/SuggestionController.cs
parent32180f5b46fe594b01c40ca1d837734b1be894d6 (diff)
New element creatorHEADmaster
Diffstat (limited to 'backend/Elements.Backend/Controllers/SuggestionController.cs')
-rw-r--r--backend/Elements.Backend/Controllers/SuggestionController.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/backend/Elements.Backend/Controllers/SuggestionController.cs b/backend/Elements.Backend/Controllers/SuggestionController.cs
index b1d28b8..9c39163 100644
--- a/backend/Elements.Backend/Controllers/SuggestionController.cs
+++ b/backend/Elements.Backend/Controllers/SuggestionController.cs
@@ -122,6 +122,12 @@ public class SuggestionController : ControllerBase
//User already suggested something
if (await _dbContext.Suggestions.AnyAsync(s => s.UserId.ToString() == currentUserId))
return BadRequest();
+
+ var exists = await _dbContext.Recipes.AnyAsync(r =>
+ (r.FirstElementId == suggestion.FirstElementId && r.SecondElementId == suggestion.SecondElementId) ||
+ (r.FirstElementId == suggestion.SecondElementId && r.SecondElementId == suggestion.FirstElementId));
+ if (exists)
+ return BadRequest();
Suggestion newSuggestion = new()
{
@@ -130,7 +136,7 @@ public class SuggestionController : ControllerBase
Icon = ConvertBitmapToPng(Convert.FromBase64String(suggestion.IconBitmap)),
FirstElementId = suggestion.FirstElementId,
SecondElementId = suggestion.SecondElementId,
- VotingEnd = DateTime.UtcNow + TimeSpan.FromMinutes(5),
+ VotingEnd = DateTime.UtcNow + TimeSpan.FromMinutes(1),
UserId = int.Parse(currentUserId)
};
await _dbContext.Suggestions.AddAsync(newSuggestion);