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