summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-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);