public ActionResult Edit(int idOffer) { if (User.Identity.Name == "Admin") { Offer offer = _offersSqlExecutor.FindOfferById(idOffer); IEnumerable <SelectListItem> hotels = _hotelsSqlExecutor.GetHotelsForSelect(); OfferEditModel model = new OfferEditModel { hotels = hotels, offer = offer, SelectedHotelId = offer.ID_HOTEL }; return(View(model)); } else { return(RedirectToAction("Index")); } }
public ActionResult Create(int idOffer) { Offer offer = _offerSqlExecutor.FindOfferById(idOffer); List <SelectListItem> guestNumberList = new List <SelectListItem>(); for (int i = offer.PEOPLE_FROM; i <= offer.PEOPLE_TO; i++) { guestNumberList.Add(new SelectListItem { Text = i.ToString(), Value = i.ToString() }); } var user = HttpContext.User.Identity; var idUser = _accountSqlExecutor.GetUserId(user.Name); UserReservationEdit model = new UserReservationEdit { Offer = offer, Reservation = new UserReservationFullData(), GuestsSelect = guestNumberList, IdUser = idUser }; return(View(model)); }