Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("IDCTHD,IDHD,TenRap,TenPhim,GioChieu,NgayChieu,PhongChieu,TenGhe,SoLuong,GiaLG")] ChiTietHoaDonModel chiTietHoaDonModel)
        {
            if (id != chiTietHoaDonModel.IDCTHD)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(chiTietHoaDonModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChiTietHoaDonModelExists(chiTietHoaDonModel.IDCTHD))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IDHD"] = new SelectList(_context.HoaDon, "IDHD", "IDHD", chiTietHoaDonModel.IDHD);
            return(View(chiTietHoaDonModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,HoaDon_ID,TenSP,SoLuong,Gia,KhuyenMai,ThanhTien")] ChiTietHoaDonModel chiTietHoaDonModel)
        {
            if (id != chiTietHoaDonModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(chiTietHoaDonModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChiTietHoaDonModelExists(chiTietHoaDonModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HoaDon_ID"] = new SelectList(_context.HoaDonModel, "ID", "ID", chiTietHoaDonModel.HoaDon_ID);
            return(View(chiTietHoaDonModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("IdCTHD,IdHoaDon,idSanPham,SoLuong")] ChiTietHoaDonModel chiTietHoaDonModel)
        {
            if (id != chiTietHoaDonModel.IdCTHD)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(chiTietHoaDonModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChiTietHoaDonModelExists(chiTietHoaDonModel.IdCTHD))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(chiTietHoaDonModel));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutChiTietHoaDonModel(int id, ChiTietHoaDonModel chiTietHoaDonModel)
        {
            if (id != chiTietHoaDonModel.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("IdCTHD,IdHoaDon,idSanPham,SoLuong")] ChiTietHoaDonModel chiTietHoaDonModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(chiTietHoaDonModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(chiTietHoaDonModel));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("IDCTHD,IDHD,TenRap,TenPhim,GioChieu,NgayChieu,PhongChieu,TenGhe,SoLuong,GiaLG")] ChiTietHoaDonModel chiTietHoaDonModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(chiTietHoaDonModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IDHD"] = new SelectList(_context.HoaDon, "IDHD", "IDHD", chiTietHoaDonModel.IDHD);
            return(View(chiTietHoaDonModel));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Create([Bind("ID,HoaDon_ID,TenSP,SoLuong,Gia,KhuyenMai,ThanhTien")] ChiTietHoaDonModel chiTietHoaDonModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(chiTietHoaDonModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HoaDon_ID"] = new SelectList(_context.HoaDonModel, "ID", "ID", chiTietHoaDonModel.HoaDon_ID);
            return(View(chiTietHoaDonModel));
        }
 public async Task <IActionResult> PostSignalR(ChiTietHoaDonModel chiTietHoaDon)
 {
     try
     {
         _chiTietHoaDon.InsertData(chiTietHoaDon);
         await Hub.Clients.All.SendAsync("NewChiTiet", chiTietHoaDon);
     }
     catch (Exception ex)
     {
         return(BadRequest("Error while creating"));
     }
     return(Ok(chiTietHoaDon));
 }
 public void Delete(ChiTietHoaDonModel chiTietHoaDon)
 {
     _chiTietHoaDon.MyDeleteData(chiTietHoaDon);
 }
 public void Put(ChiTietHoaDonModel chiTietHoaDon)
 {
     _chiTietHoaDon.UpdateData(chiTietHoaDon);
 }
 public void Post(ChiTietHoaDonModel chiTietHoaDon)
 {
     _chiTietHoaDon.InsertData(chiTietHoaDon);
 }
Exemplo n.º 12
0
        public async Task <IActionResult> Create([Bind("ID,User_ID,HoTen,Sdt,ThanhTien,TrangThai")] HoaDonModel hoaDonModel, [Bind("ID,HoaDon_ID,TenSP,SoLuong,Gia,KhuyenMai,ThanhTien,TrangThai")] ChiTietHoaDonModel chitiethoaDonModel)
        {
            var HoaDon = from m in _context.HoaDonModel
                         select m;
            int size = HoaDon.Count();

            if (ModelState.IsValid)
            {
                _context.Add(hoaDonModel);
                size++;
                await _context.SaveChangesAsync();

                chitiethoaDonModel.HoaDon_ID = size;
                _context.Add(chitiethoaDonModel);
                await _context.SaveChangesAsync();

                HttpContext.Session.Remove("cart");
                var url = Url.RouteUrl(new { area = "", controller = "Pages", action = "Index" });
                return(Redirect(url));
            }
            ViewData["User_ID"] = new SelectList(_context.Set <UserModel>(), "ID", "ID", hoaDonModel.User_ID);
            return(View(hoaDonModel));
        }
Exemplo n.º 13
0
 public void UpdateChiTietHoaDon(ChiTietHoaDonModel ChiTietHoaDonModel)
 {
     BaseBLL <ChiTietHoaDon, ChiTietHoaDonModel> .Update(ChiTietHoaDonModel);
 }
Exemplo n.º 14
0
 public void InsertChiTietHoaDon(ChiTietHoaDonModel ChiTietHoaDon)
 {
     BaseBLL <ChiTietHoaDon, ChiTietHoaDonModel> .Insert(ChiTietHoaDon);
 }
Exemplo n.º 15
0
        public async Task <ActionResult <ChiTietHoaDonModel> > PostChiTietHoaDonModel(ChiTietHoaDonModel chiTietHoaDonModel)
        {
            _context.ChiTietHoaDonModel.Add(chiTietHoaDonModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetChiTietHoaDonModel", new { id = chiTietHoaDonModel.ID }, chiTietHoaDonModel));
        }