public void PayrollTracker_DeleteButtonClickedEventHandler(object sender, EventArgs e) { BoardingRepository boardingRepository = new BoardingRepository(); foreach (KeyValuePair<int, Boarding> entry in deleteBoardingsMap) { Boarding boarding = entry.Value; if (boarding.BoardingId != null) { boardingRepository.Remove(boarding); } } deleteBoardingsMap = new Dictionary<int, Boarding>(); refreshDisplayFromDatabase(); }
private void DeleteInitialData() { IBoardingRepository boardingRepository = new BoardingRepository(); foreach (var boarding in _boardings) { Boarding fromDb = boardingRepository.GetById(boarding.BoardingId); if (fromDb != null) { boardingRepository.Remove(boarding); } } IUserRepository userRepository = new UserRepository(); userRepository.Remove(_user1); userRepository.Remove(_user2); IDogRepository dogRepository = new DogRepository(); dogRepository.Remove(_dog1); dogRepository.Remove(_dog2); ICostRepository costRepository = new CostRepository(); costRepository.Remove(_boardingCost); costRepository.Remove(_sundayDaycareCost); }
public void Can_add_new_boarding() { DateTime date = DateTime.Now; // Set the Milliseconds to 0 since MySQL DATETIME does not support milliseconds. date = DateTime.ParseExact(date.ToString(), "M/d/yyyy h:mm:ss tt", null); var boarding = new Boarding(date, true, _dog1, _boardingCost, _user1); IBoardingRepository repository = new BoardingRepository(); repository.Add(boarding); // use session to try to load the boarding using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<Boarding>(boarding.BoardingId); // Test that the boarding was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(boarding, fromDb); Assert.AreEqual(boarding.Date, fromDb.Date); Assert.AreEqual(boarding.IsDaycare, fromDb.IsDaycare); Assert.AreEqual(boarding.Dog, fromDb.Dog); Assert.AreEqual(boarding.BoardingCost, fromDb.BoardingCost); Assert.AreEqual(boarding.SundayDaycareCost, fromDb.SundayDaycareCost); Assert.AreEqual(boarding.User, fromDb.User); } repository.Remove(boarding); }
public void Can_remove_existing_boarding() { var boarding = _boardings[0]; IBoardingRepository repository = new BoardingRepository(); repository.Remove(boarding); using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<Boarding>(boarding.BoardingId); Assert.IsNull(fromDb); } }