Esempio n. 1
0
        public ProposalDocumentViewModel ProposalDocumentData()
        {
            string QRFID = Request.Query["QRFId"];
            ProposalDocumentViewModel model = new ProposalDocumentViewModel();

            if (!string.IsNullOrEmpty(QRFID))
            {
                try
                {
                    #region fetching all data from service
                    COProviders      objCOProvider      = new COProviders(_configuration);
                    QuoteAgentGetReq objQRFAgentRequest = new QuoteAgentGetReq()
                    {
                        QRFID = QRFID
                    };
                    ProposalDocumentGetRes objProposalRes = objCOProvider.GetProposalDocumentDetailsByQRFID(objQRFAgentRequest, token).Result;
                    model.COHeaderViewModel   = COCommonLibrary.GetProposalDocumentHeaderDetails(QRFID, Request, Response, token);
                    model.Itinerary           = objProposalRes.Itinerary;
                    model.Proposal            = objProposalRes.Proposal;
                    model.QRFQuote            = objProposalRes.QRFQuote;
                    model.ProductImages       = objProposalRes.ProductImages;
                    model.GenericImages       = objProposalRes.GenericImages;
                    model.CountryImageInitial = _configuration.GetValue <string>("SystemSettings:CountryImageInitial");
                    model.URLinitial          = model.COHeaderViewModel.URLinitial = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.Value;
                    model.RoutingCities.AddRange(objProposalRes.Itinerary.ItineraryDays.Select(a => a.City + "," + a.Country));
                    model.RoutingCities.AddRange(objProposalRes.Itinerary.ItineraryDays.Select(a => a.ToCityName + "," + a.ToCountryName));
                    model.RoutingCities = model.RoutingCities.Distinct().ToList();
                    model.RoutingCities.RemoveAll(a => string.IsNullOrEmpty(a) || a == ",");
                    model.Itinerary.ItineraryDays.ForEach(a => a.Hotel = a.Hotel.Where(b => b.IsDeleted == false).ToList());
                    model.Itinerary.ItineraryDays.ForEach(a => a.Meal  = a.Meal.Where(b => b.IsDeleted == false).ToList());

                    if (model.Proposal != null && model.Proposal.ProposalIncludeRegions == null)
                    {
                        model.Proposal.ProposalIncludeRegions = new ProposalIncludeRegions();
                    }
                    #endregion

                    #region creating dates list for date range
                    DateTime date; string month;
                    var      list = new List <ProposalDepartDate>();
                    foreach (var item in model.QRFQuote.Departures.OrderBy(a => a.Date))
                    {
                        date  = Convert.ToDateTime(item.Date);
                        month = date.ToString("MMMM");
                        list.Add(new ProposalDepartDate {
                            Day = date.Day.ToString(), Month = month, Year = date.Year.ToString()
                        });
                    }
                    var list2 = new List <ProposalDepartDate>();
                    foreach (var item in list)
                    {
                        month = item.Month + " " + item.Year;
                        if (list2.Where(a => a.Month == month).Count() > 0)
                        {
                            list2.Where(a => a.Month == month).FirstOrDefault().Day += (", " + item.Day);
                        }
                        else
                        {
                            list2.Add(new ProposalDepartDate {
                                Month = month, Day = item.Day
                            });
                        }
                    }
                    model.DatesList = list2;
                    #endregion

                    #region google maps section
                    StaticMap._configuration = _configuration;
                    //GeocoderLocation geocoder = StaticMap.Locate(model.QRFQuote.AgentProductInfo.Destination.Split('|')[1]);
                    string mapURL = "https://maps.googleapis.com/maps/api/staticmap?center={0}&zoom=3&size=233x206&maptype=roadmap&key=GoogleAPIKey&markers=color:red|label:AA|{0}";
                    mapURL = string.Format(mapURL, model.QRFQuote.AgentProductInfo.Destination.Split('|')[1]);
                    if (StaticMap.RenderImage(mapURL, QRFID + "_ProposalDocument_smallmap.png", out string output))
                    {
                        model.SmallMapURL = output;
                    }

                    mapURL = "https://maps.googleapis.com/maps/api/staticmap?size=773x682&maptype=roadmap&key=GoogleAPIKey";
                    foreach (string city in model.RoutingCities)
                    {
                        //geocoder = StaticMap.Locate(city);
                        mapURL += "&markers=color:red|label:AA|{0}";
                        mapURL  = string.Format(mapURL, city);
                    }
                    if (StaticMap.RenderImage(mapURL, QRFID + "_ProposalDocument_bigmap.png", out output))
                    {
                        model.BigMapURL = output;
                    }

                    string ProdId = "";
                    for (int i = 0; i < model.Itinerary.ItineraryDays.Count; i++)
                    {
                        for (int j = 0; j < model.Itinerary.ItineraryDays[i].Hotel.Count; j++)
                        {
                            if (!string.IsNullOrEmpty(model.Itinerary.ItineraryDays[i].Hotel[j].Lat) && !string.IsNullOrEmpty(model.Itinerary.ItineraryDays[i].Hotel[j].Long) &&
                                model.Itinerary.ItineraryDays[i].Hotel[j].IsDeleted == false)
                            {
                                ProdId  = !string.IsNullOrEmpty(model.Itinerary.ItineraryDays[i].Hotel[j].HotelId) ? model.Itinerary.ItineraryDays[i].Hotel[j].HotelId : model.Itinerary.ItineraryDays[i].Hotel[j].PositionId;
                                mapURL  = "https://maps.googleapis.com/maps/api/staticmap?zoom=10&size=284x191&maptype=roadmap&key=GoogleAPIKey";
                                mapURL += "&markers=color:red|label:AA|{0},{1}";
                                mapURL  = string.Format(mapURL, model.Itinerary.ItineraryDays[i].Hotel[j].Lat, model.Itinerary.ItineraryDays[i].Hotel[j].Long);
                                if (StaticMap.RenderImage(mapURL, ProdId + "_ProposalDocument_hotelmap.png", out output))
                                {
                                    model.Itinerary.ItineraryDays[i].Hotel[j].HotelMapURL = output;
                                }
                            }
                        }
                    }
                    #endregion

                    #region Proposal Terms
                    string templatePath = _configuration.GetValue <string>("Pages:ProposalTermsTemplate");
                    var    pathToFile   = Path.Combine(Directory.GetCurrentDirectory(), templatePath);
                    var    builder      = new StringBuilder();
                    using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
                    {
                        builder.Append(SourceReader.ReadToEnd());
                        model.Proposal.Terms += Environment.NewLine + builder.ToString();
                    }
                    #endregion

                    #region fetching hotel images from expedia

                    string HotelMapImage;
                    List <ArrProductResources> HotelRes = new List <ArrProductResources>();
                    foreach (var days in model.Itinerary.ItineraryDays)
                    {
                        foreach (var hotel in days.Hotel)
                        {
                            if (hotel.ProdResources != null)
                            {
                                HotelRes = hotel.ProdResources.Where(a => a.ResourceType == "Image").OrderBy(a => a.OrderNr).ToList();
                            }
                            if (hotel.ProdResources == null || HotelRes == null || HotelRes.Count < 1 || (HotelRes.Count > 0 && string.IsNullOrEmpty(HotelRes[0].ImageSRC)))
                            {
                                if (StaticMap.RenderExpediaImage(hotel.HotelCode, ProdId + "_ProposalDocument_hotelimage.png", out output))
                                {
                                    HotelMapImage = output;
                                }
                            }
                        }
                    }

                    #endregion

                    #region replacing image urls from resources to ImageResources

                    foreach (var ItineraryDay in model.Itinerary.ItineraryDays)
                    {
                        if (ItineraryDay.Hotel != null)
                        {
                            foreach (var Hotel in ItineraryDay.Hotel)
                            {
                                if (Hotel.ProdResources != null)
                                {
                                    foreach (var ProdResource in Hotel.ProdResources)
                                    {
                                        if (ProdResource.ImageSRC != null)
                                        {
                                            ProdResource.ImageSRC = ProdResource.ImageSRC.Replace("resources/", "ImageResources/");
                                        }
                                    }
                                }
                            }
                        }
                    }
                    #endregion

                    #region Get Hotel Summary details from Itinerary

                    ProposalGetReq req = new ProposalGetReq();
                    ProposalGetRes res = new ProposalGetRes();
                    req.QRFID = QRFID;
                    res       = objCOProvider.GetHotelSummaryByQrfId(req, token).Result;
                    var hotellist = res.Hotels;
                    model.HotelList = hotellist.Select(x => new Hotel {
                        HotelName = x.HotelName, Location = string.IsNullOrWhiteSpace(x.Location) ? "" : x.Location.Split(',')[0], Stars = x.Stars, Duration = x.Duration
                    }).ToList();

                    #endregion
                }
                catch (Exception ex)
                {
                    throw;
                    //Console.WriteLine(ex.Message);
                }
            }
            return(model);
        }
