public InputCategoryWindow(MainWindow _mainWindow, ExpensePage _expensePage, DateTime _date)
        {
            InitializeComponent();
            dbContext   = new MonnyDbContext();
            controller  = _mainWindow;
            expensePage = _expensePage;
            date        = _date;

            // Set ComboBox list Item with user's custom categories
            ExpenseRepository repository = new ExpenseRepository();
            // List where used custom categories ids are being saved
            List <int> usedId = new List <int>();

            foreach (Expense e in repository.GetItems())
            {
                // Checks if e is current user expense
                // e.CategoryId > 7 because custom categories have id greater than 7
                if (e.UserId == controller.user.Id && e.CategoryId > 7)
                {
                    // Check if category hasn't been used already
                    if (!usedId.Exists(i => i == e.CategoryId))
                    {
                        CategoryRepository categories = new CategoryRepository();
                        // Add category to ComboBox Items
                        customCategories.Items.Add(categories.GetItem(e.CategoryId).Name);

                        usedId.Add(e.CategoryId);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public InputWindow(MainWindow _mainWindow, ExpensePage _expensePage, string _category, DateTime _date)
 {
     InitializeComponent();
     //controller = _mainWindow;
     dbContext      = new MonnyDbContext();
     title.Content += _category;
     category       = _category;
     controller     = _mainWindow;
     expensePage    = _expensePage;
     date           = _date;
 }
Ejemplo n.º 3
0
        public InputWindow(MainWindow _mainWindow, ExpensePage _expensePage, string _category, DateTime _date)
        {
            InitializeComponent();

            categoryRepository = new CategoryRepository();
            expenseRepository  = new ExpenseRepository();

            title.Content += _category;
            category       = _category;
            controller     = _mainWindow;
            expensePage    = _expensePage;
            date           = _date;
        }