public void LoadData(Guid selectId) { var users = UserBusiness.GetList(); var payments = PaymentBusiness.GetList(); Models = CreateUsersModel(users, payments); if (Models.Count > 0) { var model = Models.FirstOrDefault(x => x.Id == selectId); SelectedItem = model ?? Models[0]; } else { AddNewVisibility = Visibility.Visible; } //Create new item NewItem = new UserModel(); NewItem.Id = Guid.NewGuid(); }
public void LoadData(Guid selectId) { var fullUsers = UserBusiness.GetList(); if (fullUsers == null || fullUsers.Count == 0) { //MessageBox.Show("Please input users to the app", "Group Shared", MessageBoxButton.OK, // MessageBoxImage.Information); OpenUserListCommandExecute(); return; } //Load payments var payments = PaymentBusiness.GetList(); Models = CreatePaymentModel(payments, fullUsers); if (Models.Count > 0) { var model = Models.FirstOrDefault(x => x.Id == selectId); SelectedItem = model ?? Models[0]; } else { AddNewVisibility = Visibility.Visible; } //Create new item NewItem = new PaymentModel(); NewItem.Id = Guid.NewGuid(); NewItem.Date = DateTime.Today; NewItem.Users = new ObservableCollection <UserModel>(fullUsers.Select(x => new UserModel { Id = x.Id, Name = x.Name, IsSpent = false })); }