Esempio n. 2
0
        public bool GetProposalPriceBreakupByQRFId(IConfiguration _configuration, string token, ref ProposalViewModel model, string QRFID)
        {
            #region Get Costsheet by QRFId
            CostsheetGetReq request  = new CostsheetGetReq();
            CostsheetGetRes response = new CostsheetGetRes();
            request.QRFID = QRFID;
            //request.DepartureId = filterByDeparture == 0 ? objDepartureDatesRes.DepartureDates[0].Departure_Id : filterByDeparture;
            response = coProviders.GetCostsheet(request, token).Result;
            #endregion

            #region Price breakup data binding
            List <QRFPkgAndNonPkgPrice> lstDepartureDates         = new List <QRFPkgAndNonPkgPrice>();
            List <QRFPkgAndNonPkgPrice> lstTwinPkg                = new List <QRFPkgAndNonPkgPrice>();
            List <QRFPkgAndNonPkgPrice> lstDoublePkg              = new List <QRFPkgAndNonPkgPrice>();
            List <QRFPkgAndNonPkgPrice> lstSinglePkg              = new List <QRFPkgAndNonPkgPrice>();
            List <QRFPkgAndNonPkgPrice> lstPositionTypeSupplement = new List <QRFPkgAndNonPkgPrice>();
            List <QRFPkgAndNonPkgPrice> lstPositionTypeOptional   = new List <QRFPkgAndNonPkgPrice>();
            List <QRFPkgAndNonPkgPrice> lstNonPkgSupplement       = new List <QRFPkgAndNonPkgPrice>();
            List <QRFPkgAndNonPkgPrice> lstNonPkgOptional         = new List <QRFPkgAndNonPkgPrice>();

            foreach (var date in response.QrfPackagePrice)
            {
                if (lstDepartureDates.Where(x => x.DepartureId == date.Departure_Id).Count() <= 0)
                {
                    lstDepartureDates.Add(new QRFPkgAndNonPkgPrice {
                        DepartureDate = date.DepartureDate, DepartureId = date.Departure_Id, PaxSlabId = date.PaxSlab_Id, PaxSlab = date.PaxSlab
                    });
                }
            }

            var twinrooms   = new List <mQRFPackagePrice>();
            var doublerooms = new List <mQRFPackagePrice>();
            var singlerooms = new List <mQRFPackagePrice>();

            twinrooms = response.QrfPackagePrice.Where(x => x.RoomName.ToUpper() == "TWIN").ToList();
            if (twinrooms.Count() <= 0)
            {
                doublerooms = response.QrfPackagePrice.Where(x => x.RoomName.ToUpper() == "DOUBLE").ToList();
                if (doublerooms.Count() <= 0)
                {
                    singlerooms = response.QrfPackagePrice.Where(x => x.RoomName.ToUpper() == "SINGLE").ToList();
                }
            }

            if (twinrooms.Count() > 0)
            {
                foreach (var pkg in twinrooms)
                {
                    lstTwinPkg.Add(new QRFPkgAndNonPkgPrice {
                        SellPrice = pkg.SellPrice, QRFCurrency = pkg.QRFCurrency.Substring(0, 3).ToUpper(), PaxSlabId = pkg.PaxSlab_Id, PaxSlab = pkg.PaxSlab, RoomName = pkg.RoomName, DepartureDate = pkg.DepartureDate, DepartureId = pkg.Departure_Id
                    });
                }
            }

            if (doublerooms.Count() > 0)
            {
                foreach (var pkg in doublerooms)
                {
                    lstDoublePkg.Add(new QRFPkgAndNonPkgPrice {
                        SellPrice = pkg.SellPrice, QRFCurrency = pkg.QRFCurrency.Substring(0, 3).ToUpper(), PaxSlabId = pkg.PaxSlab_Id, PaxSlab = pkg.PaxSlab, RoomName = pkg.RoomName, DepartureDate = pkg.DepartureDate, DepartureId = pkg.Departure_Id
                    });
                }
            }

            if (singlerooms.Count() > 0)
            {
                foreach (var pkg in singlerooms)
                {
                    lstSinglePkg.Add(new QRFPkgAndNonPkgPrice {
                        SellPrice = pkg.SellPrice, QRFCurrency = pkg.QRFCurrency.Substring(0, 3).ToUpper(), PaxSlabId = pkg.PaxSlab_Id, PaxSlab = pkg.PaxSlab, RoomName = pkg.RoomName, DepartureDate = pkg.DepartureDate, DepartureId = pkg.Departure_Id
                    });
                }
            }

            //#region QRFNonPkgPrice Position Bindings
            //foreach (var a in response.QrfNonPackagePrice.Where(x => x.PositionKeepAs.ToUpper() == "SUPPLEMENT"))
            //{
            //    if (lstPositionTypeSupplement.Where(x => x.PositionId == a.PositionId).Count() <= 0)
            //    {
            //        lstPositionTypeSupplement.Add(new QRFPkgAndNonPkgPrice { PaxSlabId = a.PaxSlab_Id, PaxSlab = a.PaxSlab, SellPrice = a.SellPrice, RoomName = a.RoomName, PositionKeepAs = a.PositionKeepAs, PositionType = a.PositionType, PositionId = a.PositionId, ProductName = a.ProductName, DepartureDate = a.DepartureDate, DepartureId = a.Departure_Id });
            //    }
            //}

            //foreach (var a in response.QrfNonPackagePrice.Where(x => x.PositionKeepAs.ToUpper() == "OPTIONAL"))
            //{
            //    if (lstPositionTypeOptional.Where(x => x.PositionId == a.PositionId).Count() <= 0)
            //    {
            //        lstPositionTypeOptional.Add(new QRFPkgAndNonPkgPrice { PaxSlabId = a.PaxSlab_Id, PaxSlab = a.PaxSlab, SellPrice = a.SellPrice, RoomName = a.RoomName, PositionKeepAs = a.PositionKeepAs, PositionType = a.PositionType, PositionId = a.PositionId, ProductName = a.ProductName, DepartureDate = a.DepartureDate, DepartureId = a.Departure_Id });
            //    }
            //}
            //#endregion

            foreach (var nonpkg in response.QrfNonPackagePrice)
            {
                if (nonpkg.RoomName.ToUpper() == "ADULT" && nonpkg.PositionKeepAs.ToUpper() == "SUPPLEMENT")
                {
                    lstNonPkgSupplement.Add(new QRFPkgAndNonPkgPrice {
                        SellPrice = nonpkg.SellPrice, QRFCurrency = nonpkg.QRFCurrency.Substring(0, 3).ToUpper(), PaxSlabId = nonpkg.PaxSlab_Id, PaxSlab = nonpkg.PaxSlab, RoomName = nonpkg.RoomName, DepartureDate = nonpkg.DepartureDate, DepartureId = nonpkg.Departure_Id, PositionId = nonpkg.PositionId, PositionType = nonpkg.PositionType, ProductName = nonpkg.ProductName
                    });
                }
            }

            foreach (var nonpkg in response.QrfNonPackagePrice)
            {
                if (nonpkg.RoomName.ToUpper() == "ADULT" && nonpkg.PositionKeepAs.ToUpper() == "OPTIONAL")
                {
                    lstNonPkgOptional.Add(new QRFPkgAndNonPkgPrice {
                        SellPrice = nonpkg.SellPrice, QRFCurrency = nonpkg.QRFCurrency.Substring(0, 3).ToUpper(), PaxSlabId = nonpkg.PaxSlab_Id, PaxSlab = nonpkg.PaxSlab, RoomName = nonpkg.RoomName, DepartureDate = nonpkg.DepartureDate, DepartureId = nonpkg.Departure_Id, PositionId = nonpkg.PositionId, PositionType = nonpkg.PositionType, ProductName = nonpkg.ProductName
                    });
                }
            }

            model.ProposalPriceBreakupViewModel.DepartureDatesList    = lstDepartureDates.OrderBy(x => x.DepartureDate).ToList();
            model.ProposalPriceBreakupViewModel.QrfTwinPkgPriceList   = lstTwinPkg;
            model.ProposalPriceBreakupViewModel.QrfDoublePkgPriceList = lstDoublePkg;
            model.ProposalPriceBreakupViewModel.QrfSinglePkgPriceList = lstSinglePkg;
            //model.ProposalPriceBreakupViewModel.QRFNonPkgSupplementPositions = lstPositionTypeSupplement;
            //model.ProposalPriceBreakupViewModel.QRFNonPkgOptionalPositions = lstPositionTypeOptional;
            model.ProposalPriceBreakupViewModel.QrfNonPkgPriceSupplementList = lstNonPkgSupplement;
            model.ProposalPriceBreakupViewModel.QrfNonPkgPriceOptionalList   = lstNonPkgOptional;

            #region Get Costing Officer Tour Info Header By QRFId
            NewQuoteViewModel modelQuote = new NewQuoteViewModel();
            modelQuote.QRFID = QRFID;
            model.ProposalPriceBreakupViewModel.COHeaderViewModel = cOCommonLibrary.GetCOTourInfoHeader(ref modelQuote, token);
            #endregion

            #region Get Hotel Summary details from Itinerary

            ProposalGetReq req = new ProposalGetReq();
            ProposalGetRes res = new ProposalGetRes();

            req.QRFID = model.QRFID;
            res       = coProviders.GetHotelSummaryByQrfId(req, token).Result;
            var hotellist = res.Hotels;
            model.ProposalPriceBreakupViewModel.HotelList = hotellist.Select(x => new Hotel {
                HotelName = x.HotelName, Location = string.IsNullOrWhiteSpace(x.Location) ? "" : x.Location.Split(',')[0], Stars = x.Stars, Duration = x.Duration
            }).ToList();

            #endregion

            #endregion

            return(true);
        }