public void PayrollTracker_DeleteButtonClickedEventHandler(object sender, EventArgs e) { TrainingRepository repository = new TrainingRepository(); foreach (KeyValuePair<int, Training> entry in deleteObjectsMap) { Training training = entry.Value; if (training.TrainingId != null) { repository.Remove(training); } } deleteObjectsMap = new Dictionary<int, Training>(); refreshDisplayFromDatabase(); }
public void Can_add_new_training() { 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 training = new Training(date, _classType, _classCost, _dog1, _user1); ITrainingRepository repository = new TrainingRepository(); repository.Add(training); // use session to try to load the training using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<Training>(training.TrainingId); // Test that the training was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(training, fromDb); Assert.AreEqual(training.Date, fromDb.Date); Assert.AreEqual(training.Dog, fromDb.Dog); Assert.AreEqual(training.User, fromDb.User); Assert.AreEqual(training.ClassType, fromDb.ClassType); Assert.AreEqual(training.ClassCost, fromDb.ClassCost); Assert.AreEqual(training.PreK9DaycareCost, fromDb.PreK9DaycareCost); } repository.Remove(training); }
private void DeleteInitialData() { ITrainingRepository trainingRepository = new TrainingRepository(); foreach (var training in _trainings) { Training fromDb = trainingRepository.GetById(training.TrainingId); if (fromDb != null) { trainingRepository.Remove(training); } } 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(_classCost); costRepository.Remove(_preK9DaycareCost); costRepository.Remove(_newClassCost); ICostTypeRepository costTypeRepository = new CostTypeRepository(); costTypeRepository.Remove(_classType); }
public void Can_remove_existing_training() { var training = _trainings[0]; ITrainingRepository repository = new TrainingRepository(); repository.Remove(training); using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<Training>(training.TrainingId); Assert.IsNull(fromDb); } }