コード例 #1
0
        public async Task <IActionResult> Create([Bind("Name")] Terminal terminal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(terminal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(terminal));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("OrderId,Date")] Order order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(order));
        }
コード例 #3
0
        public async Task <IActionResult> Create([Bind("DestinationId,Name,Language,CurrencyValue")] Destination destination)
        {
            if (ModelState.IsValid)
            {
                _context.Add(destination);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(destination));
        }
コード例 #4
0
        public async Task <IActionResult> Create([Bind("SeatId")] Seat seat)
        {
            if (ModelState.IsValid)
            {
                _context.Add(seat);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(seat));
        }
コード例 #5
0
        public async Task <IActionResult> Create([Bind("Passport,Mail,Name,Country,Address,Phone,DateOfBirth")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customer));
        }
コード例 #6
0
        public async Task <IActionResult> Create([Bind("TicketNumber,LandingDate,TakeOffTime")] Ticket ticket)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ticket);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ticket));
        }
コード例 #7
0
        public async Task <IActionResult> Create([Bind("PlaneId,Name,NumberOfSeats")] Plane plane)
        {
            if (ModelState.IsValid)
            {
                _context.Add(plane);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(plane));
        }
コード例 #8
0
        public async Task <IActionResult> Create([Bind("Name,ExtraPrice")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("FlightNumber,TakeOff,Landing,Price")] Flight flight)
        {
            if (ModelState.IsValid)
            {
                _context.Add(flight);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(flight));
        }
コード例 #10
0
        public async Task <IActionResult> Create([Bind("PlaneId,DepartmentName")] PlaneDepartment planeDepartment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(planeDepartment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentName"] = new SelectList(_context.Department, "Name", "Name", planeDepartment.DepartmentName);
            ViewData["PlaneId"]        = new SelectList(_context.Plane, "PlaneId", "PlaneId", planeDepartment.PlaneId);
            return(View(planeDepartment));
        }
コード例 #11
0
        public static void Main(string[] args)
        {
            var host = BuildWebHost(args);


            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                FlyHighContext context = services.GetRequiredService <FlyHighContext>();

                if (context.Flight.Count() == 0)
                {
                    for (int i = 0; i < 20; i++)
                    {
                        context.Add(new Flight());
                    }
                    context.SaveChanges();
                }
            }

            host.Run();
        }