Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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));
            }
        }
Ejemplo n.º 5
0
        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));
            }
        }
Ejemplo n.º 6
0
        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));
            }
        }
Ejemplo n.º 7
0
        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));
            }
        }
Ejemplo n.º 8
0
        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));
            }
        }
Ejemplo n.º 9
0
        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));
            }
        }
Ejemplo n.º 10
0
        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));
            }
        }
Ejemplo n.º 11
0
        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));
            }
        }