예제 #1
0
 public void DisplayInvoice(Recipe recipe)
 {
     Console.WriteLine(recipe.RecipeName);
     Console.WriteLine("Tax= $" + recipe.SalesTaxDue);
     Console.WriteLine("Discount=($" + recipe.DiscountAmount + ")");
     Console.WriteLine("Total= $" + recipe.RecipeTotalAfterDiscount+"\n\n");
 }
예제 #2
0
        public Recipe GetRecipe(int recipeID)
        {
            SqlParameter _parameters = new SqlParameter("RecipeID", recipeID);
            DataSet recipeData = _dbConnection.GetData("vsp_GetRecipeByRecipeID", _parameters);
            Recipe recipe = new Recipe();
            this.IngridientList = new RecipeIngredient().GetIngredientsByRecipe(recipeID);

            if (recipeData != null && recipeData.Tables.Count > 0)
            {

                foreach (DataRow item in recipeData.Tables[0].Rows)
                {
                    recipe.RecipeName = item["RecipeName"].ToString();
                }
            }

            if (this.IngridientList != null)
            {
                foreach(RecipeIngredient ingredient in this.IngridientList)
                {
                    recipe.RecipeTotalAfterDiscount += ingredient.IngredientCostAfterDiscount;
                    recipe.RecipeTotalBeforeDiscount += ingredient.IngredientCost;
                }
            }
            recipe.SalesTaxDue = Math.Round(this.CalCulateSalesTax(recipe.RecipeTotalBeforeDiscount),2);
            recipe.RecipeTotalAfterDiscount = Math.Round((recipe.RecipeTotalAfterDiscount), 2);
            recipe.RecipeTotalBeforeDiscount = Math.Round((recipe.RecipeTotalBeforeDiscount), 2);
            recipe.DiscountAmount = Math.Round((recipe.RecipeTotalBeforeDiscount - recipe.RecipeTotalAfterDiscount),2);
            return recipe;
        }
        public void TestRecipeContents()
        {
            string TestRecipeName = "";
            double TestSalesTaxDue=0, TestDiscountAmount=0;
            bool expectedResult = bool.Parse(TestContextInstance.DataRow[1].ToString());
            TestRecipeName = TestContextInstance.DataRow[0].ToString();
            TestSalesTaxDue = double.Parse(TestContextInstance.DataRow[1].ToString());
            TestDiscountAmount = double.Parse(TestContextInstance.DataRow[2].ToString()); ;

            Recipe recipe = new Recipe().GetRecipe(1);
            Assert.AreEqual(recipe.RecipeName, TestRecipeName);
            Assert.AreEqual(recipe.SalesTaxDue, TestSalesTaxDue);
            Assert.AreEqual(recipe.DiscountAmount, TestSalesTaxDue);
        }
예제 #4
0
 static void Main(string[] args)
 {
     ////var container = new UnityContainer();
     ////container.RegisterType(typeof(IRecipe), typeof(Recipe));
     ////container.RegisterType(typeof(IDatabaseManager), typeof(DatabaseManager));
     ////container.RegisterType(typeof(IIngredient), typeof(RecipeIngredient));
     Recipe recipe = new Recipe().GetRecipe(1);
     recipe.DisplayInvoice(recipe);
     int[] recipeList = { 1, 2, 3 };
     IList<Recipe> list = new Recipe().GetAllRecipes(recipeList);
     foreach (Recipe rcp in list)
     {
         rcp.DisplayInvoice(rcp);
     }
     Console.ReadKey();
 }