public async Task <IActionResult> Create([Bind("Id,Name,Template")] HotelType hotelType) { if (ModelState.IsValid) { _context.Add(hotelType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(hotelType)); }
public async Task <IActionResult> Create([Bind("Id,Name")] Country country) { if (ModelState.IsValid) { _context.Add(country); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(country)); }
public async Task <IActionResult> Create([Bind("Id,Name,HotelTypeId,CountryId,Description,Rating,AllowGroups,Activities,OnlyAdults")] Hotel hotel) { if (ModelState.IsValid) { _context.Add(hotel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CountryId"] = new SelectList(_context.Country, "Id", "Name", hotel.CountryId); ViewData["HotelTypeId"] = new SelectList(_context.HotelType, "Id", "Name", hotel.HotelTypeId); return(View(hotel)); }
public async Task <IActionResult> Create([Bind("Id,CustomerId,PaxesCount,StartDate,EndDate,Profit,Currency,CountryId,Hotels")] Booking booking) { if (ModelState.IsValid) { var hotelIds = ModelState["Hotels"].AttemptedValue.Split(","); booking.Hotels = _context.Hotel.Where(h => hotelIds.Contains(h.Id.ToString())).ToList(); _context.Add(booking); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Hotels"] = new MultiSelectList(_context.Hotel, "Id", "Name", booking.Hotels); ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "Name", booking.CustomerId); return(View(booking)); }