public IActionResult MerchantShop() { MerchantShopViewModel msvm = new MerchantShopViewModel(); msvm.IngList = repo.Ingredients; return(View(msvm)); }
public IActionResult MerchantShop(MerchantShopViewModel msvn) { msvn.IngList = repo.Ingredients; if (ModelState.IsValid) { repo.addIngredientStock(msvn); return(View(msvn)); } return(View(msvn)); }
public Tests() { frepo = new FakeRepository(); home = new HomeController(frepo); i1 = new Ingredient { IngID = 0, IngPicture = "nether.png", IngName = "NetherWart", IngDescription = "The basics of every potion.", IngStock = 250 }; i2 = new Ingredient { IngID = 1, IngPicture = "sugar.png", IngName = "Sugar", IngDescription = "Sweet.", IngStock = 50 }; i3 = new Ingredient { IngID = 2, IngPicture = "blaze.png", IngName = "Blaze Powder", IngDescription = "Hot to the touch.", IngStock = 50 }; p1 = new Potion { PotionID = 0, PotionName = "Potion of Swiftness", PotionDescription = "Makes the user run with godspeed", PIng1 = i1, PIng2 = i2, PIng3 = i2, PotionStock = 1 }; p2 = new Potion { PotionID = 1, PotionName = "Potion of Strength", PotionDescription = "Gives the strength of the mightiest warrior", PIng1 = i1, PIng2 = i3, PIng3 = i3, PotionStock = 1 }; p3 = new Potion { PotionID = 2, PotionName = "Potion of Coolness", PotionDescription = "Makes you really cool", PIng1 = i1, PIng2 = i2, PIng3 = i3, PotionStock = 1 }; r1 = new Recipe { RecipeID = 0, RPotionName = "Potion of Swiftness", RPotionDesc = "Makes the user run with godspeed", RIng1 = i1, RIng2 = i2, RIng3 = i2 }; r2 = new Recipe { RecipeID = 1, RPotionName = "Potion of Strength", RPotionDesc = "Gives the strength of the mightiest warrior", RIng1 = i1, RIng2 = i3, RIng3 = i3 }; r3 = new Recipe { RecipeID = 2, RPotionName = "Potion of Coolness", RPotionDesc = "Makes you really cool", RIng1 = i1, RIng2 = i2, RIng3 = i3 }; frepo.Potions.Clear(); frepo.Recipes.Clear(); frepo.Ingredients.Clear(); frepo.Ingredients.Add(i1); frepo.Ingredients.Add(i2); frepo.Ingredients.Add(i3); pcvm = new PotionCreationViewModel { Ingredients = frepo.Ingredients, Recipes = frepo.Recipes }; prcvm = new PotionRecipeCreationViewModel { Recipes = frepo.Recipes, Ingredients = frepo.Ingredients }; psvm = new PotionStockViewModel { Ingredients = frepo.Ingredients, Potions = frepo.Potions }; rpvm = new RecipePotionViewModel { Recipes = frepo.Recipes }; msvn = new MerchantShopViewModel { IngList = frepo.Ingredients }; }
public void addIngredientStock(MerchantShopViewModel msvn) { Ingredient i = getIngredientByID(msvn.IngredientID); if (msvn.AmountBought >= 0 && msvn.AmountBought <= 100) { i.IngStock = i.IngStock + msvn.AmountBought; } else { throw new ArgumentOutOfRangeException("Input a number between 0 and 100"); } }
public void addIngredientStock(MerchantShopViewModel msvn) { Ingredient i = getIngredientByID(msvn.IngredientID); if (msvn.AmountBought >= 0 && msvn.AmountBought <= 100) { i.IngStock = i.IngStock + msvn.AmountBought; context.Ingredients.Update(i); context.SaveChanges(); } else { throw new ArgumentOutOfRangeException("Please input a value between 0 and 100"); } }