// 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()); } }
public async Task <ActionResult> Create(int?id) //Request id { try { if (!id.HasValue) { return(RedirectToAction("Search", "Searches")); } TravelerProfile tp = await ProfileManager.LoadUserAndTravelerProfile(User); using (var db = new ApplicationDbContext()) { TravelerProfileSearchSession searchSession = await db.LikibuSearchSession.FindAsync(tp.TravelerSearchID); //to fill checkDates, Location Models.Request.Request request = await db.Requests.FindAsync(id); request.Accommodation = await AccommodationsController.LoadAccommodation(request.Accommodation_ID); if (Check.IsNull(request, "Create RoomRequest")) { NotificationManager.AddNotification(NotificationType.Warning, "Request is not valid"); return(RedirectToAction("Search", "Searches")); } if (request.IsDeleted("CreateRoomRequest, rq deleted")) { NotificationManager.AddNotification(NotificationType.Warning, "Request is not valid"); return(RedirectToAction("Search", "Searches")); } if (request.IsClosed()) //dann keine RoomRequests mehr { NotificationManager.AddNotification(NotificationType.Info, "You can't apply for closed requests"); return(RedirectToAction("Search", "Searches")); } //calc Valid Time here DateTime CheckIn = request.CheckIn; DateTime CheckOut = request.CheckOut; DateTime chckinUser = DateTime.Parse(searchSession.CheckIn); DateTime chckoutUser = DateTime.Parse(searchSession.CheckOut); if (chckinUser < CheckIn) { CheckIn = chckinUser; } if (chckoutUser > CheckOut) { CheckOut = chckoutUser; } Models.RoomRequest.RoomRequestVMUser roomRequestVM = new Models.RoomRequest.RoomRequestVMUser(CheckIn, CheckOut, request); if (tp.ID == request.RequestOwner_ID) { roomRequestVM.RequestOwner = true; } return(View(roomRequestVM)); } } catch (Exception e) { NotificationManager.AddException(e); return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError)); } }