public IActionResult ListingDetails(ListDetailsViewModel modelData, int ListID) { if (HttpContext.Session.GetInt32("UserID") != null) { modelData.UserID = (int)HttpContext.Session.GetInt32("UserID"); } modelData.Listing = DBContext.Listings .Include(l => l.Host) .Include(l => l.Address) .Include(l => l.Bookings) .FirstOrDefault(l => l.ListingID == ListID); if (ModelState.IsValid) { modelData.NewBooking.Total = (modelData.Listing.Price * (modelData.NewBooking.CheckOut - modelData.NewBooking.CheckIn).TotalDays) + (20 * modelData.NewBooking.PetNum); modelData.NewBooking.ListingID = ListID; modelData.NewBooking.UserID = modelData.UserID; DBContext.Bookings.Add(modelData.NewBooking); DBContext.SaveChanges(); modelData.NewBooking.BookingID = DBContext.Bookings.LastOrDefault().BookingID; return(Redirect($"/TravelNow/Booking/{modelData.NewBooking.BookingID}/Confirm")); } modelData.Amenities = modelData.Listing.Amenities.Split(", ").ToList(); return(View(modelData)); }
public ActionResult ListDetails(string listName) { var list = SharepointHelper.GetList(listName); var model = new ListDetailsViewModel(); model.Title = listName; model.Items = list.Select(_ => new SPListItem() { Title = _["Title"].ToString(), Id = _["ID"].ToString() }); return(View(model)); }
public ViewResult ListingDetails(int ListID) { ListDetailsViewModel ViewModel = new ListDetailsViewModel() { Listing = DBContext.Listings .Include(l => l.Host) .Include(l => l.Address) .Include(l => l.Bookings) .FirstOrDefault(l => l.ListingID == ListID), }; ViewModel.Amenities = ViewModel.Listing.Amenities.Split(", ").ToList(); if (HttpContext.Session.GetInt32("UserID") != null) { ViewModel.UserID = (int)HttpContext.Session.GetInt32("UserID"); } return(View(ViewModel)); }
public ListDetailsPage(ListDetailsViewModel viewModel) { InitializeComponent(); DataContext = viewModel; }