public ActionResult Search() { IEnumerable <Flight> flights = flightBL.DisplayFlight(); List <FlightModel> flightModels = new List <FlightModel>(); foreach (var flight in flights) { FlightModel flightModel = AutoMapper.Mapper.Map <Flight, FlightModel>(flight); //Auto Mapper entity to model flightModels.Add(flightModel); } TempData["flightsDisplay"] = flightModels; return(View()); }
public ActionResult EditClass(FlightTravelClassModel flightTravelClass) { IEnumerable <TravelClass> travelClass = flightBL.GetTravelClass(); ViewBag.ClassId = new SelectList(travelClass, "ClassId", "ClassName"); if (ModelState.IsValid) //condition pass when all the model state validation is true { FlightTravelClass edit = AutoMapper.Mapper.Map <FlightTravelClassModel, FlightTravelClass>(flightTravelClass); //Auto Mapper model to entity flightBL.EditClass(edit); return(RedirectToAction("DisplayFlight", "Flight")); } ViewBag.Flight_Id = new SelectList(flightBL.DisplayFlight(), "FlightId", "FlightName", flightTravelClass.FlightId); ViewBag.Class_Id = new SelectList(flightBL.GetTravelClass(), "ClassId", "ClassName", flightTravelClass.ClassId); return(View(flightTravelClass)); //Calling View for the Edit Class(when the ModelState is in valid) }
public ActionResult DisplayFlight() { IEnumerable <Flight> flights = flightBL.DisplayFlight(); IEnumerable <FlightTravelClass> flightTravelClasses = flightBL.GetFlightTravelClass(); IEnumerable <TravelClass> travelClasses = flightBL.GetTravelClass(); TempData["FlightTravelClass"] = flightTravelClasses; TempData["TravelClass"] = travelClasses; List <FlightModel> flightModels = new List <FlightModel>(); foreach (var flight in flights) { FlightModel flightModel = AutoMapper.Mapper.Map <Flight, FlightModel>(flight); //Auto Mapper entity to model flightModels.Add(flightModel); } return(View(flightModels)); //Calling View for the Display Flight }