Ejemplo n.º 1
0
        public void UpdateFlight()
        {
            // This test checks if the repository is able of updating an entity
            // that was updated outside of the repository (for example,
            // an updated entity sent to the service)

            // The instance created here has the same values as the DB entity
            Flight flight = new Flight {
                FlightId = 3, FlightNumber = "BY002"
            };

            // Update the flight number
            flight.FlightNumber = "BY002_updated";

            //TODO: Lab 02 Exercise 2, Task 4.1 : Implement the UpdateFlight Method
            FlightRepository repository;

            using (repository = new FlightRepository())
            {
                repository.Edit(flight);
                repository.Save();
            }

            using (repository = new FlightRepository())
            {
                Flight updatedFlight = repository.FindBy(f => f.FlightNumber == "BY002_updated").FirstOrDefault();
                Assert.IsNotNull(updatedFlight);
            }
        }
Ejemplo n.º 2
0
        internal Flight Edit(Flight editFlight)
        {
            Flight original = Get(editFlight.Id);


            original.Destination = editFlight.Destination != null ? editFlight.Destination : original.Destination;
            original.Price       = editFlight.Price != null ? editFlight.Price : original.Price;

            return(_repo.Edit(original));
        }
Ejemplo n.º 3
0
        internal Flight Edit(Flight editFlight)
        {
            Flight original = Get(editFlight.Id);

            original.Title       = editFlight.Title != null ? editFlight.Title : original.Title;
            original.Description = editFlight.Description != null ? editFlight.Description : original.Description;
            original.Price       = editFlight.Price > 0 ? editFlight.Price : original.Price;

            return(_repo.Edit(original));
        }