public async Task <bool> UpdateCountNewAccount() { bool result = false; var existCountNewAccounts = _context.CountNewAccount.Where(m => m.Date == DateTime.Now.Date).ToList(); if (existCountNewAccounts.Count == 0 || existCountNewAccounts == null) { CountNewAccountModel countNewAccountModel = new CountNewAccountModel(); countNewAccountModel.Date = DateTime.Now.Date; countNewAccountModel.Count = 1; //countNewAccountModel.Name = countNewAccountModel.GetName(1); _context.Add(countNewAccountModel); await _context.SaveChangesAsync(); result = true; } else { var existCountNewAccount = existCountNewAccounts.FirstOrDefault(); existCountNewAccount.Count++; _context.Update(existCountNewAccount); await _context.SaveChangesAsync(); result = true; } return(result); }
public async Task <IActionResult> PutTypeProduct(int id, TypeProduct typeProduct) { if (id != typeProduct.Id) { return(BadRequest()); } _context.Entry(typeProduct).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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 <String> PutSize(int id, Size size) { if (id != size.Id) { return("0"); } _context.Entry(size).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SizeExists(id)) { return("0"); } else { throw; } } return("{\"id\":" + id + ",\" stt\":\"" + size.Name + "\"}"); }
public async Task <IActionResult> Edit(int id, [Bind("Id,TenSuatChieu,GiaSuatChieu")] LoaiSuatChieuModel loaiSuatChieuModel) { if (id != loaiSuatChieuModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(loaiSuatChieuModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LoaiSuatChieuModelExists(loaiSuatChieuModel.Id)) { return(NotFound()); } else { throw; } } } return(RedirectToAction(nameof(Index))); }
public async Task <String> PutTypeAccount(int id, TypeAccount typeAccount) { if (id != typeAccount.Id) { return("0"); } _context.Entry(typeAccount).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeAccountExists(id)) { return("0"); } else { throw; } } return("{\"id\":" + id + ",\" stt\":\"" + typeAccount.Status + "\"}"); }
public async Task <IActionResult> PutThanhVienModel(int id, ThanhVienModel thanhVienModel) { if (id != thanhVienModel.Id) { return(BadRequest()); } _context.Entry(thanhVienModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThanhVienModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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> Create([Bind("CategoryID,Name,Description,Status")] CategoryModel categoryModel) { if (ModelState.IsValid) { _context.Add(categoryModel); await _context.SaveChangesAsync(); } return(View("Index")); }
public async Task <IActionResult> Create([Bind("Id,Name")] Size size) { if (ModelState.IsValid) { _context.Add(size); await _context.SaveChangesAsync(); } return(View("Index")); }
public async Task <IActionResult> Create([Bind("Id,TenSuatChieu,GiaSuatChieu")] LoaiSuatChieuModel loaiSuatChieuModel) { if (ModelState.IsValid) { _context.Add(loaiSuatChieuModel); await _context.SaveChangesAsync(); } return(View("Index")); }
public async Task <IActionResult> Create([Bind("ID,Name,Row_ID,Col_ID,Status,Room_ID,Equipment_Level_ID")] Equipment equipment) { Middleware.CheckStafLogin(HttpContext); if (ModelState.IsValid) { _context.Add(equipment); await _context.SaveChangesAsync(); } return(Redirect("/Admin/Equipments/Index/" + equipment.Room_ID)); }
public async Task<IActionResult> Create([Bind("Id,TenLoai")] LoaiPhimModel loaiPhimModel) { if (ModelState.IsValid) { _context.Add(loaiPhimModel); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(loaiPhimModel); }
public async Task <IActionResult> Create([Bind("Id,Name,Status")] TypeAccount typeAccount) { if (ModelState.IsValid) { _context.Add(typeAccount); await _context.SaveChangesAsync(); } TempData["result"] = "Thêm mới thành công"; return(RedirectToAction("Index")); }
public async Task <IActionResult> Create([Bind("IdThanhPho,TenThanhPho")] ThanhPhoModel thanhPhoModel) { if (ModelState.IsValid) { _context.Add(thanhPhoModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(thanhPhoModel)); }
public async Task <IActionResult> Create([Bind("Id,TenRapChieu,TongSoPhong,ThanhPho,QuanHuyen")] RapChieuPhimModel rapChieuPhimModel) { if (ModelState.IsValid) { _context.Add(rapChieuPhimModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(rapChieuPhimModel)); }
public async Task <IActionResult> Create([Bind("IdPro,Name,Description,Date")] ProducerModel producerModel) { if (ModelState.IsValid) { _context.Add(producerModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(producerModel)); }
public async Task <IActionResult> Create([Bind("PaymentID,Name,Logo,Status")] PaymentModel paymentModel) { if (ModelState.IsValid) { _context.Add(paymentModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(paymentModel)); }
public async Task <IActionResult> Create([Bind("Id,DateTime,TotalPrice")] Bill bill) { if (ModelState.IsValid) { _context.Add(bill); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bill)); }
public async Task <IActionResult> Create([Bind("Id,NguoiDung,TaiKhoan,MatKhau,NgaySinh,NgayDangKy,TinhTrang")] NguoiDungModel nguoiDungModel) { if (ModelState.IsValid) { _context.Add(nguoiDungModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(nguoiDungModel)); }
public async Task <IActionResult> Create([Bind("IdType,Name,Description,Status")] TypeShoeModel typeShoeModel) { if (ModelState.IsValid) { _context.Add(typeShoeModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(typeShoeModel)); }
public async Task <IActionResult> Create([Bind("MaHD,MaND,MaSP,TenSP,NgayLapHD,NgayNhanHang,TrangThai")] HoaDonModel hoaDonModel) { if (ModelState.IsValid) { _context.Add(hoaDonModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(hoaDonModel)); }
public async Task <IActionResult> Create([Bind("MaQuyen,TenQuyen,TrangThai")] PhanQuyenModel phanQuyenModel) { if (ModelState.IsValid) { _context.Add(phanQuyenModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(phanQuyenModel)); }
public async Task <IActionResult> Create([Bind("IdHoaDon,idUser,NgayLap,TongTien")] HoaDonModel hoaDonModel) { if (ModelState.IsValid) { _context.Add(hoaDonModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(hoaDonModel)); }
public async Task <IActionResult> Create([Bind("Id,Name,Phone,Addresss")] Publisher publisher) { if (ModelState.IsValid) { _context.Add(publisher); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(publisher)); }
public async Task <IActionResult> Create([Bind("Id,Name")] TypeAccount typeAccount) { if (ModelState.IsValid) { _context.Add(typeAccount); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(typeAccount)); }
public async Task <IActionResult> Create([Bind("IdSanPham,IDLoaiSp,TenSanPham,SoLuong,GiaNhap,GiaBan,Mota,HinhAnh,TrangThai")] SanPhamModel sanPhamModel) { if (ModelState.IsValid) { _context.Add(sanPhamModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(sanPhamModel)); }
public async Task <IActionResult> Create([Bind("ID,Ten_phim,Hinh_anh,Thoi_luong,Luot_xem,Gia_ve,Lich_Chieu,Da_xoa")] PhimModel phimModel) { if (ModelState.IsValid) { _context.Add(phimModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(phimModel)); }
public async Task <IActionResult> Create([Bind("IDLG,TenLoai,GiaLG,TrangThai")] LoaiGheModel loaiGheModel) { if (ModelState.IsValid) { _context.Add(loaiGheModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(loaiGheModel)); }
public async Task <IActionResult> Create([Bind("AccountName,Password,Rule,Status")] AccountModel accountModel) { if (ModelState.IsValid) { _context.Add(accountModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(accountModel)); }