Esempio n. 1
0
        public async Task <IActionResult> PutLoaiSPModels(int id, LoaiSPModels loaiSPModels)
        {
            if (id != loaiSPModels.MaLoai)
            {
                return(BadRequest());
            }

            _context.Entry(loaiSPModels).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LoaiSPModelsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PutNCC(int id, NCC nCC)
        {
            if (id != nCC.ID)
            {
                return(BadRequest());
            }

            _context.Entry(nCC).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NCCExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 3
0
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.UserId)
            {
                return(BadRequest());
            }

            _context.Entry(user).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("ID,TenNCC,DiaChi,TrangThai")] NCC nCC)
        {
            if (ModelState.IsValid)
            {
                _context.Add(nCC);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(nCC));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create([Bind("UserId,UserName,PassWord,TrangThai")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Esempio n. 6
0
        public async Task <IActionResult> Create([Bind("MaCTHD,MaHD,MaSP,SoLuong,ThanhTien")] CTHD cTHD)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cTHD);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cTHD));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("MaHD,TongTien,UserID")] HoaDon hoaDon)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hoaDon);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserID"] = new SelectList(_context.User, "UserId", "UserId", hoaDon.UserID);
            return(View(hoaDon));
        }
Esempio n. 8
0
        public async Task <IActionResult> Create([Bind("IdComment,UserId,MaSP,NoiDung,Time")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(comment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaSP"] = new SelectList(_context.SanPham, "MaSP", "MaSP", comment.MaSP);
            return(View(comment));
        }
        public async Task <IActionResult> Create([Bind("MaLoai,Ten,TT,MaNCC")] LoaiSPModels loaiSPModels)
        {
            if (ModelState.IsValid)
            {
                _context.Add(loaiSPModels);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaNCC"] = new SelectList(_context.NCC, "ID", "ID", loaiSPModels.MaNCC);
            return(View(loaiSPModels));
        }
Esempio n. 10
0
        public async Task <IActionResult> Create([Bind("MaSP,TenSP,NgaySX,Hinh,MoTa,Gia,TrangThai,MaLoai")] SanPhamModels sanPhamModels, IFormFile ful)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sanPhamModels);
                await _context.SaveChangesAsync();

                var path = Path.Combine(
                    Directory.GetCurrentDirectory(), "wwwroot/img/product", sanPhamModels.MaSP + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1]);
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await ful.CopyToAsync(stream);
                }
                sanPhamModels.Hinh = sanPhamModels.MaSP + "." + ful.FileName.Split(".")[ful.FileName.Split(".").Length - 1];
                _context.Update(sanPhamModels);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaLoai"] = new SelectList(_context.LoaiSanPham, "MaLoai", "MaLoai", sanPhamModels.MaLoai);
            return(View(sanPhamModels));
        }