/// <summary> /// Creates the specifed vehicle from user arguments /// </summary> /// <param name="args">List of user-inputted arguments</param> /// <returns></returns> private Entity CreateEntity(List <string> args) { // Generic repository has a M:1 with an entity parser // So we must manually cast the generic Repository<T, U> to access its custom entityParser properties FleetRepository fleetRepository = (FleetRepository)repository; return(fleetRepository.vehicleEntityParser.CreateEntity(args.ToArray())); }
public void GetByIdTestValidId() { FleetContext fleetContext = new FleetContext(); FleetRepository fleetRepository = new FleetRepository(fleetContext); var fleetFiles = fleetRepository.GetByID(1); Assert.IsTrue(fleetFiles.HeaderId == 1); }
public void GetByIdTestInvalidId() { FleetContext fleetContext = new FleetContext(); FleetRepository fleetRepository = new FleetRepository(fleetContext); var fleetFiles = fleetRepository.GetByID(3231); Assert.IsNull(fleetFiles); }
public void GetByIdTestValidId() { FleetContext fleetContext = new FleetContext(); FleetRepository fleetRepository = new FleetRepository(fleetContext); var fleetFiles = fleetRepository.GetByID(1); Assert.IsTrue(fleetFiles.HeaderId==1); }
/// <summary> /// Rents a vehicle based on user input /// </summary> /// <param name="args">List of user-input arguments</param> protected override void Execute(List <string> args) { // Setup variables int customerID = int.Parse(args[0]); string vehicleRego = args[1]; int days = int.Parse(args[2]); FleetRepository fleetRepository = (FleetRepository)repository; Fleet fleet = fleetRepository.Get(); CRM crm = crmRepository.Get(); // Resolve Vehicle vehicle = fleet.GetVehicle(vehicleRego); Customer customer = crm.GetCustomer(customerID); // Inform user of cost with lots of details Console.WriteLine("Rent {0} to {1} {2} (ID: {3}) for {4} days.", vehicle.vehicleRego, customer.firstName, customer.lastName, customer.ID, days); Console.WriteLine("This vehicle has a daily cost of ${0}, bringing the total to ${1:0.00}.", vehicle.dailyRate, (vehicle.dailyRate * days)); Console.WriteLine(); // Make user confirm rental at price string input = ""; do { Console.Write("Confirm you want to go ahead with this rental (y/n): "); input = Console.ReadLine().Trim().ToLower(); if (input == "y") { break; } if (input == "n") { return; } } while (input != "y" || input != "n"); // Let user know it was successful Console.WriteLine(); fleet.RentVehicle(vehicle.vehicleRego, customer.ID); Console.WriteLine("Successfully rented a {0} {1} {2} to {3} {4} (ID: {5})", vehicle.year, vehicle.make, vehicle.model, customer.firstName, customer.lastName, customer.ID); Console.WriteLine(); }
public FleetControllerTest() { this.CreateAppContext(); // Automapper initializers Mapper.AddProfile <FleetMappingProfile>(); Mapper.AddProfile <WidgetMappingProfile>(); // setting up the context and repositories this.FleetDbContext = this.CreateDbContext <FleetDbContext>(); FleetRepository fleetRepository = new FleetRepository(this.FleetDbContext); FleetDomain fleetDomain = new FleetDomain(fleetRepository); FleetDashboardDomain dashboardDomain = new FleetDashboardDomain(fleetRepository); this.WidgetDbContext = this.CreateDbContext <WidgetDbContext>(); WidgetRepository widgetRepository = new WidgetRepository(this.WidgetDbContext); WidgetDomain widgetDomain = new WidgetDomain(widgetRepository); this.Controller = new FleetController(fleetDomain, dashboardDomain, widgetDomain); }
public FleetControllerTest() { this.CreateAppContext(); // Automapper initializers Mapper.AddProfile<FleetMappingProfile>(); Mapper.AddProfile<WidgetMappingProfile>(); // setting up the context and repositories this.FleetDbContext = this.CreateDbContext<FleetDbContext>(); FleetRepository fleetRepository = new FleetRepository(this.FleetDbContext); FleetDomain fleetDomain = new FleetDomain(fleetRepository); FleetDashboardDomain dashboardDomain = new FleetDashboardDomain(fleetRepository); this.WidgetDbContext = this.CreateDbContext<WidgetDbContext>(); WidgetRepository widgetRepository = new WidgetRepository(this.WidgetDbContext); WidgetDomain widgetDomain = new WidgetDomain(widgetRepository); this.Controller = new FleetController(fleetDomain, dashboardDomain, widgetDomain); }
public FleetDomain(FleetRepository fleetRepository) { this.fleetRepository = fleetRepository; }
public AddVehicleHandler(FleetRepository repository) : base(repository) { }
public SearchVehicleHandler(FleetRepository repository) : base(repository) { }
public RentalTable(Menu parentMenu, FleetRepository fleetRepository) : base(parentMenu, fleetRepository) { }
public RentVehicleHandler(FleetRepository repository, CRMRepository crmRepository) : base(repository) { this.crmRepository = crmRepository; }
public ReturnVehicleHandler(FleetRepository repository) : base(repository) { }
public DeleteVehicleHandler(FleetRepository repository) : base(repository) { }
/// <summary> /// Pass the repository to the parent with improved type-hinting /// </summary> /// <param name="repository">Repository that corresponds with the expected repository for the entity</param> public RentalHandler(FleetRepository repository) : base(repository) { }
public EditCustomerHandler(CRMRepository repository, FleetRepository fleetRepository) : base(repository) { this.fleetRepository = fleetRepository; }
public FleetDashboardDomain(FleetRepository fleetRepository) { this.repository = fleetRepository; }
public SearchResultTable(Menu parentMenu, FleetRepository fleetRepository, List <Vehicle> results) : base(parentMenu, fleetRepository) { this.results = results; }
/// <summary> /// Creates new entity from passed arguments /// </summary> /// <param name="args">List of user-defined inputs</param> /// <returns>Newly created unpersisted vehicle</returns> private Vehicle CreateNewVehicle(List <string> args) { FleetRepository fleetRepository = (FleetRepository)repository; return((Vehicle)fleetRepository.vehicleEntityParser.CreateEntity(args.ToArray())); }