public async Task <IActionResult> Edit(int id, [Bind("GiaId,GiaSoTien,GiaTuNgay,GiaDenNgay,NgayTao")] TourGia tourGia) { if (id != tourGia.GiaId) { return(NotFound()); } if (ModelState.IsValid) { try { tourGia.TourId = (int)tourId; context.Update(tourGia); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TourGiaExists(tourGia.GiaId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } var tour = await context.Tour.FindAsync(tourId); ViewData["TourId"] = tour.TourTen; return(View(tourGia)); }
public async Task <IActionResult> Create([Bind("GiaId,GiaSoTien,TourId,GiaTuNgay,GiaDenNgay,NgayTao")] TourGia tourGia) { if (ModelState.IsValid) { context.Add(tourGia); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TourId"] = new SelectList(context.Tour, "TourId", "TourTen", tourGia.TourId); return(View(tourGia)); }