changed multiplier to string, kotlin weird

This commit is contained in:
LilleBRG 2025-05-14 09:17:16 +02:00
parent 6e72f549cf
commit fd85841daf
4 changed files with 7 additions and 4 deletions

View File

@ -20,6 +20,7 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "API_BASE_URL", project.property("API_BASE_URL").toString())
}
buildTypes {

View File

@ -10,7 +10,6 @@ import android.view.ViewGroup
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import tech.mercantec.easyeat.R
import tech.mercantec.easyeat.helpers.ApiRequestException
import tech.mercantec.easyeat.helpers.RecipeDetailsResponse
@ -19,6 +18,7 @@ import kotlin.concurrent.thread
import android.widget.EditText
import android.widget.ImageButton
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.widget.doAfterTextChanged
import tech.mercantec.easyeat.helpers.AddRecipeToShoppingList
import tech.mercantec.easyeat.models.Ingredient

View File

@ -111,13 +111,15 @@ namespace API.BusinessLogic
}
// Adds an entire recipes ingredients to the shoppinglist
public async Task<IActionResult> AddRecipeToShoppingList(int userId, int recipeId, int multiplier)
public async Task<IActionResult> AddRecipeToShoppingList(int userId, int recipeId, string multiplier)
{
var user = await _dbAccess.ReadShoppingList(userId);
var recipe = await _recipeDBAccess.ReadRecipe(recipeId);
var ingredients = recipe.Ingredients;
for (int i = 0; i < multiplier; i++)
int multiToInt = int.Parse(multiplier);
for (int i = 0; i < multiToInt; i++)
{
foreach (var ingredient in ingredients)
{

View File

@ -100,7 +100,7 @@ namespace API.Controllers
/// <returns>returns a okobjectresult with a boolean that is true if it fails it returns a confliftobjectresult with a message of why it failed</returns>
[Authorize]
[HttpPost("recipeadd")]
public async Task<IActionResult> AddARecipesItems(int recipeId, int multiplier = 1)
public async Task<IActionResult> AddARecipesItems(int recipeId, string multiplier = "1")
{
var claims = HttpContext.User.Claims;
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;