Exemplo n.º 1
0
        public bool RemoveIncome(DateTime date, decimal value)
        {
            errorMessage = "";
            int index = incomes.FindIndex(x => ((x.Date == date) && (x.Value == value)));

            if (index != -1)
            {
                incomes.RemoveAt(index);
                return(true);
            }
            else
            {
                errorMessage = messages[MESSAGE_INCOME_NOT_FOUND];
                return(false);
            }
        }
Exemplo n.º 2
0
        public bool RemoveExpense(DateTime date, decimal value)
        {
            errorMessage = "";
            int index = expenses.FindIndex(x => (x.Date == date) && (x.Value == value));

            if (index == -1)
            {
                errorMessage = messages[MESSAGE_EXPENSE_NOT_FOUND];
                return(false);
            }
            else
            {
                expenses.RemoveAt(index);
                return(true);
            }
        }
Exemplo n.º 3
0
        public Operations GetOperationsByArticle(DateTime?startDate, DateTime?endDate)
        {
            Operations items = GetOperationsByRange(startDate, endDate);

            items.Sort((x1, x2) => x1.Article.CompareTo(x2.Article));
            int i = 1;

            while (i < items.Count)
            {
                if (items[i - 1].Article == items[i].Article)
                {
                    items[i - 1].Value += items[i].Value;
                    items.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }
            return(items);
        }