Example #1
0
        public void OnGetPrice()
        {
            // Gets the TempData["Passengers"] to compute bill baggage.
            var strPassengers = TempData.Peek("Passengers") as string;
            var passengers    = JsonConvert.DeserializeObject <List <Passenger> >(strPassengers);

            // Gets the TempData["ChosenService"] to compute the total price in PriceInfo.
            var strChosenService = TempData.Peek("ChosenService") as string;
            var chosenService    = System.Text.Json.JsonSerializer.Deserialize <Model.FlightService>(strChosenService);

            this.FlightNumber = chosenService.FsId;

            this.AirlineProvider = this._context.GetAirline(chosenService.AirlineCode).Name;

            // To display what things are billed.
            this.CabinBagCount   = BookingInfo.GetCabinBagTotal(passengers);
            this.CheckedBagCount = BookingInfo.GetCheckedBagTotal(passengers);

            this.PriceInfo = new PriceInfo();

            this.PriceInfo.Passengers  = this.PriceInfo.CalcPassenger(passengers);
            this.PriceInfo.CabinBags   = BaggagePrice.Calc(BookingInfo.GetCabinBagTotal(passengers));
            this.PriceInfo.CheckedBags = BaggagePrice.Calc(BookingInfo.GetCheckedBagTotal(passengers));
            this.PriceInfo.TotalPrice  = this.PriceInfo.SetTotalPrice(chosenService);

            // Processes the bill of bags of a respective passenger.
            var billBaggage = PriceInfo.CalcBaggage(passengers);

            //TempData["BillBaggage"] = JsonSerializer.Serialize(billBaggage);
            TempData["BillBaggage"] = JsonConvert.SerializeObject(billBaggage);
            TempData["PriceInfo"]   = System.Text.Json.JsonSerializer.Serialize(this.PriceInfo);
        }