public ActionResult EditCrew(AssignCrewViewModel assign) { ViewBag.AllCrewMembers = crewMember.GetAll(); Flight flight = flightMethods.Get(assign.Id); flight.CrewMembers.Clear(); flightMethods.Edit(flight); 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.CrewMembers = crew; flightMethods.CrewAssigment(flight); logger.Info($"Flight Id: {flight.Id} crew edited By: {HttpContext.User.Identity.Name}"); return(RedirectToAction("DispatcherPanel", "Dispatcher")); } else { return(View(assign)); } }
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 Book(int id) //бронирование рейса для пользователя { try { int profileId = ProfileMethods.GetByEmail(User.Identity.Name); Profile profile = ProfileMethods.Get(profileId); Flight flight = flightMethods.Get(id); if (profile.Name != null && profile.Surname != null && profile.PassportID != null && profile.Birth != null && profile.Email != null && flight.TotalNumberPassengers != flight.CurrentNumberPassengers) { if (!profile.Flights.Contains(flight)) { List <Flight> flights = new List <Flight>() { flight }; profile.Flights = flights; ProfileMethods.Edit(profile); flight.CurrentNumberPassengers++; flightMethods.Edit(flight); return(RedirectToAction("UserBooking", "Home")); } else { return(RedirectToAction("UserBooking", "Home")); } } else { return(RedirectToAction("FillProfile", "Home")); } } catch (Exception) { return(RedirectToAction("FillProfile", "Home")); } }