//Oppdaterer pris i partial view dynamisk public int UpdateDynamicPrice(int trav, int ret, int num) { int price = 0; var db = new DBWebApp(); price = db.getPrice(db.getFlights(((List <List <int> >)TempData["tids"])[trav])) * num; TempData.Keep("tids"); if (ret != -1) { price += db.getPrice(db.getFlights(((List <List <int> >)TempData["rids"])[ret])) * num; TempData.Keep("rids"); } return(price); }
public ActionResult pushDatabase(ViewModel incard) { var toPush = (ViewModel)TempData["toDataBase"]; toPush.cardInfo = incard.cardInfo; if (ModelState.IsValid) { var db = new DBWebApp(); bool pushOK = db.pushToDataBase(toPush); if (pushOK) { return(RedirectToAction("FinishedBooking")); } } return(RedirectToAction("Error")); }
//Hjelper til med å sette opp registrerings-viewet public void Helper(int travelID, int returnID) { var db = new DBWebApp(); ViewModel reg = new ViewModel(); reg.flight = new ViewFlight(); reg.booking = (ViewBooking)TempData["booking"]; reg.flight.travelIDs = (List <List <int> >)TempData["tids"]; reg.booking.chosenTravel = db.getFlights(reg.flight.travelIDs[travelID]); reg.booking.totalPrice = db.getPrice(reg.booking.chosenTravel) * reg.booking.travelers; if (returnID != -1) { reg.flight.returnIDs = (List <List <int> >)TempData["rids"]; reg.booking.chosenReturn = db.getFlights(reg.flight.returnIDs.ElementAt(returnID)); reg.booking.totalPrice += db.getPrice(reg.booking.chosenReturn) * reg.booking.travelers; } TempData["help"] = reg; }
public ActionResult ChooseFlight(ViewModel searchFlight) { if (ModelState.IsValid) { var db = new DBWebApp(); TempData["booking"] = searchFlight.booking; ViewModel search = new ViewModel(); search.flight = new ViewFlight(); search.travelflights = db.searchTravelFlights(searchFlight); TempData["tids"] = db.filterIDs(search.travelflights); if (searchFlight.booking.roundTrip) { search.returnflights = db.searchReturnFlight(searchFlight); TempData["rids"] = db.filterIDs(search.returnflights); } return(PartialView("FlightPartial", search)); } return(RedirectToAction("Error")); }