コード例 #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);
        }
コード例 #4
0
        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
ファイル: FleetDomain.cs プロジェクト: Nootus/MegaMine
 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()));
        }