public void PayrollTracker_SaveButtonClickedEventHandler(object sender, EventArgs e) { BoardingRepository boardingRepository = new BoardingRepository(); foreach (KeyValuePair<int, Boarding> entry in dirtyBoardingsMap) { Boarding boarding = entry.Value; bool isValid = dataGridView1_RowValidating(entry.Key, boarding); if (isValid) { if (boarding.BoardingId == null) { boardingRepository.Add(boarding); } else { boardingRepository.Update(boarding); } dirtyBoardingsMap = new Dictionary<int, Boarding>(); refreshDisplayFromDatabase(); } } }
public void Can_update_existing_boarding() { var boarding = _boardings[1]; boarding.Tip = 30.00; IBoardingRepository repository = new BoardingRepository(); repository.Update(boarding); // use session to try to load the boarding using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<Boarding>(boarding.BoardingId); Assert.AreEqual(boarding.Tip, fromDb.Tip); } }