public IActionResult AddChiPhiChiTiet(int id) { if (id == null) { return(NotFound()); } var doan = context.TourDoan.Find(id); if (doan == null) { return(NotFound()); } var loaiChiPhi = from lcp in context.TourLoaiChiPhi where !((from cpct in context.TourChiPhiChiTiet where cpct.DoanId.Equals(id) select cpct.LoaiChiPhiId).Contains(lcp.LoaiChiPhiId) ) select lcp; ViewData["DoanId"] = doan.DoanTen; ViewData["LoaiChiPhiId"] = new SelectList(loaiChiPhi, "LoaiChiPhiId", "LoaiChiPhiTen"); TourChiPhiChiTiet doanNhanVien = new TourChiPhiChiTiet(); doanNhanVien.DoanId = doan.DoanId; return(View(doanNhanVien)); }
public async Task <IActionResult> EditChiPhiChiTiet(int id, [Bind("ChiPhiChiTietId,ChiPhi,NgayTao")] TourChiPhiChiTiet tourChiPhiChiTiet) { if (id != tourChiPhiChiTiet.ChiPhiChiTietId) { return(NotFound()); } if (ModelState.IsValid) { try { var cpct = await context.TourChiPhiChiTiet.FindAsync(id); cpct.ChiPhi = tourChiPhiChiTiet.ChiPhi; context.Update(cpct); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TourChiPhiChiTietExists(tourChiPhiChiTiet.ChiPhiChiTietId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details), new { id = doanId })); } var chiPhiChiTiet = await context.TourChiPhiChiTiet.Include(tcpct => tcpct.Doan).Include(tcpct => tcpct.LoaiChiPhi).FirstOrDefaultAsync(tcpct => tcpct.ChiPhiChiTietId == id); if (chiPhiChiTiet == null) { return(NotFound()); } ViewData["DoanId"] = chiPhiChiTiet.Doan.DoanTen; ViewData["LoaiChiPhiId"] = chiPhiChiTiet.LoaiChiPhi.LoaiChiPhiTen; return(View(tourChiPhiChiTiet)); }
public async Task <IActionResult> AddChiPhiChiTiet([Bind("ChiPhiChiTietId,LoaiChiPhiId,ChiPhi,NgayTao")] TourChiPhiChiTiet tourChiPhiChiTiet) { if (ModelState.IsValid) { tourChiPhiChiTiet.DoanId = (int)doanId; context.Add(tourChiPhiChiTiet); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Details), new { id = tourChiPhiChiTiet.DoanId })); } var doan = context.TourDoan.Find(tourChiPhiChiTiet.DoanId); if (doan == null) { return(NotFound()); } ViewData["DoanId"] = doan.DoanTen; ViewData["LoaiChiPhiId"] = new SelectList(context.TourLoaiChiPhi, "LoaiChiPhiId", "LoaiChiPhiTen", tourChiPhiChiTiet.LoaiChiPhiId); return(View(tourChiPhiChiTiet)); }