public async Task <IActionResult> DeleteTicketItem(long id)
        {
            var ticketToDelete = _context.Find <TicketItem>(id);

            if (ticketToDelete == null)
            {
                return(NotFound());
            }

            _context.Remove(ticketToDelete);
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Esempio n. 2
0
        public void DeleteFlight_Deleted_True()
        {
            Ticket testTicket = new Ticket();
            int    ticketID   = 0;
            Flight flight     = new Flight
            {
                FlightID           = 25,
                FlightName         = FlightType.Boeing737,
                FlightDescription  = "Lot testowy",
                FlightDate         = new DateTime(2018, 6, 3),
                DestinationAirport = "Edinburgh",
                DepartureAirport   = "Radom"
            };
            var optionsBuilder = new DbContextOptionsBuilder <TicketContext>();

            optionsBuilder.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=Ticket-1;Trusted_Connection=True;MultipleActiveResultSets=true");
            TicketContext services = new TicketContext(optionsBuilder.Options);

            ticketID = flight.DeleteFlight();
            services.Find <Ticket>(ticketID);
            Assert.Null(testTicket.TicketDescription);
        }
Esempio n. 3
0
 public Ticket Find(int TicketId)
 {
     return(_context.Find <Ticket>(TicketId));
 }