Exemple #1
0
        // GET: Requests/Create //id is roomid likibu
        public async Task <ActionResult> Create(string id, string thumb, string Location)
        {
            try
            {
                //load Offer from Likibu SearchSession
                if (User != null)
                {
                    TravelerProfile tp = await ProfileManager.LoadUserAndTravelerProfile(User);

                    TravelerProfileSearchSession searchsession = tp.SearchSession; ///searchsession comes here fom view? any has to be saved in loaded TravelerProfile
                    tp = await ProfilesController.LoadProfile(tp.ID);

                    tp.SearchSession = searchsession;
                    Models.Accommodation.Likibu.AccomodationDetailsParam para    = new Models.Accommodation.Likibu.AccomodationDetailsParam(tp.Attributes.Language, tp.Attributes.Currency, tp.SearchSession.CheckIn, tp.SearchSession.CheckOut);
                    Models.Accommodation.Likibu.AccomodationDetails      details = await Likibu.LikibuAccess.RequestAccomodationDetails(para, id);

                    Models.Request.RequestVMOwner requestVM = new Models.Request.RequestVMOwner(details.offer.Destination, details.offer.BedRooms, details.offer.PriceNight, details.offer.PriceWeek, details.offer.PriceMonth, details.offer.Lat, details.offer.Lng, tp.SearchSession.CheckIn, tp.SearchSession.CheckOut, id, tp.Attributes.Currency, thumb);

                    requestVM.Location = Location;
                    requestVM.Thumbs   = Models.Accommodation.Likibu.Offer.StringToArray(thumb).ToList();


                    return(View(requestVM));
                }
                return(View());
            }
            catch (Exception e)
            {
                NotificationManager.AddException(e);
                NotificationManager.AddNotification(NotificationType.Error, "Oops, something went wrong!");
                return(View());
            }
        }
Exemple #2
0
        private async Task <Models.Accommodation.Likibu.AccomodationDetails> GetAcomodationDetails(string lang, string cur, string chIn, string chOut, string roomID)
        {
            Models.Accommodation.Likibu.AccomodationDetailsParam reqParam = new Models.Accommodation.Likibu.AccomodationDetailsParam(lang, cur, chIn, chOut);
            Models.Accommodation.Likibu.AccomodationDetails      result   = await Likibu.LikibuAccess.RequestAccomodationDetails(reqParam, roomID);

            return(result);
        }
Exemple #3
0
        private async Task <Models.Accommodation.Likibu.AccomodationDetails> GetAcomodationDetails(Models.Find.SearchVM searchVM, string roomID)
        {
            Models.Accommodation.Likibu.AccomodationDetailsParam reqParam = new Models.Accommodation.Likibu.AccomodationDetailsParam(searchVM.Language, searchVM.Currency, searchVM.Search.CheckIn, searchVM.Search.CheckOut);
            Models.Accommodation.Likibu.AccomodationDetails      result   = await Likibu.LikibuAccess.RequestAccomodationDetails(reqParam, roomID);

            return(result);
        }
Exemple #4
0
        public async Task <ActionResult> Create([Bind(Exclude = "ID")] Models.Request.RequestVMOwner requestVM)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    TravelerProfile tp = await ProfileManager.LoadUserAndTravelerProfile(User);

                    Models.Accommodation.Likibu.AccomodationDetailsParam para    = new Models.Accommodation.Likibu.AccomodationDetailsParam(tp.Attributes.Language, tp.Attributes.Currency, requestVM.CheckIn.ToString(), requestVM.CheckOut.ToString());
                    Models.Accommodation.Likibu.AccomodationDetails      details = await Likibu.LikibuAccess.RequestAccomodationDetails(para, requestVM.AccomID);

                    ///
                    using (var db = new ApplicationDbContext())
                    {
                        requestVM.BedRooms    = details.offer.BedRooms;
                        requestVM.Lat         = details.offer.Lat;
                        requestVM.Lng         = details.offer.Lng;
                        requestVM.PricePNight = details.offer.PriceNight.ToString();
                        requestVM.PricePWeek  = details.offer.PriceWeek.ToString();
                        requestVM.PricepMonth = details.offer.PriceMonth.ToString();

                        details.offer.Destination = requestVM.Location;
                        details.offer.Thumbnails  = Models.Accommodation.Likibu.Offer.StringToArray(requestVM.ThumbsTemp).ToList();



                        Models.Request.Request rq = new Models.Request.Request(tp.ID, requestVM);

                        rq.Accommodation = new Models.Accommodation.Accommodation(details.offer.MaxGuests, details.offer.BedRooms); //AccommodationModel is generated here
                        if (!rq.Accommodation.Verified)
                        {
                            throw new Exception("Accommodation abstraction failed");
                        }
                        string currency = ProfilesController.Currency(tp.Attributes.Currency);
                        rq.Accommodation.AccomProfile = new Models.Accommodation.AccommodationProfile(details.offer, currency);

                        db.Requests.Add(rq);
                        await db.SaveChangesAsync();

                        NotificationManager.AddNotification(NotificationType.Success, "Your Request has been saved!");

                        return(RedirectToAction("Create", "RoomRequests", new { id = rq.ID }));
                    }
                }
                catch (Exception e)
                {
                    NotificationManager.AddException(e);
                    NotificationManager.AddNotification(NotificationType.Error, "Oops, something went wrong!");
                    return(RedirectToAction("Search", "Searches"));
                }
            }
            return(View(requestVM));
        }
        public static async Task <Models.Accommodation.Likibu.AccomodationDetails> RequestAccomodationDetails(Models.Accommodation.Likibu.AccomodationDetailsParam para, string roomID)
        {
            try
            {
                string webrq    = DetailsRqString + roomID + ApiKey;
                string rqString = webrq + para.Body;
                string retStr   = null;
                retStr = await webClient.DownloadStringTaskAsync(rqString);

                Models.Accommodation.Likibu.AccomodationDetails ADetails = ParseDetailsResult(retStr);
                return(ADetails);
            }
            catch (Exception e)
            {
                NotificationManager.AddException(e);
                return(null);
            }
        }