public async Task <IActionResult> DangKy(RegisterModel model) { var temp = 0; if (ModelState.IsValid) { if (!Regex.IsMatch(model.Email, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase)) { throw new UserDefException("Email không hợp lệ!"); } else { var user = new KhachHang(); user.MaKh = model.UserName; user.MatKhau = passwordHasher.HashPassword(model.PassWord); // user.MatKhau = model.PassWord; user.HoTen = model.Name; user.GioiTinh = model.GioiTinh; user.NgaySinh = model.NgaySinh; user.DiaChi = model.Diachi; user.PhoneNumber = model.Phonenumer; db.Add(user); await db.SaveChangesAsync(); temp = 1; } if (temp > 0) { ViewBag.Success = "Đăng ký thành công!!"; temp = 0; } } // return View(model); return(View("DangKy")); }
public async Task <IActionResult> Create([Bind("MaKh,MatKhau,HoTen,GioiTinh,NgaySinh,DiaChi,DienThoai,Email,HieuLuc,VaiTro,RandomKey")] KhachHang khachHang) { if (HttpContext.Session.Get <NhanVien>("MaNv") == null) { return(Redirect("/Admin/Login")); } else { if (ModelState.IsValid) { _context.Add(khachHang); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(khachHang)); } }
public async Task <IActionResult> Create([Bind("MaYt,MaSp,MaKh,NgayChon,MoTa")] YeuThich yeuThich) { if (ModelState.IsValid) { _context.Add(yeuThich); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaKh"] = new SelectList(_context.KhachHang, "MaKh", "MaKh", yeuThich.MaKh); ViewData["MaSp"] = new SelectList(_context.SanPham, "MaSp", "MaSp", yeuThich.MaSp); return(View(yeuThich)); }
public async Task <IActionResult> Create([Bind("MaLoai,TenLoai,TenLoaiAlias,MoTa")] Loai loai) { if (HttpContext.Session.Get <NhanVien>("MaNv") == null) { return(Redirect("/Admin/Login")); } else { if (ModelState.IsValid) { _context.Add(loai); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(loai)); } }
public async Task <IActionResult> Create([Bind("MaNv,HoTen,Email,MatKhau")] NhanVien nhanVien) { if (HttpContext.Session.Get <NhanVien>("MaNv") == null) { return(Redirect("/Admin/Login")); } else { if (ModelState.IsValid) { _context.Add(nhanVien); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(nhanVien)); } }
public async Task <IActionResult> Create([Bind("MaKho,MaSp,SoLuong")] KhoHang khoHang) { if (HttpContext.Session.Get <NhanVien>("MaNv") == null) { return(Redirect("/Admin/Login")); } else { if (ModelState.IsValid) { _context.Add(khoHang); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaSp"] = new SelectList(_context.SanPham, "MaSp", "MaSp", khoHang.MaSp); return(View(khoHang)); } }
public async Task <IActionResult> Create([Bind("MaHieu,TenHieu,MaSp,Hinh")] ThuongHieu thuongHieu) { if (HttpContext.Session.Get <NhanVien>("MaNv") == null) { return(Redirect("/Admin/Login")); } else { if (ModelState.IsValid) { _context.Add(thuongHieu); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaHieu"] = new SelectList(_context.ThuongHieu, "MaHieu", "MaHieu", thuongHieu.MaHieu); return(View(thuongHieu)); } }
public async Task <IActionResult> Create([Bind("MaBl,MaSp,MaKh,NgayBl,HoTen,Email,NoiDung")] BinhLuan binhLuan) { if (HttpContext.Session.Get <NhanVien>("MaNv") == null) { return(Redirect("/Admin/Login")); } else { if (ModelState.IsValid) { _context.Add(binhLuan); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaKh"] = new SelectList(_context.KhachHang, "MaKh", "MaKh", binhLuan.MaKh); ViewData["MaSp"] = new SelectList(_context.SanPham, "MaSp", "MaSp", binhLuan.MaSp); return(View(binhLuan)); } }
public async Task <IActionResult> Create([Bind("MaSp,TenSp,TenAlias,MaLoai,MoTa,DonGia,Hinh,GiaCu,MaNcc")] SanPham sanPham) { if (HttpContext.Session.Get <NhanVien>("MaNv") == null) { return(Redirect("/Admin/Login")); } else { if (ModelState.IsValid) { _context.Add(sanPham); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaLoai"] = new SelectList(_context.Loai, "MaLoai", "MaLoai", sanPham.MaLoai); ViewData["MaNcc"] = new SelectList(_context.NhaCungCap, "MaNcc", "MaNcc", sanPham.MaNcc); return(View(sanPham)); } }
public async Task <IActionResult> Create([Bind("MaCt,MaHd,MaSp,DonGia,SoLuong,GiamGia")] ChiTietHd chiTietHd) { if (HttpContext.Session.Get <NhanVien>("MaNv") == null) { return(Redirect("/Admin/Login")); } else { if (ModelState.IsValid) { _context.Add(chiTietHd); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaHd"] = new SelectList(_context.HoaDon, "MaHd", "DiaChi", chiTietHd.MaHd); ViewData["MaSp"] = new SelectList(_context.SanPham, "MaSp", "MaSp", chiTietHd.MaSp); return(View(chiTietHd)); } }
public async Task <IActionResult> Create([Bind("MaHd,MaKh,NgayDat,NgayGiao,MaNv,HoTen,DiaChi,CachThanhToan,CachVanChuyen,PhiVanChuyen,MaTrangThai,GhiChu,DienThoai,TenNgNhan,DtngNhan,DiaChiNgNhan")] HoaDon hoaDon) { if (HttpContext.Session.Get <NhanVien>("MaNv") == null) { return(Redirect("/Admin/Login")); } else { if (ModelState.IsValid) { _context.Add(hoaDon); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["MaKh"] = new SelectList(_context.KhachHang, "MaKh", "MaKh", hoaDon.MaKh); ViewData["MaNv"] = new SelectList(_context.NhanVien, "MaNv", "MaNv", hoaDon.MaNv); ViewData["MaTrangThai"] = new SelectList(_context.TrangThai, "MaTrangThai", "MaTrangThai", hoaDon.MaTrangThai); return(View(hoaDon)); } }