Ejemplo n.º 1
0
        private string LoadCarts()
        {
            var cartsStored = _fm.LoadCarts();

            if (cartsStored == null)
            {
                return("");
            }
            if (cartsStored.Element("Corrupted") != null)
            {
                return("Carts Could not be Loaded");
            }
            var cartsXml = cartsStored.Elements();

            foreach (var cart in cartsXml)
            {
                var specificCart = new Cart();
                var cartName     = (string)cart.Element("CartName");
                specificCart.ChangeName(cartName);
                var expenses    = cart.Element("Expenses");
                var allExpenses = expenses.Elements();
                foreach (var expense in allExpenses)
                {
                    var cartExpense = new CartExpense(
                        (string)expense.Element("Name"),
                        (double)expense.Element("Amount"),
                        (string)expense.Element("Category")
                        );
                    specificCart.AddExpense(cartExpense);
                }
                _carts.Add(specificCart);
            }
            return("Carts Loaded");
        }
Ejemplo n.º 2
0
        public void AddExpenseToCart(CurrentInfoHolder cih)
        {
            var expense = new CartExpense(cih.CurrentName, double.Parse(cih.CurrentAmout), cih.CurrentCategory);

            _currentCart.AddExpense(expense);
        }