changed multiplier to string, kotlin weird
This commit is contained in:
parent
6e72f549cf
commit
fd85841daf
@ -20,6 +20,7 @@ android {
|
|||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
buildConfigField("String", "API_BASE_URL", project.property("API_BASE_URL").toString())
|
buildConfigField("String", "API_BASE_URL", project.property("API_BASE_URL").toString())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -10,7 +10,6 @@ import android.view.ViewGroup
|
|||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import tech.mercantec.easyeat.R
|
import tech.mercantec.easyeat.R
|
||||||
import tech.mercantec.easyeat.helpers.ApiRequestException
|
import tech.mercantec.easyeat.helpers.ApiRequestException
|
||||||
import tech.mercantec.easyeat.helpers.RecipeDetailsResponse
|
import tech.mercantec.easyeat.helpers.RecipeDetailsResponse
|
||||||
@ -19,6 +18,7 @@ import kotlin.concurrent.thread
|
|||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.widget.doAfterTextChanged
|
import androidx.core.widget.doAfterTextChanged
|
||||||
import tech.mercantec.easyeat.helpers.AddRecipeToShoppingList
|
import tech.mercantec.easyeat.helpers.AddRecipeToShoppingList
|
||||||
import tech.mercantec.easyeat.models.Ingredient
|
import tech.mercantec.easyeat.models.Ingredient
|
||||||
|
@ -111,13 +111,15 @@ namespace API.BusinessLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Adds an entire recipes ingredients to the shoppinglist
|
// 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 user = await _dbAccess.ReadShoppingList(userId);
|
||||||
var recipe = await _recipeDBAccess.ReadRecipe(recipeId);
|
var recipe = await _recipeDBAccess.ReadRecipe(recipeId);
|
||||||
var ingredients = recipe.Ingredients;
|
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)
|
foreach (var ingredient in ingredients)
|
||||||
{
|
{
|
||||||
|
@ -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>
|
/// <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]
|
[Authorize]
|
||||||
[HttpPost("recipeadd")]
|
[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;
|
var claims = HttpContext.User.Claims;
|
||||||
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
string userIdString = claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
|
Loading…
Reference in New Issue
Block a user