public Family(FamilyOrganizerContext familyOrganizerContext, AppUser currentUser) { InitializeComponent(); _context = familyOrganizerContext; _currentUser = currentUser; usersList.ItemsSource = _context.AppUsers.Local.ToBindingList().Where(u => u.Id != _currentUser.Id); }
public Diary(FamilyOrganizerContext familyOrganizerContext, AppUser currentUser) { InitializeComponent(); _context = familyOrganizerContext; _currentUser = currentUser; TaskListRoutine.ItemsSource = _context.TodayPlans.Local.ToBindingList().Where(p => p.IsRoutine == true && _currentUser.Id == p.UserId); TasksList.ItemsSource = _context.TodayPlans.Local.ToBindingList().Where(p => p.IsAdded == true && _currentUser.Id == p.UserId); }
public Register(FamilyOrganizerContext context, bool ToMainWindow = false) { InitializeComponent(); _context = context; _toMainWindow = ToMainWindow; if (_context.AppUsers.Count() == 0) { ParentWithCheckBox.Visibility = Visibility.Hidden; } }
public ShoppingList(FamilyOrganizerContext context, AppUser currentUser) { InitializeComponent(); _context = context; _currentUser = currentUser; ShoppingListUnapproved.ItemsSource = _context.ShoppingPlans.Local.ToBindingList().Where(p => !p.Accepted); ShoppingListApproved.ItemsSource = _context.ShoppingPlans.Local.ToBindingList().Where(p => p.Accepted); }
public static void SeedBalances(FamilyOrganizerContext context) { if (context.Balances.Any()) { return; } var balancesJson = (File.ReadAllText(@".\DB\Seed\BalancesSeed.json")); var balances = JsonSerializer.Deserialize <IEnumerable <Balance> >(balancesJson); context.Balances.AddRange(balances); context.SaveChanges(); }
public static void SeedTransactions(FamilyOrganizerContext context) { if (context.Transactions.Any()) { return; } var transactionsJson = (File.ReadAllText(@".\DB\Seed\TransactionsSeed.json")); var transactions = JsonSerializer.Deserialize <IEnumerable <Transaction> >(transactionsJson); context.Transactions.AddRange(transactions); context.SaveChanges(); }
private async void DeleteUser_Click(object sender, RoutedEventArgs e) { var currentUser = DataContext as AppUser; if (_context == null) { var a = VisualTreeHelper.GetParent(this); while (!(a is Family)) { a = VisualTreeHelper.GetParent(a); } _context = (a as Family)._context; } if (!await _context.AppUsers.AnyAsync(u => u.Id == currentUser.Id)) { return; } _context.AppUsers.Remove(currentUser); var currentBalance = await _context.AppUsers.Where(u => u.UserName != currentUser.UserName).SumAsync(u => u.Balance); var currentBalanceEntry = await _context.Balances.OrderByDescending(b => b.Date).FirstOrDefaultAsync(); if (currentBalanceEntry == null) { currentBalanceEntry = new Balance { CurrentBalance = 0, Date = DateTime.Now } } ; if (currentBalanceEntry.Date.Day == DateTime.Now.Day && _context.Balances.Count() > 0) { _context.Balances.Remove(currentBalanceEntry); } _context.Balances.Add(new Balance { Date = DateTime.Now, CurrentBalance = currentBalance }); await _context.SaveChangesAsync(); var mb = new FamilyOrganizerMessageBox("Refresh the page to see the changes"); mb.Show(); }
public General(FamilyOrganizerContext familyOrganizerContext, AppUser currentUser) { InitializeComponent(); _context = familyOrganizerContext; _currentUser = currentUser; commentsList.ItemsSource = _context.Comments.Local.ToBindingList(); WelcomeLabel.Content = _currentUser.UserName; ProfileImage.DataContext = _currentUser; Role.Content = _currentUser.Role; Balance.Content = currentUser.Balance; Comments.ScrollToEnd(); }
public MainWindow(FamilyOrganizerContext familyOrganizerContext, AppUser currentUser) { InitializeComponent(); _context = familyOrganizerContext; _currentUser = currentUser; DataContext = _context.AppUsers.Local.ToBindingList(); LV.SelectedIndex = 0; if (_currentUser.Role != "Parent") { FamilyTab.Visibility = Visibility.Collapsed; StatsTab.Visibility = Visibility.Collapsed; } }
public AddTransaction(FamilyOrganizerContext context, AppUser currentUser) { InitializeComponent(); _context = context; _currentUser = currentUser; ToUser.ItemsSource = _context.AppUsers.Where(u => u.UserName != _currentUser.UserName) .Select(u => u.UserName).ToList(); if (_context.AppUsers.Count() <= 1) { TransferItem.IsEnabled = false; } if (_currentUser.Role == "Child") { DepositItem.IsEnabled = false; } }
public Edit(FamilyOrganizerContext familyOrganizerContext, AppUser currentUser) { InitializeComponent(); _context = familyOrganizerContext; _currentUser = currentUser; BitmapImage icon = new BitmapImage(); icon.BeginInit(); icon.UriSource = new Uri(_currentUser.Photo.Source, UriKind.Relative); icon.EndInit(); ProfileAvatar.Source = icon; PhotoId = _currentUser.PhotoId; TextBoxCurrentUsername.Text = _currentUser.UserName; }
public Money(FamilyOrganizerContext familyOrganizerContext, AppUser currentUser) { InitializeComponent(); _context = familyOrganizerContext; _currentUser = currentUser; YearComboBox.ItemsSource = _context.Transactions.Select(b => b.Date.Year).Distinct() .ToList(); MonthComboBox.ItemsSource = _context.Transactions.Select(b => b.Date.Month).Distinct() .ToList(); YearComboBox.SelectedIndex = 0; MonthComboBox.SelectedIndex = 0; SelectTransactions(); }
public Statistics(FamilyOrganizerContext familyOrganizerContext, AppUser currentUser) { InitializeComponent(); _context = familyOrganizerContext; _currentUser = currentUser; YearComboBox.ItemsSource = _context.Balances.Select(b => b.Date.Year).Distinct() .ToList(); MonthComboBox.ItemsSource = _context.Balances.Select(b => b.Date.Month).Distinct() .ToList(); YearComboBox.SelectedIndex = 0; MonthComboBox.SelectedIndex = 0; Chart(); PieChart(); DataContext = this; }
private async void AddMoney_Click(object sender, RoutedEventArgs e) { var currentUser = DataContext as AppUser; if (_context == null) { var a = VisualTreeHelper.GetParent(this); while (!(a is Family)) { a = VisualTreeHelper.GetParent(a); } _context = (a as Family)._context; } if (!await _context.AppUsers.AnyAsync(u => u.Id == currentUser.Id)) { return; } AddMoneyAdmin ama = new AddMoneyAdmin(_context, currentUser); ama.Show(); }
public AddMoneyAdmin(FamilyOrganizerContext context, AppUser currentUser) { InitializeComponent(); _context = context; _currentUser = currentUser; }
public Login(FamilyOrganizerContext context) { InitializeComponent(); this.context = context; }
protected override async void OnStartup(StartupEventArgs e) { try { if (mutex.WaitOne(0)) { mutexAccessed = true; } } catch (AbandonedMutexException) { mutexAccessed = true; } if (mutexAccessed) { base.OnStartup(e); } else { MessageBox.Show("FamilyOrganizer is running"); Shutdown(); return; } var ss = new SplashScreen(); ss.Show(); Context = new FamilyOrganizerContext(); await Context.Photos.LoadAsync(); await Context.AppUsers.LoadAsync(); await Context.Transactions.LoadAsync(); await Context.Balances.LoadAsync(); await Context.Comments.LoadAsync(); await Context.ShoppingPlans.LoadAsync(); await Context.TodayPlans.LoadAsync(); //Seed.SeedTransactions(Context); //Seed.SeedBalances(Context); //Seed.SeedPhotos(Context); if (Context.AppUsers.Count() == 0) { var r = new Register(Context, true); r.Show(); } else { var l = new Login(Context); l.Show(); } ss.Close(); }