Exemple #1
0
        public void DeleteTest()
        {
            //Arrange
            List <Flight> flights = new List <Flight>();
            var           flight1 = new Flight()
            {
                LocationFrom = "Lviv", LocationTo = "Kyiv"
            };
            var flight2 = new Flight()
            {
                LocationFrom = "Lviv", LocationTo = "Odesa"
            };

            flights.Add(flight1);
            flights.Add(flight2);

            //Act
            flightMockRepository.Setup(x => x.GetAll()).Returns(flights);
            flightMockRepository.Setup(x => x.Delete(flight1.Id.ToString()));
            mapper.Setup(x => x.Map <Flight>(flight1)).Returns(flight1);

            flightService.Delete(flight1.Id);


            //Assert
            Assert.Null(flightService.Get(flight1.Id));
        }
        public IActionResult EditTicket(int id)
        {
            var ticket     = _ticketService.Get(id);
            var flight     = _flightService.Get(ticket.FlightID);
            var viewTicket = new TicketViewModel()
            {
                Id    = ticket.Id,
                Price = ticket.Price,
                FlightArrivingDate   = flight.FlightArrivingDate,
                FlightDepartmentDate = flight.FlightDepartmentDate,
                LocationFrom         = flight.LocationFrom,
                LocationTo           = flight.LocationTo,
                Type     = ticket.Type,
                FlightId = flight.Id
            };

            return(View(viewTicket));
        }