public TransferRequestByDateBLL() { RouteRepository = new RouteRepository(); BusTypeRepository = new BusTypeRepository(); AgencyRepository = new AgencyRepository(); RoleRepository = new RoleRepository(); BookingRepository = new BookingRepository(); BusByDateRepository = new BusByDateRepository(); BookingBusByDateRepository = new BookingBusByDateRepository(); LockingTransferRepository = new LockingTransferRepository(); ExpenseRepository = new ExpenseRepository(); ExpenseServiceRepository = new ExpenseServiceRepository(); CostTypeRepository = new CostTypeRepository(); GuideRepository = new GuideRepository(); }
public BookingReportBLL() { BookingRepository = new BookingRepository(); CruiseRepository = new CruiseRepository(); ExpenseRepository = new ExpenseRepository(); AgencyRepository = new AgencyRepository(); UserRepository = new UserRepository(); ExpenseHistoryRepository = new ExpenseHistoryRepository(); CostTypeRepository = new CostTypeRepository(); ExpenseServiceRepository = new ExpenseServiceRepository(); LockingExpenseRepository = new LockingExpenseRepository(); BookingHistoryRepository = new BookingHistoryRepository(); BookingRoomRepository = new BookingRoomRepository(); CustomerRepository = new CustomerRepository(); AgencyNotesRepository = new AgencyNotesRepository(); }
public void Can_add_new_costType() { var costType = new CostType ("test new cost name"); ICostTypeRepository repository = new CostTypeRepository(); repository.Add(costType); // use session to try to load the costType using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<CostType>(costType.CostTypeId); // Test that the costType was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(costType, fromDb); Assert.AreEqual(costType.CostName, fromDb.CostName); } repository.Remove(costType); }
private void DeleteInitialData() { ICostTypeRepository repository = new CostTypeRepository(); foreach (var costType in _costTypes) { CostType fromDb = repository.GetById(costType.CostTypeId); if (fromDb != null) { repository.Remove(costType); } } }
public void Can_update_existing_costType() { var costType = _costTypes[1]; costType.CostName = "test cost name update"; ICostTypeRepository repository = new CostTypeRepository(); repository.Update(costType); // use session to try to load the costType using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<CostType>(costType.CostTypeId); Assert.AreEqual(costType.CostName, fromDb.CostName); } }
public void Can_remove_existing_costType() { var costType = _costTypes[0]; ICostTypeRepository repository = new CostTypeRepository(); repository.Remove(costType); using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<CostType>(costType.CostTypeId); Assert.IsNull(fromDb); } }
public void Can_get_existing_costType_by_id() { ICostTypeRepository repository = new CostTypeRepository(); var fromDb = repository.GetById(_costTypes[1].CostTypeId); Assert.IsNotNull(fromDb); Assert.AreNotSame(_costTypes[1], fromDb); Assert.AreEqual(_costTypes[1].CostName, fromDb.CostName); }
public void DatabaseSetupInsertions_script() { CompanyRepository companyRepository = new CompanyRepository(); Company universityOfDoglando = new Company("University of Doglando"); Company groomGrubAndBellyRub = new Company("Groom, Grub & Belly Rub"); companyRepository.Add(universityOfDoglando); companyRepository.Add(groomGrubAndBellyRub); PayrollRepository payrollRepository = new PayrollRepository(); Payroll universityOfDoglandoPayroll = new Payroll(); universityOfDoglandoPayroll.Company = universityOfDoglando; universityOfDoglandoPayroll.PayrollNumberOfWeeks = 2; universityOfDoglandoPayroll.PayrollStartDate = new DateTime(2010, 11, 6); Payroll groomGrubAndBellyRubPayroll = new Payroll(); groomGrubAndBellyRubPayroll.Company = groomGrubAndBellyRub; groomGrubAndBellyRubPayroll.PayrollNumberOfWeeks = 2; groomGrubAndBellyRubPayroll.PayrollStartDate = new DateTime(2010, 11, 6); payrollRepository.Add(universityOfDoglandoPayroll); payrollRepository.Add(groomGrubAndBellyRubPayroll); RoleRepository roleRepository = new RoleRepository(); Role training = new Role("Training"); Role pickupDropoff = new Role("Pickup/Dropoff"); Role boarding = new Role("Boarding"); Role grooming = new Role("Grooming"); Role timeCard = new Role("Time Card"); Role administrator = new Role("Administrator"); Role addDog = new Role("Add Dog"); roleRepository.Add(training); roleRepository.Add(pickupDropoff); roleRepository.Add(boarding); roleRepository.Add(grooming); roleRepository.Add(timeCard); roleRepository.Add(administrator); roleRepository.Add(addDog); UserRepository userRepository = new UserRepository(); User teena = new User("teena", "teena123", "Teena", "Patel", DateTime.Now); User nim = new User("nim", "nim123", "Nim", "Patel", DateTime.Now); User jessica = new User("jessica", "jessica123", "Jessica", "Barajas", DateTime.Now); teena.AssignedRoles.Add(training); teena.AssignedRoles.Add(pickupDropoff); teena.AssignedRoles.Add(boarding); teena.AssignedRoles.Add(grooming); teena.AssignedRoles.Add(timeCard); teena.AssignedRoles.Add(administrator); teena.AssignedRoles.Add(addDog); teena.WorksForCompanies.Add(universityOfDoglando); teena.WorksForCompanies.Add(groomGrubAndBellyRub); nim.AssignedRoles.Add(training); nim.AssignedRoles.Add(pickupDropoff); nim.AssignedRoles.Add(boarding); nim.AssignedRoles.Add(grooming); nim.AssignedRoles.Add(timeCard); nim.AssignedRoles.Add(administrator); nim.AssignedRoles.Add(addDog); nim.WorksForCompanies.Add(universityOfDoglando); nim.WorksForCompanies.Add(groomGrubAndBellyRub); jessica.AssignedRoles.Add(training); jessica.AssignedRoles.Add(pickupDropoff); jessica.AssignedRoles.Add(boarding); jessica.AssignedRoles.Add(timeCard); jessica.AssignedRoles.Add(addDog); jessica.WorksForCompanies.Add(universityOfDoglando); userRepository.Add(teena); userRepository.Add(nim); userRepository.Add(jessica); CostTypeRepository costTypeRepository = new CostTypeRepository(); CostType costType1 = new CostType("Boarding - Rate"); CostType costType2 = new CostType("Boarding - Sunday Daycare"); CostType costType3 = new CostType("Daycare"); CostType costType4 = new CostType("PickupDropoff - Pickup"); CostType costType5 = new CostType("PickupDropoff - Dropoff"); CostType costType6 = new CostType("Training - Class - Pre K9"); CostType costType7 = new CostType("Training - Class - AA"); CostType costType8 = new CostType("Training - Class - BS"); CostType costType9 = new CostType("Training - Class - K9 Nose Work"); CostType costType10 = new CostType("Training - Class - Agility 1"); CostType costType11 = new CostType("Training - Class - Agility 2"); CostType costType12 = new CostType("Training - Pre-K9 Daycare"); //Boarding costs. CostRepository costRepository = new CostRepository(); Cost cost1 = new Cost(7); Cost cost2 = new Cost(10); costRepository.Add(cost1); costRepository.Add(cost2); List<Cost> possibleCosts1 = new List<Cost>(); possibleCosts1.Add(cost1); possibleCosts1.Add(cost2); costType1.PossibleCosts = possibleCosts1; costTypeRepository.Add(costType1); Cost cost3 = new Cost(15); costRepository.Add(cost3); List<Cost> possibleCosts2 = new List<Cost>(); possibleCosts2.Add(cost2); possibleCosts2.Add(cost3); costType2.PossibleCosts = possibleCosts2; costTypeRepository.Add(costType2); // Daycare costs. Cost cost4 = new Cost(20); Cost cost5 = new Cost(22); Cost cost6 = new Cost(25); Cost cost7 = new Cost(28); Cost cost8 = new Cost(30); Cost cost9 = new Cost(40); costRepository.Add(cost4); costRepository.Add(cost5); costRepository.Add(cost6); costRepository.Add(cost7); costRepository.Add(cost8); costRepository.Add(cost9); List<Cost> possibleCosts3 = new List<Cost>(); possibleCosts3.Add(cost4); possibleCosts3.Add(cost5); possibleCosts3.Add(cost6); possibleCosts3.Add(cost7); possibleCosts3.Add(cost8); possibleCosts3.Add(cost9); costType3.PossibleCosts = possibleCosts3; costTypeRepository.Add(costType3); //Pickup dropoff costs. Cost cost10 = new Cost(3); Cost cost11 = new Cost(5); costRepository.Add(cost10); costRepository.Add(cost11); List<Cost> possibleCosts4 = new List<Cost>(); possibleCosts4.Add(cost10); possibleCosts4.Add(cost11); costType4.PossibleCosts = possibleCosts4; costTypeRepository.Add(costType4); costType5.PossibleCosts = possibleCosts4; costTypeRepository.Add(costType5); //Training costs Cost cost12 = new Cost(60); Cost cost13 = new Cost(80); Cost cost14 = new Cost(100); Cost cost15 = new Cost(120); Cost cost16 = new Cost(160); costRepository.Add(cost12); costRepository.Add(cost13); costRepository.Add(cost14); costRepository.Add(cost15); costRepository.Add(cost16); List<Cost> possibleCosts6 = new List<Cost>(); possibleCosts6.Add(cost12); possibleCosts6.Add(cost13); possibleCosts6.Add(cost14); possibleCosts6.Add(cost15); possibleCosts6.Add(cost16); List<Cost> possibleCosts7 = new List<Cost>(); possibleCosts7.Add(cost12); possibleCosts7.Add(cost13); costType6.PossibleCosts = possibleCosts7; costTypeRepository.Add(costType6); costType7.PossibleCosts = possibleCosts6; costTypeRepository.Add(costType7); costType8.PossibleCosts = possibleCosts6; costTypeRepository.Add(costType8); costType9.PossibleCosts = possibleCosts6; costTypeRepository.Add(costType9); costType10.PossibleCosts = possibleCosts6; costTypeRepository.Add(costType10); costType11.PossibleCosts = possibleCosts6; costTypeRepository.Add(costType11); // - Pre K9 Daycare Costss List<Cost> possibleCosts8 = new List<Cost>(); possibleCosts8.Add(cost11); // $5 possibleCosts8.Add(cost2); // $10 costType12.PossibleCosts = possibleCosts8; costTypeRepository.Add(costType12); // Training Class Types // Add Grooming Types GroomingTypeRepository groomingTypeRepository = new GroomingTypeRepository(); GroomingType groomingType1 = new GroomingType("Bath"); GroomingType groomingType2 = new GroomingType("Nose and Ears"); GroomingType groomingType3 = new GroomingType("Mini Groom"); GroomingType groomingType4 = new GroomingType("Full Groom"); groomingTypeRepository.Add(groomingType1); groomingTypeRepository.Add(groomingType2); groomingTypeRepository.Add(groomingType3); groomingTypeRepository.Add(groomingType4); }
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.IsCurrentCellDirty) { if (dirtyObjectsMap.Keys.Contains(e.RowIndex)) { dirtyObjectsMap.Remove(e.RowIndex); } Training training = new Training(); DateTime date = (DateTime)dataGridView1.Rows[e.RowIndex].Cells["DateColumn"].Value; training.Date = date; string dogId = (string)dataGridView1.Rows[e.RowIndex].Cells["DogNameColumn"].Value; DogRepository dogRepository = new DogRepository(); if (dogId != null) { Dog dog = dogRepository.GetById(dogId); training.Dog = dog; } CostRepository costRepository = new CostRepository(); CostTypeRepository costTypeRepository = new CostTypeRepository(); string classTypeId = (string)dataGridView1.Rows[e.RowIndex].Cells["ClassColumn"].Value; if (classTypeId != null) { CostType costType = costTypeRepository.GetById(classTypeId); training.ClassType = costType; // If Class column value is Pre-K9, then enable Pre-K9 Daycare // Cost column. if (TRAINING_CLASS_PRE_K9.Equals(costType.CostName)) { DataGridViewComboBoxCell preK9DaycareComboBoxCell = (DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells["PreK9DaycareCostColumn"]; preK9DaycareComboBoxCell.ReadOnly = false; } else { DataGridViewComboBoxCell preK9DaycareComboBoxCell = (DataGridViewComboBoxCell)dataGridView1.Rows[e.RowIndex].Cells["PreK9DaycareCostColumn"]; preK9DaycareComboBoxCell.ReadOnly = true; } // Has Class column combobox value changed? if (e.ColumnIndex == 3) { // Yes, Class column value has changed, so update // Class Cost column combobox with appropriate // values for new Class. // Sort the costs. IList<Cost> possibleCosts1 = costType.PossibleCosts; ArrayList.Adapter((IList)possibleCosts1).Sort(); DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)(dataGridView1.Rows[e.RowIndex].Cells["CostOfClassColumn"]); // Now that a class type has been selected, we can populate // the cost of class drop down box appropriately. cell.Value = null; cell.DataSource = null; if (cell.Items != null) { cell.Items.Clear(); } cell.DataSource = possibleCosts1; cell.DisplayMember = "CostValue"; cell.ValueMember = "CostId"; } } string classCostId = (string)dataGridView1.Rows[e.RowIndex].Cells["CostOfClassColumn"].Value; if (classCostId != null) { Cost cost = costRepository.GetById(classCostId); training.ClassCost = cost; } string preK9DaycareCostId = (string)dataGridView1.Rows[e.RowIndex].Cells["PreK9DaycareCostColumn"].Value; if (preK9DaycareCostId != null) { Cost cost = costRepository.GetById(preK9DaycareCostId); training.PreK9DaycareCost = cost; } training.User = user; string trainingId = (string)dataGridView1.Rows[e.RowIndex].Cells["TrainingIdColumn"].Value; training.TrainingId = trainingId; // Add object to dirty objects map. if (!dirtyObjectsMap.Keys.Contains(e.RowIndex)) { dirtyObjectsMap.Add(e.RowIndex, training); } // Remove the entry from the delete map, if // an entry for the Daycare exists in the // delete map already. if (deleteObjectsMap.Keys.Contains(e.RowIndex)) { deleteObjectsMap.Remove(e.RowIndex); } var isSelected = dataGridView1.Rows[e.RowIndex].Cells["SelectColumn"].Value; if (isSelected != null && (bool)isSelected) { deleteObjectsMap.Add(e.RowIndex, training); } } }
public IQueryOver <CostType, CostType> CostTypeGetAll() { return(CostTypeRepository.CostTypeGetAll()); }
private void BoardingUserControl_Load(object sender, EventArgs e) { this.dataGridView1.AutoResizeRows(); DogRepository dogRepository = new DogRepository(); IList<Dog> dataSourceDogsList = dogRepository.GetAllDogs(); DogNameColumn.DataSource = dataSourceDogsList; DogNameColumn.DisplayMember = "FullName"; DogNameColumn.ValueMember = "DogId"; CostTypeRepository costTypeRepository = new CostTypeRepository(); CostType boardingRateCostType = costTypeRepository.GetByCostName(BOARDING_RATE_COST_TYPE); IList<Cost> possibleCosts1 = boardingRateCostType.PossibleCosts; ArrayList.Adapter((IList)possibleCosts1).Sort(); BoardingRateColumn.DataSource = possibleCosts1; BoardingRateColumn.DisplayMember = "CostValue"; BoardingRateColumn.ValueMember = "CostId"; CostType sundayDaycareCostType = costTypeRepository.GetByCostName(SUNDAY_DAYCARE_COST_TYPE); IList<Cost> possibleCosts2 = sundayDaycareCostType.PossibleCosts; ArrayList.Adapter((IList)possibleCosts2).Sort(); SundayDaycareColumn.DataSource = possibleCosts2; SundayDaycareColumn.DisplayMember = "CostValue"; SundayDaycareColumn.ValueMember = "CostId"; refreshDisplayFromDatabase(); }
public void Dispose() { if (BookingRepository != null) { BookingRepository.Dispose(); BookingRepository = null; } if (CruiseRepository != null) { CruiseRepository.Dispose(); CruiseRepository = null; } if (ExpenseRepository != null) { ExpenseRepository.Dispose(); ExpenseRepository = null; } if (AgencyRepository != null) { AgencyRepository.Dispose(); AgencyRepository = null; } if (UserRepository != null) { UserRepository.Dispose(); UserRepository = null; } if (ExpenseHistoryRepository != null) { ExpenseHistoryRepository.Dispose(); ExpenseHistoryRepository = null; } if (CostTypeRepository != null) { CostTypeRepository.Dispose(); CostTypeRepository = null; } if (ExpenseServiceRepository != null) { ExpenseServiceRepository.Dispose(); ExpenseServiceRepository = null; } if (LockingExpenseRepository != null) { LockingExpenseRepository.Dispose(); LockingExpenseRepository = null; } if (BookingHistoryRepository != null) { BookingHistoryRepository.Dispose(); BookingHistoryRepository = null; } if (BookingRoomRepository != null) { BookingRoomRepository.Dispose(); BookingRoomRepository = null; } if (CustomerRepository != null) { CustomerRepository.Dispose(); CustomerRepository = null; } if (AgencyNotesRepository != null) { AgencyNotesRepository.Dispose(); AgencyNotesRepository = null; } }
private void initializeDataGridComponentsDatasources() { DogRepository dogRepository = new DogRepository(); IList<Dog> dataSourceDogsList = dogRepository.GetAllDogs(); DogNameColumn.DataSource = dataSourceDogsList; DogNameColumn.DisplayMember = "FullName"; DogNameColumn.ValueMember = "DogId"; CostTypeRepository costTypeRepository = new CostTypeRepository(); IList<CostType> trainingCostTypes = costTypeRepository.GetAllSimilarCostTypes(CLASS_COST_TYPE); ClassColumn.DataSource = trainingCostTypes; ClassColumn.DisplayMember = "CostName"; ClassColumn.ValueMember = "CostTypeId"; CostType preK9DaycareCostType = costTypeRepository.GetByCostName(PRE_K9_DAYCARE_COST_TYPE); IList<Cost> possibleCosts1 = preK9DaycareCostType.PossibleCosts; ArrayList.Adapter((IList)possibleCosts1).Sort(); PreK9DaycareCostColumn.DataSource = possibleCosts1; PreK9DaycareCostColumn.DisplayMember = "CostValue"; PreK9DaycareCostColumn.ValueMember = "CostId"; CostOfClassColumn.DataSource = bindingSource; }
public void Can_add_new_cost_type_with_new_costs() { var costType = new CostType("new cost type"); ICostTypeRepository costTypeRepository = new CostTypeRepository(); costTypeRepository.Add(costType); var cost1 = new Cost(1000.11); var cost2 = new Cost(1500.11); ICostRepository costRepository = new CostRepository(); costRepository.Add(cost1); costRepository.Add(cost2); IList<Cost> possibleCosts = new List<Cost>(); possibleCosts.Add(cost1); possibleCosts.Add(cost2); costType.PossibleCosts = possibleCosts; costTypeRepository.Update(costType); // use session to try to load the cost type using (ISession session = _sessionFactory.OpenSession()) { var fromDb = session.Get<CostType>(costType.CostTypeId); // Test that the costType was successfully inserted Assert.IsNotNull(fromDb); Assert.AreNotSame(costType, fromDb); Assert.AreEqual(costType.CostName, fromDb.CostName); Assert.AreEqual(possibleCosts.Count, fromDb.PossibleCosts.Count); } costTypeRepository.Remove(costType); costRepository.Remove(cost1); costRepository.Remove(cost2); }
public void Dispose() { if (RouteRepository != null) { RouteRepository.Dispose(); RouteRepository = null; } if (BusTypeRepository != null) { BusTypeRepository.Dispose(); BusTypeRepository = null; } if (AgencyRepository != null) { AgencyRepository.Dispose(); AgencyRepository = null; } if (RoleRepository != null) { RoleRepository.Dispose(); RoleRepository = null; } if (BookingRepository != null) { BookingRepository.Dispose(); BookingRepository = null; } if (BusByDateRepository != null) { BusByDateRepository.Dispose(); BusByDateRepository = null; } if (BookingBusByDateRepository != null) { BookingBusByDateRepository.Dispose(); BookingBusByDateRepository = null; } if (LockingTransferRepository != null) { LockingTransferRepository.Dispose(); LockingTransferRepository = null; } if (ExpenseRepository != null) { ExpenseRepository.Dispose(); ExpenseRepository = null; } if (ExpenseServiceRepository != null) { ExpenseServiceRepository.Dispose(); ExpenseServiceRepository = null; } if (CostTypeRepository != null) { CostTypeRepository.Dispose(); CostTypeRepository = null; } if (GuideRepository != null) { GuideRepository.Dispose(); GuideRepository = null; } }
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); }
private void initializeDataGridComponentsDatasources() { DogRepository dogRepository = new DogRepository(); IList<Dog> dataSourceDogsList = dogRepository.GetAllDogs(); DogNameColumn.DataSource = dataSourceDogsList; DogNameColumn.DisplayMember = "FullName"; DogNameColumn.ValueMember = "DogId"; CostTypeRepository costTypeRepository = new CostTypeRepository(); CostType pickupCostType = costTypeRepository.GetByCostName(PICKUP_COST_TYPE); IList<Cost> possibleCosts1 = pickupCostType.PossibleCosts; ArrayList.Adapter((IList)possibleCosts1).Sort(); PickupCostColumn.DataSource = possibleCosts1; PickupCostColumn.DisplayMember = "CostValue"; PickupCostColumn.ValueMember = "CostId"; CostType dropoffCostType = costTypeRepository.GetByCostName(DROPOFF_COST_TYPE); IList<Cost> possibleCosts2 = dropoffCostType.PossibleCosts; ArrayList.Adapter((IList)possibleCosts2).Sort(); DropoffCostColumn.DataSource = possibleCosts2; DropoffCostColumn.DisplayMember = "CostValue"; DropoffCostColumn.ValueMember = "CostId"; }