Example #1
0
        // GET: Users/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            UsersController.CheckIfLoginAndManager(this, _context);

            if (ViewBag.IsManager == null || !ViewBag.IsManager)
            {
                return(Unauthorized());
            }

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

            var user = await _context.User.FindAsync(id);

            if (user == null)
            {
                return(NotFound());
            }
            return(View(user));
        }
Example #2
0
        public async Task <IActionResult> MostSoldFlightsView()
        {
            UsersController.CheckIfLoginAndManager(this, _context);

            // Keep the searched variables
            if (TempData["date"] != null)
            {
                ViewBag.date = TempData["date"].ToString();
            }
            if (TempData["from"] != null)
            {
                ViewBag.from = TempData["from"].ToString();
            }
            if (TempData["to"] != null)
            {
                ViewBag.to = TempData["to"].ToString();
            }
            if (TempData["maxPrice"] != null)
            {
                ViewBag.maxPrice = Convert.ToInt32(TempData["maxPrice"]);
            }

            return(View(await _context.Ticket.Include(ticket => ticket.Flight)
                        .ThenInclude(Flight => Flight.Airplane)
                        .Include(ticket => ticket.Flight)
                        .ThenInclude(Flight => Flight.SourceAirport)
                        .Include(ticket => ticket.Flight)
                        .ThenInclude(Flight => Flight.DestAirport)
                        .Where(ticket => (ticket.Buyer != null))
                        .GroupBy(ticket => ticket.Flight)
                        .Select(o => new SoldFlightsView
            {
                Flight = o.Key,
                TicketsSold = o.Count()
            })
                        .OrderByDescending(o => o.TicketsSold)
                        .ToListAsync()));
        }
Example #3
0
        // GET: Airports/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            UsersController.CheckIfLoginAndManager(this, _context);

            if (ViewBag.IsManager == null || !ViewBag.IsManager)
            {
                return(Unauthorized());
            }

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

            var airport = await _context.Airport
                          .FirstOrDefaultAsync(m => m.ID == id);

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

            return(View(airport));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Country,City,Longitude,Latitude,Acronyms")] Airport airport)
        {
            UsersController.CheckIfLoginAndManager(this, _context);

            if (ViewBag.IsManager == null || !ViewBag.IsManager)
            {
                return(Unauthorized());
            }

            if (id != airport.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(airport);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AirportExists(airport.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(airport));
        }
Example #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,UserName,Password,FirstName,LastName,Age,Email,IsManager")] User user)
        {
            UsersController.CheckIfLoginAndManager(this, _context);

            if (ViewBag.IsManager == null || !ViewBag.IsManager)
            {
                return(Unauthorized());
            }

            if (id != user.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Example #6
0
        // GET: Orders/MoreInfo/*id*
        public async Task <IActionResult> MoreInfo(int?id)
        {
            UsersController.CheckIfLoginAndManager(this, _context);

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

            var selectedTicket = await _context.Ticket.Include(ticket => ticket.Flight)
                                 .ThenInclude(Flight => Flight.Airplane)
                                 .Include(ticket => ticket.Flight)
                                 .ThenInclude(Flight => Flight.SourceAirport)
                                 .Include(ticket => ticket.Flight)
                                 .ThenInclude(Flight => Flight.DestAirport)
                                 .FirstOrDefaultAsync(m => m.Id == id);

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

            return(View(selectedTicket));
        }
Example #7
0
 public IActionResult Privacy()
 {
     UsersController.CheckIfLoginAndManager(this, _context);
     return(View());
 }
Example #8
0
 public IActionResult Index()
 {
     UsersController.CheckIfLoginAndManager(this, _context);
     return(View(_context.Airport.ToList()));
 }
Example #9
0
 public ActionResult FailedLogout()
 {
     UsersController.CheckIfLoginAndManager(this, _context);
     return(View("FailedLogout"));
 }