Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("MaLoai,TenLoai")] Loai loai)
        {
            if (ModelState.IsValid)
            {
                _context.Add(loai);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(loai));
        }
        public async Task <IActionResult> Create([Bind("MaNcc,TenCongTy,Email,DienThoai,DiaChi,MoTa,Hinh")] NhaCungCap nhaCungCap)
        {
            if (ModelState.IsValid)
            {
                _context.Add(nhaCungCap);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(nhaCungCap));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("MaKh,MatKhau,HoTen,DiaChi,DienThoai,Email,Hinh,LoaiKh,TaiKhoan,GioiTinh,NgaySinh,TrangThaiHd")] KhachHang khachHang)
        {
            if (ModelState.IsValid)
            {
                _context.Add(khachHang);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(khachHang));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("MaNv,HoTen,Email,MatKhau,MaPq,TrangThaiHd")] NhanVien nhanVien)
        {
            if (ModelState.IsValid)
            {
                _context.Add(nhanVien);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaPq"] = new SelectList(_context.PhanQuyen, "MaPq", "MaPq", nhanVien.MaPq);
            return(View(nhanVien));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var hoaDon = await _context.HoaDon.FindAsync(id);

            _context.HoaDon.Remove(hoaDon);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("MaHh,TenHh,MaLoai,Hinh,DonGia,GiamGia,MoTa,MaNcc,SoLuong,SanPhamMoi")] HangHoa hangHoa, IFormFile fHinh)
        {
            if (ModelState.IsValid)
            {
                if (fHinh != null)
                {
                    string path = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "HangHoa", fHinh.FileName);
                    using (var file = new FileStream(path, FileMode.Create))
                    {
                        fHinh.CopyTo(file);
                    }
                    hangHoa.Hinh = fHinh.FileName;
                }
                _context.Add(hangHoa);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaLoai"] = new SelectList(_context.Loai, "MaLoai", "MaLoai", hangHoa.MaLoai);
            ViewData["MaNcc"]  = new SelectList(_context.NhaCungCap, "MaNcc", "MaNcc", hangHoa.MaNcc);
            return(View(hangHoa));
        }