private void BtnMainWindow_Clicked(object sender, RoutedEventArgs e) { // saves data into csv file _csvWriter.Flush(); Button button = sender as Button; rep = Repository.GetInstance(); Member selectedCd = (Member)lbxCds.SelectedItem; // new member if (button.Name.Equals("btnNew")) { AddMemberWindow addMemberWindow = new AddMemberWindow(); addMemberWindow.ShowDialog(); } else { // Database--- using (var db = new ClubMemberContext()) { if (selectedCd == null) { MessageBox.Show("Wählen Sie einen Mitglied!"); } else { // delete member if (button.Name.Equals("btnDel")) { rep.RemoveCd(selectedCd); // Delete-------------------------- MessageBox.Show("Lösche Mitglied aus der Datenbank"); db.Remove(selectedCd); db.SaveChanges(); //--------------------------------- } // edit member else if (button.Name.Equals("btnEdit")) { AddMemberWindow addMemberWindow = new AddMemberWindow(selectedCd); addMemberWindow.ShowDialog(); } } } } _members = rep.GetAllMembers(); lbxCds.ItemsSource = _members; }
private void BtnSave_Clicked(object sender, RoutedEventArgs e) { if (_memberToEdit == null) { Repository.GetInstance().AddMember(newCd); _line = new List <string> { newCd.Name, newCd.Email, newCd.Phone }; // if member is new one, will be appended into csv file _csvWriter = new CsvWriter(path, ";"); _csvWriter.Write(_line.ElementAt(0), _line.ElementAt(1), _line.ElementAt(2)); _csvWriter.Flush(); // Database-------------------------------------- using (var db = new ClubMemberContext()) { // Create MessageBox.Show("Ein neues Mitglied einfügen"); db.Add(newCd); db.SaveChanges(); //--------------------------------------------- } } else { Repository.GetInstance().UpdateCd(_memberToEdit, newCd); // Database------------------------------------ using (var db = new ClubMemberContext()) { // Update MessageBox.Show("Mitglied aktualisieren"); db.Update(_memberToEdit); db.SaveChanges(); } //---------------------------------------------- } Close(); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { using (var db = new ClubMemberContext()) { rep = Repository.GetInstance(); _members = rep.GetAllMembers(); lbxCds.ItemsSource = _members; // prints members data to csv file _csvWriter = new CsvWriter(path, ";"); for (int i = 0; i < _members.Count; i++) { _csvWriter.Write ( _members.ElementAt(i).Name, _members.ElementAt(i).Email, _members.ElementAt(i).Phone ); // db.Add(_members.ElementAt(i)); } // Read and save into database db.AttachRange(_members); db.SaveChanges(); } }
public ClubMemberMutations(ClubMemberContext context, IEventService template1EventService, IMapper mapper, IAuthorizationService authorizationService) : base(authorizationService) { _context = context ?? throw new ArgumentNullException(nameof(context));; _eventService = template1EventService ?? throw new ArgumentNullException(nameof(template1EventService)); _mapper = mapper; }
public SignUpSubscriptionSuccessEventConsumer(ClubMemberContext context, IMapper mapper, IEventService eventService) { _context = context; _mapper = mapper; _eventService = eventService; }
public UnitOfWork() { _dbContext = new ClubMemberContext(); PersonRepository = new PersonRepository(_dbContext); }
public ClubMemberQueries(ClubMemberContext context) { _context = context; }