public async Task <IActionResult> Edit(int id, DongXe dongXe) { if (id != dongXe.DongXeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dongXe); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DongXeExists(dongXe.DongXeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["NhaSanXuatId"] = new SelectList(_context.NhaSanXuat, "NhaSanXuatId", "TenNSX", dongXe.NhaSanXuatId); return(View(dongXe)); }
public async Task <IActionResult> Edit(int id, [Bind("DongXeId,TenDongXe,HangXeId,PhanKhoiId,TheLoaiXeId")] DongXe dongXe) { if (id != dongXe.DongXeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dongXe); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DongXeExists(dongXe.DongXeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["HangXeId"] = new SelectList(_context.HangXes, "HangXeId", "TenHangXe", dongXe.HangXeId); ViewData["PhanKhoiId"] = new SelectList(_context.PhanKhois, "PhanKhoiId", "TenPhanKhoi", dongXe.PhanKhoiId); ViewData["TheLoaiXeId"] = new SelectList(_context.TheLoaiXes, "TheLoaiXeId", "TenTheLoaiXe", dongXe.TheLoaiXeId); return(View(dongXe)); }
public ActionResult SuaDongXe(int madongxe) { if (Session["Taikhoanadmin"] == null) { return(RedirectToAction("Login", "Admin")); } DongXe loai = db.DongXes.SingleOrDefault(n => n.MaDongXe == madongxe); return(View(loai)); }
public ActionResult ThemDongXe(DongXe loai) { if (Session["Taikhoanadmin"] == null) { return(RedirectToAction("Login", "Admin")); } db.DongXes.InsertOnSubmit(loai); db.SubmitChanges(); return(RedirectToAction("DongXe")); }
public async Task <IActionResult> Create(DongXe dongXe) { if (ModelState.IsValid) { _context.Add(dongXe); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["NhaSanXuatId"] = new SelectList(_context.NhaSanXuat, "NhaSanXuatId", "TenNSX", dongXe.NhaSanXuatId); return(View(dongXe)); }
public async Task <IActionResult> Create([Bind("DongXeId,TenDongXe,HangXeId,PhanKhoiId,TheLoaiXeId")] DongXe dongXe) { if (ModelState.IsValid) { _context.Add(dongXe); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["HangXeId"] = new SelectList(_context.HangXes, "HangXeId", "TenHangXe", dongXe.HangXeId); ViewData["PhanKhoiId"] = new SelectList(_context.PhanKhois, "PhanKhoiId", "TenPhanKhoi", dongXe.PhanKhoiId); ViewData["TheLoaiXeId"] = new SelectList(_context.TheLoaiXes, "TheLoaiXeId", "TenTheLoaiXe", dongXe.TheLoaiXeId); return(View(dongXe)); }
public ActionResult SuaDongXe(DongXe loai) { if (Session["Taikhoanadmin"] == null) { return(RedirectToAction("Login", "Admin")); } if (string.IsNullOrEmpty(loai.TenDongXe)) { ViewData["Loi"] = "Tên dòng xe không được bỏ trống"; return(View(loai)); } DongXe loaixe = db.DongXes.SingleOrDefault(n => n.MaDongXe == loai.MaDongXe); loaixe.TenDongXe = loai.TenDongXe; db.SubmitChanges(); return(RedirectToAction("DongXe", "Admin")); }