示例#1
0
        /// <summary>GetVehicleDetailsById
        /// CreatedBy   :   Roshan Rahood
        /// CreatedOn   :   Jan-06-2015
        /// CreatedFor  :   Get the Vehicle details by Id.
        /// </summary>
        /// <returns></returns>
        public VehicleRegistrationModel GetVehicleDetailsById(long vehicleId)
        {
            try
            {
                VehicleRegistrationModel objVehicleRegistrationModel = objworkorderEMSEntities.VehicleRegistrations.Where(g => g.VehicleID == vehicleId && g.IsDeleted == false).OrderBy(code => code.VehicleID).Select(s => new VehicleRegistrationModel()
                {
                    VehicleIdentificationNo = s.VehicleIdentificationNo,
                    VehicleMake             = s.VehicleMake,
                    VehicleType             = s.VehicleType,
                    CreatedBy           = s.CreatedBy,
                    IsApprovedByClient  = s.IsApprovedByClient,
                    IsApprovedByManager = s.IsApprovedByManager,
                    VehicleID           = vehicleId,
                    VehicleModel        = s.VehicleModel,
                    VehicleTagNo        = s.VehicleTagNo,
                    DriverName          = s.DriverName,
                    LicenseNo           = s.LicenseNo,
                    PermitTypePrice     = s.PermitTypePrice,
                    VendorUserID        = s.VendorUserID,
                    QRCID = s.QRCID
                }).SingleOrDefault();

                return(objVehicleRegistrationModel);
            }
            catch (Exception)
            { throw; }
        }
示例#2
0
        public void AddVehiclesThatMeetRequirements()
        {
            var car = new VehicleRegistrationModel
            {
                TeamName            = "Test1",
                VehicleType         = VehicleType.Car,
                Make                = "Test",
                Model               = "Test",
                IsTowStrapAvailable = true,
                LiftingHeight       = 0,
                TireWear            = 0,
                Year                = DateTime.Now.Year
            };

            var truck = new VehicleRegistrationModel
            {
                TeamName            = "Test2",
                VehicleType         = VehicleType.Truck,
                Make                = "Test",
                Model               = "Test",
                IsTowStrapAvailable = true,
                LiftingHeight       = 0,
                TireWear            = 0,
                Year                = DateTime.Now.Year
            };

            var fakeRepository = A.Fake <IRepository <Vehicle> >();
            var vehicleService = new VehicleService(fakeRepository);
            var controller     = new RaceManagementController(vehicleService);

            controller.Create(car);
            controller.Create(truck);

            A.CallTo(() => fakeRepository.Add(A <Vehicle> ._)).MustHaveHappenedTwiceExactly();
        }
        public ActionResult Create(VehicleRegistrationModel vehicle)
        {
            var validationResult = service.ValidateVehicle(vehicle);

            if (ModelState.IsValid && validationResult.IsSuccess)
            {
                service.AddVehicle(vehicle);
                return(RedirectToAction(nameof(Index)));
            }

            foreach (var item in validationResult.Errors)
            {
                ModelState.AddModelError(item.Name, item.Message);
            }

            return(View(vehicle));
        }
示例#4
0
        public void AddVehicleWithoutTowStrap()
        {
            var car = new VehicleRegistrationModel
            {
                TeamName            = "Test",
                VehicleType         = VehicleType.Car,
                Make                = "Test",
                Model               = "Test",
                IsTowStrapAvailable = false,
                LiftingHeight       = 0,
                TireWear            = 0,
                Year                = DateTime.Now.Year
            };

            var fakeRepository = A.Fake <IRepository <Vehicle> >();
            var vehicleService = new VehicleService(fakeRepository);
            var controller     = new RaceManagementController(vehicleService);

            controller.Create(car);

            A.CallTo(() => fakeRepository.Add(A <Vehicle> ._)).MustNotHaveHappened();
        }