示例#1
0
        public async Task <IActionResult> ProductEditStep4(FoodItemAdapter foodItemAdapter)
        {
            FoodItem dbFoodItem = await sessionHelper.GetObjectFromJson <FoodItem>("foodItem");

            if (dbFoodItem == null)
            {
                dbFoodItem = new FoodItem();
            }

            dbFoodItem.Weight        = foodItemAdapter.Weight;
            dbFoodItem.WeightUnit    = foodItemAdapter.WeightUnit;
            dbFoodItem.Fat           = ParseStringToFloat(foodItemAdapter.Fat);
            dbFoodItem.Protein       = ParseStringToFloat(foodItemAdapter.Protein);
            dbFoodItem.Carbohydrates = ParseStringToFloat(foodItemAdapter.Carbohydrates);

            await ProductChange("foodItem", dbFoodItem);

            return(RedirectToRoute("AdminEditFinal"));
        }
示例#2
0
        public async void ProductEditStep4()
        {
            fixture.sessionMock.Clear();
            FoodItemAdapter foodItem = new FoodItemAdapter
            {
                Id            = 77,
                Weight        = 171,
                WeightUnit    = "gr",
                Carbohydrates = "14.2",
                Fat           = "2.2f",
                Protein       = "8.1"
            };
            bool contains = fixture.sessionMock.ContainsKey("foodItem");


            await controller.ProductEditStep4(foodItem);

            bool actual = fixture.sessionMock.ContainsKey("foodItem");


            Assert.False(contains);
            Assert.True(actual);
        }