public async Task <IActionResult> Create([Bind("Id,TenPhim,ThoiLuong,DaoDien,DienVien,QuocGia,Mota,HinhAnh,Trailer,NgayPhatHanh,MaLoai,TrangThai")] PhimModel phimModel, IFormFile ful) { ViewBag.lstLoaiPhim_Active = (from p in _context.tb_LoaiPhim where p.TrangThai == true select p).ToList(); if (ModelState.IsValid) { _context.Add(phimModel); await _context.SaveChangesAsync(); var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/template_admin/images/Phim", phimModel.Id + "." + ful.FileName.Split(".") [ful.FileName.Split(".").Length - 1]); using (var stream = new FileStream(path, FileMode.Create)) { await ful.CopyToAsync(stream); } phimModel.HinhAnh = phimModel.Id + "." + ful.FileName.Split(".") [ful.FileName.Split(".").Length - 1]; if (phimModel.NgayPhatHanh > DateTime.Now) { phimModel.TrangThai = 2; } else { phimModel.TrangThai = 1; } _context.Update(phimModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } //ViewData["MaLoai"] = new SelectList(_context.tb_LoaiPhim, "Id", "TenLoai", phimModel.MaLoai); return(View(phimModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ProductName,Producer,Status")] Product product) { if (id != product.Id) { return(NotFound()); } if (ModelState.IsValid) { try { product.Status = true; _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.Id)) { return(NotFound()); } else { throw; } } return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _context.Product.ToList()) })); } return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "Edit", product) })); }
public async Task <IActionResult> Create([Bind("Id,Image")] Slide slide, IFormFile File) { if (ModelState.IsValid) { if (File == null) { return(RedirectToAction(nameof(Create))); } _context.Add(slide); _context.SaveChanges(); var path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot/Img/Pro", slide.Id + "." + File.FileName.Split(".")[File.FileName.Split(".").Length - 1]); using (var stream = new FileStream(path, FileMode.Create)) { await File.CopyToAsync(stream); } slide.Image = slide.Id + "." + File.FileName.Split(".")[File.FileName.Split(".").Length - 1]; try { _context.Update(slide); await _context.SaveChangesAsync(); } catch (Exception e) { _context.RemoveRange(slide); throw; } return(RedirectToAction(nameof(Index)));; } return(View(slide)); }
public async Task <IActionResult> AddSong(int idAlbum, List <int> idSong) { foreach (var item in idSong) { var song = await _context.Song.FindAsync(item); if (song != null) { song.IdAlbum = idAlbum; _context.Update(song); await _context.SaveChangesAsync(); } } return(RedirectToAction("DetailAlbum", "Album", new { area = "Admin", id = idAlbum })); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Ten_Phong,Da_xoa,RapPhim_ID")] PhongChieuModel phongChieuModel) { if (id != phongChieuModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(phongChieuModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhongChieuModelExists(phongChieuModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["RapPhim_ID"] = new SelectList(_context.Set <RapPhimModel>(), "ID", "ID", phongChieuModel.RapPhim_ID); return(View(phongChieuModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdThanhPho,TenThanhPho")] ThanhPhoModel thanhPhoModel) { if (id != thanhPhoModel.IdThanhPho) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(thanhPhoModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThanhPhoModelExists(thanhPhoModel.IdThanhPho)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(thanhPhoModel)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Row_ID,Col_ID,Status,Room_ID,Equipment_Level_ID")] Equipment equipment) { Middleware.CheckStafLogin(HttpContext); if (id != equipment.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(equipment); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EquipmentExists(equipment.ID)) { return(NotFound()); } else { throw; } } return(Redirect("/Admin/Equipments/Index/" + equipment.Room_ID)); } ViewData["Equipment_Level_ID"] = new SelectList(_context.Category_Equipment, "ID", "Name", equipment.Equipment_Level_ID); ViewData["Room_ID"] = new SelectList(_context.Rooms, "ID", "Name", equipment.Room_ID); return(View(equipment)); }
public async Task <IActionResult> Edit(int id, [Bind("IDPhim,IDPhong,AnhPhim,TenPhim,TenDienVien,TenNgonNgu,TheLoai,TenPhuDe,DaoDien,KhoiChieu,ThoiLuong,Rated,TrangThai")] PhimModel phimModel) { if (id != phimModel.IDPhim) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(phimModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhimModelExists(phimModel.IDPhim)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IDPhong"] = new SelectList(_context.Phong, "IDPhong", "IDPhong", phimModel.IDPhong); return(View(phimModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,TenRapChieu,TongSoPhong,ThanhPho,QuanHuyen")] RapChieuPhimModel rapChieuPhimModel) { if (id != rapChieuPhimModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rapChieuPhimModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RapChieuPhimModelExists(rapChieuPhimModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(rapChieuPhimModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Username,Password,Name,Image,Address,Phone,Email,Catid")] Account account) { if (id != account.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(account); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountExists(account.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Catid"] = new SelectList(_context.typeAccount, "Id", "Id", account.Catid); return(View(account)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,NguoiDung,TaiKhoan,MatKhau,NgaySinh,NgayDangKy,TinhTrang")] NguoiDungModel nguoiDungModel) { if (id != nguoiDungModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(nguoiDungModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NguoiDungModelExists(nguoiDungModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(nguoiDungModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdOrder,IdUser,Date,Status")] OrderModel orderModel) { if (id != orderModel.IdOrder) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(orderModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderModelExists(orderModel.IdOrder)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdUser"] = new SelectList(_context.User, "IdUser", "Address", orderModel.IdUser); return(View(orderModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdPhong,TenPhong,MaRap")] PhongModel phongModel) { if (id != phongModel.IdPhong) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(phongModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PhongModelExists(phongModel.IdPhong)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaRap"] = new SelectList(_context.rapModels, "IdRap", "DiaChiRap", phongModel.MaRap); return(View(phongModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdRap,TenRap,DiaChiRap,MaQuanHuyen")] RapModel rapModel) { if (id != rapModel.IdRap) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rapModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RapModelExists(rapModel.IdRap)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaQuanHuyen"] = new SelectList(_context.quanHuyenModels, "IdQuanHuyen", "TenQuanHuyen", rapModel.MaQuanHuyen); return(View(rapModel)); }
public async Task <IActionResult> Edit(int id, [Bind("PaymentID,Name,Logo,Status")] PaymentModel paymentModel) { if (id != paymentModel.PaymentID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(paymentModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PaymentModelExists(paymentModel.PaymentID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(paymentModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IDRap,TenRap,TrangThai,IDTP")] RapModel rapModel) { if (id != rapModel.IDRap) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rapModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RapModelExists(rapModel.IDRap)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IDTP"] = new SelectList(_context.ThanhPho, "IDTP", "IDTP", rapModel.IDTP); return(View(rapModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdSanPham,IDLoaiSp,TenSanPham,SoLuong,GiaNhap,GiaBan,Mota,HinhAnh,TrangThai")] SanPhamModel sanPhamModel) { if (id != sanPhamModel.IdSanPham) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sanPhamModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SanPhamModelExists(sanPhamModel.IdSanPham)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(sanPhamModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdAdmin,FullName,Address,Phone,IdAccount")] AdminModel adminModel) { if (id != adminModel.IdAdmin) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(adminModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdminModelExists(adminModel.IdAdmin)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdAccount"] = new SelectList(_context.Account, "AccountName", "AccountName", adminModel.IdAccount); return(View(adminModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdChiTietDatVe,TenGhe,GiaVe,MaDatVe")] ChiTietDatVeModel chiTietDatVeModel) { if (id != chiTietDatVeModel.IdChiTietDatVe) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(chiTietDatVeModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChiTietDatVeModelExists(chiTietDatVeModel.IdChiTietDatVe)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaDatVe"] = new SelectList(_context.datVeModels, "IdDatVe", "IdDatVe", chiTietDatVeModel.MaDatVe); return(View(chiTietDatVeModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdUser,UserName,PassWord,AnhDaiDien,MoTa,NgayLap,IdLoaiUser")] UserModel userModel) { if (id != userModel.IdUser) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserModelExists(userModel.IdUser)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdDatVe,SoGhe,NgayDat,TongGia,MaLichChieu,TrangThaiThanhToan,MaKhachHang")] DatVeModel datVeModel) { if (id != datVeModel.IdDatVe) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(datVeModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DatVeModelExists(datVeModel.IdDatVe)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaKhachHang"] = new SelectList(_context.userModels, "IdUser", "DiaChi", datVeModel.MaKhachHang); ViewData["MaLichChieu"] = new SelectList(_context.lichChieuModels, "IdLichChieu", "IdLichChieu", datVeModel.MaLichChieu); return(View(datVeModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Size size) { if (id != size.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(size); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SizeExists(size.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(size)); }
public async Task <IActionResult> Edit(int id, [Bind("IDCTHD,IDHD,TenRap,TenPhim,GioChieu,NgayChieu,PhongChieu,TenGhe,SoLuong,GiaLG")] ChiTietHoaDonModel chiTietHoaDonModel) { if (id != chiTietHoaDonModel.IDCTHD) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(chiTietHoaDonModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ChiTietHoaDonModelExists(chiTietHoaDonModel.IDCTHD)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IDHD"] = new SelectList(_context.HoaDon, "IDHD", "IDHD", chiTietHoaDonModel.IDHD); return(View(chiTietHoaDonModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IDGhe,IDLG,IDPhong,TenGhe,SoGhe,TrangThai")] GheModel gheModel) { if (id != gheModel.IDGhe) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(gheModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GheModelExists(gheModel.IDGhe)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IDLG"] = new SelectList(_context.LoaiGhe, "IDLG", "IDLG", gheModel.IDLG); ViewData["IDPhong"] = new SelectList(_context.Phong, "IDPhong", "IDPhong", gheModel.IDPhong); return(View(gheModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IDLG,TenLoai,GiaLG,TrangThai")] LoaiGheModel loaiGheModel) { if (id != loaiGheModel.IDLG) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(loaiGheModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiGheModelExists(loaiGheModel.IDLG)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(loaiGheModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdUser,Username,Password,HoTen,NgaySinh,GioiTinh,DiaChi,SDT,LoaiTaiKhoan")] UserModel userModel) { if (id != userModel.IdUser) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserModelExists(userModel.IdUser)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,NgayLap,TongTien,MaThanhVien,TrangThai")] HoaDonModel hoaDonModel) { if (id != hoaDonModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(hoaDonModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!HoaDonModelExists(hoaDonModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["MaThanhVien"] = new SelectList(_context.tb_ThanhVien, "Id", "Email", hoaDonModel.MaThanhVien); return(View(hoaDonModel)); }
public async Task <IActionResult> Edit(int id, [Bind("IdPro,Name,Description,Date")] ProducerModel producerModel) { if (id != producerModel.IdPro) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(producerModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProducerModelExists(producerModel.IdPro)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(producerModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,IdPhong,IdPhim,NgayCongChieu")] LichChieuModel lichChieuModel) { if (id != lichChieuModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(lichChieuModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LichChieuModelExists(lichChieuModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdPhong"] = new SelectList(_context.Phong, "Id", "TenPhong", lichChieuModel.IdPhong); return(View(lichChieuModel)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Ten_rap,Dia_chi,Da_xoa")] RapPhimModel rapPhimModel) { if (id != rapPhimModel.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(rapPhimModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RapPhimModelExists(rapPhimModel.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(rapPhimModel)); }