Exemplo n.º 1
0
 public ActionResult SearchByNumber(SearchByNumber search) //поиск рейса по номеру
 {
     if (ModelState.IsValid)
     {
         if (search.Number > 0 && flightMethods.Get(search.Number) != null)
         {
             if (User.IsInRole("admin"))
             {
                 return(RedirectToAction("More", "Admin", new { Id = flightMethods.Get(search.Number).Id }));
             }
             if (User.IsInRole("dispatcher"))
             {
                 return(RedirectToAction("More", "Dispatcher", new { Id = flightMethods.Get(search.Number).Id }));
             }
             if (User.IsInRole("user"))
             {
                 return(RedirectToAction("More", "Home", new { Id = flightMethods.Get(search.Number).Id }));
             }
             else
             {
                 return(RedirectToAction("SearchFailed", "Home"));
             }
         }
         else
         {
             return(RedirectToAction("SearchFailed", "Home"));
         }
     }
     else
     {
         return(RedirectToAction("SearchFailed", "Home"));
     }
 }
Exemplo n.º 2
0
 public ActionResult EditFlight(EditFlightViewModel _flight)
 {
     if (_flight.Id > 0)
     {
         if (_flight.Arraival > DateTime.Now && _flight.Departure > DateTime.Now && _flight.Price > 0 && _flight.Total > 0 &&
             _flight.Arraival >= _flight.Departure)
         {
             Flight flight = flightMethods.Get(_flight.Id);
             flight.Departure             = _flight.Departure;
             flight.Arrival               = _flight.Arraival;
             flight.FromCountry           = _flight.FromCountry;
             flight.FromCity              = _flight.FromCity;
             flight.ToCountry             = _flight.ToCountry;
             flight.ToCity                = _flight.ToCity;
             flight.Price                 = _flight.Price;
             flight.TotalNumberPassengers = _flight.Total;
             flightMethods.Edit(flight);
             logger.Info($"Edited fligth: Id: {flight.Id}, Departure: {flight.Departure.ToShortDateString()}, Arrival: {flight.Arrival.ToShortDateString()}, FCity: {flight.FromCity}," +
                         $"FCountry: {flight.FromCountry}, TCity: {flight.ToCity}, TCountry: {flight.ToCountry}, By: {HttpContext.User.Identity.Name}");
             return(RedirectToAction("AllFlights", "Admin"));
         }
         else
         {
             return(View(_flight));
         }
     }
     else
     {
         return(View("Error404"));
     }
 }
 public ActionResult AssignCrew(AssignCrewViewModel assign) //назначение экипажа на рейса
 {
     ViewBag.AllCrewMembers = crewMember.GetAll();
     if (ModelState.IsValid)
     {
         List <CrewMember> crew = new List <CrewMember>()
         {
             crewMember.Get((int)assign.PilotId),
             crewMember.Get((int)assign.NavigatorId),
             crewMember.Get((int)assign.RadioOperatorId),
             crewMember.Get((int)assign.StewardessId)
         };
         Flight flight = flightMethods.Get(assign.Id);
         flight.CrewMembers = crew;
         flightMethods.CrewAssigment(flight);
         logger.Info($"For Flight: Id: {flight.Id} assigned crew By: {HttpContext.User.Identity.Name}");
         return(RedirectToAction("DispatcherPanel", "Dispatcher"));
     }
     else
     {
         return(View(assign));
     }
 }