Exemple #1
0
        public IActionResult CreateNewVehicle(CreateVehicleViewModel input)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Carriers = SetCarriersToSelectListItems();

                return(this.View());
            }
            var vehicle = _carriersService.CreateNewVehicle(input.RegNumber, input.CarrierName);

            return(Redirect("/Nomenclatures/Vehicles"));
        }
Exemple #2
0
        public void CreateNewVehicle_works_Properly()
        {
            string errorMessagePrefix = "CarriersService CreateNewVehicle() method does not work properly.";

            var context = OilsProDbContextInMemoryFactory.InitializeContext();

            this.carriersService = new CarriersService(context);

            var carrier = new Carrier
            {
                Name = "Carrier1"
            };

            context.Carriers.Add(carrier);
            context.SaveChanges();

            var result = carriersService.CreateNewVehicle("RegNumber1", carrier.Name);

            Assert.True(context.Vehicles.Count() == 1);
            Assert.True(context.Vehicles.First().RegNumber == "RegNumber1");
        }