summaryrefslogtreecommitdiff
path: root/backend/Elements.Backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend/Elements.Backend')
-rw-r--r--backend/Elements.Backend/Controllers/ElementController.cs8
-rw-r--r--backend/Elements.Backend/Controllers/SuggestionController.cs4
2 files changed, 7 insertions, 5 deletions
diff --git a/backend/Elements.Backend/Controllers/ElementController.cs b/backend/Elements.Backend/Controllers/ElementController.cs
index 890f614..2f57514 100644
--- a/backend/Elements.Backend/Controllers/ElementController.cs
+++ b/backend/Elements.Backend/Controllers/ElementController.cs
@@ -51,13 +51,13 @@ public class ElementController : ControllerBase
if (!firstExists || !secondExists)
return BadRequest();
- Recipe? recipe = await _dbContext.Recipes.Include(r => r.Result).FirstOrDefaultAsync(r =>
- (r.FirstIngredient.Id == firstElementId && r.SecondIngredient.Id == secondElementId) ||
- (r.FirstIngredient.Id == secondElementId && r.SecondIngredient.Id == firstElementId));
+ Recipe? recipe = await _dbContext.Recipes.Include(r => r.ResultElement).FirstOrDefaultAsync(r =>
+ (r.FirstElementId == firstElementId && r.SecondElementId == secondElementId) ||
+ (r.FirstElementId == secondElementId && r.SecondElementId == firstElementId));
if (recipe == null)
return NotFound();
var serializeOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
- return Ok(JsonSerializer.Serialize(recipe.Result, serializeOptions));
+ return Ok(JsonSerializer.Serialize(recipe.ResultElement, serializeOptions));
}
} \ No newline at end of file
diff --git a/backend/Elements.Backend/Controllers/SuggestionController.cs b/backend/Elements.Backend/Controllers/SuggestionController.cs
index 77a3944..040b19b 100644
--- a/backend/Elements.Backend/Controllers/SuggestionController.cs
+++ b/backend/Elements.Backend/Controllers/SuggestionController.cs
@@ -112,16 +112,18 @@ public class SuggestionController : ControllerBase
if (currentUserId == null)
return StatusCode(StatusCodes.Status500InternalServerError);
+ //User already suggested something
if (await _dbContext.Suggestions.AnyAsync(s => s.UserId.ToString() == currentUserId))
return BadRequest();
Suggestion newSuggestion = new()
{
+ CreationDate = DateTime.UtcNow,
Name = suggestion.Name,
Icon = ConvertBitmapToPng(Convert.FromBase64String(suggestion.IconBitmap)),
FirstElementId = suggestion.FirstElementId,
SecondElementId = suggestion.SecondElementId,
- VotingEnd = DateTime.UtcNow + TimeSpan.FromMinutes(1),
+ VotingEnd = DateTime.UtcNow + TimeSpan.FromSeconds(10),
UserId = int.Parse(currentUserId)
};
await _dbContext.Suggestions.AddAsync(newSuggestion);