public async Task <IActionResult> Edit(int id, [Bind("ID,TenNCC,DiaChi,TrangThai")] NCC nCC) { if (id != nCC.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(nCC); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NCCExists(nCC.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(nCC)); }
public async Task <IActionResult> Edit(string id, [Bind("MaHD,TongTien,UserID")] HoaDon hoaDon) { if (id != hoaDon.MaHD) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hoaDon); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HoaDonExists(hoaDon.MaHD)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["UserID"] = new SelectList(_context.User, "UserId", "UserId", hoaDon.UserID); return(View(hoaDon)); }
public async Task <IActionResult> Edit(int id, [Bind("UserId,UserName,PassWord,TrangThai")] User user) { if (id != user.UserId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.UserId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("MaCTHD,MaHD,MaSP,SoLuong,ThanhTien")] CTHD cTHD) { if (id != cTHD.MaCTHD) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cTHD); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CTHDExists(cTHD.MaCTHD)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cTHD)); }
public async Task <IActionResult> Edit(int id, [Bind("IdComment,UserId,MaSP,NoiDung,Time")] Comment comment) { if (id != comment.IdComment) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(comment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CommentExists(comment.IdComment)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaSP"] = new SelectList(_context.SanPham, "MaSP", "MaSP", comment.MaSP); return(View(comment)); }
public async Task <IActionResult> Edit(int id, [Bind("MaLoai,Ten,TT,MaNCC")] LoaiSPModels loaiSPModels) { if (id != loaiSPModels.MaLoai) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(loaiSPModels); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiSPModelsExists(loaiSPModels.MaLoai)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaNCC"] = new SelectList(_context.NCC, "ID", "ID", loaiSPModels.MaNCC); return(View(loaiSPModels)); }
public async Task <IActionResult> Create([Bind("MaSP,TenSP,NgaySX,Hinh,MoTa,Gia,TrangThai,MaLoai")] SanPhamModels sanPhamModels, IFormFile ful) { if (ModelState.IsValid) { _context.Add(sanPhamModels); await _context.SaveChangesAsync(); var path = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot/img/product", sanPhamModels.MaSP + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1]); using (var stream = new FileStream(path, FileMode.Create)) { await ful.CopyToAsync(stream); } sanPhamModels.Hinh = sanPhamModels.MaSP + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1]; _context.Update(sanPhamModels); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaLoai"] = new SelectList(_context.LoaiSanPham, "MaLoai", "MaLoai", sanPhamModels.MaLoai); return(View(sanPhamModels)); }