private void GetAllExtraExpenseForCase(Case @case)
        {
            Dictionary <IExtraExpenseSpecification, Category> listOfExtraExpenses = new Dictionary <IExtraExpenseSpecification, Category>();

            try
            {
                conn.Open();

                SqlCommand command = new SqlCommand("CH_SP_GetAllExtraExpensesForCase", conn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add(new SqlParameter("@CaseYear", @case.DateOfCreation.Year));
                command.Parameters.Add(new SqlParameter("@CaseNumber", @case.CaseNumber));

                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        string  name       = reader.GetString(0);
                        int     amount     = reader.GetInt32(1);
                        decimal price      = reader.GetDecimal(2);
                        string  title      = reader.GetString(3);
                        int     categoryId = reader.GetInt32(4) - 1;

                        IExtraExpenseSpecification iExpSpec = new ExtraExpenseSpecification();
                        iExpSpec.Title        = title;
                        iExpSpec.Description  = name;
                        iExpSpec.Amount       = amount;
                        iExpSpec.PricePerUnit = price;

                        listOfExtraExpenses.Add(iExpSpec, (Category)categoryId);
                    }
                }
                reader.Close();
                reader.Dispose();
            }
            catch (SqlException)
            { }
            finally
            {
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            foreach (KeyValuePair <IExtraExpenseSpecification, Category> kvp in listOfExtraExpenses)
            {
                @case.GetExpenseCategory(kvp.Value).ExtraExpenses.Add(kvp.Key);
            }
        }
Beispiel #2
0
        public void PriceChangeOnUpdatedPriceOfMaterial()
        {
            ICase case1 = ObjectFactory.Instance.CreateNewCase();

            IExpenseCategory ec = case1.GetExpenseCategory(Comforthuse.Category.CarportGarage);

            IExtraExpenseSpecification ees = new ExtraExpenseSpecification();

            ees.PricePerUnit = 10;
            ees.Amount       = 1;
            ec.ExtraExpenses.Add(ees);

            Assert.AreEqual(10, case1.Price);

            ees.PricePerUnit = 20;
            Assert.AreEqual(20, case1.Price);
        }