Esempio n. 1
0
        public IActionResult EditIncludedVehicle(string id)
        {
            var carrier = _carriersService.GetCarrierByVehicleId(id);
            var vehicle = carrier.Vehicles.FirstOrDefault(x => x.Id == id);

            return(this.View(vehicle));
        }
Esempio n. 2
0
        public void GetCarrierByVehicleId_works_Properly()
        {
            string errorMessagePrefix = "CarriersService GetCarrierByVehicleId() method does not work properly.";

            var context = OilsProDbContextInMemoryFactory.InitializeContext();

            this.carriersService = new CarriersService(context);

            var carrier = new Carrier
            {
                Name     = "Carrier1",
                Vehicles = new List <Vehicle>
                {
                    new Vehicle()
                    {
                        RegNumber = "RegNumber1"
                    },
                }
            };

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

            var vehicleId = context.Vehicles.First().Id;

            var result   = carriersService.GetCarrierByVehicleId(vehicleId);
            var expected = carrier;

            Assert.AreEqual(expected, result, errorMessagePrefix);
        }