Пример #1
0
        /// <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()));
        }
Пример #2
0
        public void GetByIdTestValidId()
        {
            FleetContext fleetContext = new FleetContext();

            FleetRepository fleetRepository = new FleetRepository(fleetContext);

            var fleetFiles = fleetRepository.GetByID(1);

            Assert.IsTrue(fleetFiles.HeaderId == 1);
        }
Пример #3
0
        public void GetByIdTestInvalidId()
        {
            FleetContext fleetContext = new FleetContext();

            FleetRepository fleetRepository = new FleetRepository(fleetContext);

            var fleetFiles = fleetRepository.GetByID(3231);

            Assert.IsNull(fleetFiles);
        }
        public void GetByIdTestInvalidId()
        {
            FleetContext fleetContext = new FleetContext();

            FleetRepository fleetRepository = new FleetRepository(fleetContext);

            var fleetFiles = fleetRepository.GetByID(3231);

            Assert.IsNull(fleetFiles);
        }
Пример #5
0
        public void GetByIdTestValidId()
        {
            FleetContext fleetContext = new FleetContext();

            FleetRepository fleetRepository = new FleetRepository(fleetContext);

               var fleetFiles =  fleetRepository.GetByID(1);

               Assert.IsTrue(fleetFiles.HeaderId==1);
        }
Пример #6
0
        /// <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();
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
 public FleetDomain(FleetRepository fleetRepository)
 {
     this.fleetRepository = fleetRepository;
 }
Пример #10
0
 public AddVehicleHandler(FleetRepository repository) : base(repository)
 {
 }
Пример #11
0
 public SearchVehicleHandler(FleetRepository repository) : base(repository)
 {
 }
Пример #12
0
 public RentalTable(Menu parentMenu, FleetRepository fleetRepository) : base(parentMenu, fleetRepository)
 {
 }
Пример #13
0
 public RentVehicleHandler(FleetRepository repository, CRMRepository crmRepository) : base(repository)
 {
     this.crmRepository = crmRepository;
 }
Пример #14
0
 public ReturnVehicleHandler(FleetRepository repository) : base(repository)
 {
 }
Пример #15
0
 public DeleteVehicleHandler(FleetRepository repository) : base(repository)
 {
 }
Пример #16
0
 /// <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)
 {
 }
Пример #17
0
 public FleetDomain(FleetRepository fleetRepository)
 {
     this.fleetRepository = fleetRepository;
 }
Пример #18
0
 public EditCustomerHandler(CRMRepository repository, FleetRepository fleetRepository) : base(repository)
 {
     this.fleetRepository = fleetRepository;
 }
Пример #19
0
 public FleetDashboardDomain(FleetRepository fleetRepository)
 {
     this.repository = fleetRepository;
 }
Пример #20
0
 public SearchResultTable(Menu parentMenu, FleetRepository fleetRepository, List <Vehicle> results) : base(parentMenu, fleetRepository)
 {
     this.results = results;
 }
Пример #21
0
        /// <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()));
        }