Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdPhong,IdPhim,NgayCongChieu")] LichChieuModel lichChieuModel)
        {
            if (id != lichChieuModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lichChieuModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LichChieuModelExists(lichChieuModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdPhong"] = new SelectList(_context.Phong, "Id", "TenPhong", lichChieuModel.IdPhong);
            return(View(lichChieuModel));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Ngay,Da_xoa,RapPhim_ID")] LichChieuModel lichChieuModel)
        {
            if (id != lichChieuModel.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lichChieuModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LichChieuModelExists(lichChieuModel.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RapPhim_ID"] = new SelectList(_context.Set <RapPhimModel>(), "ID", "ID", lichChieuModel.RapPhim_ID);
            return(View(lichChieuModel));
        }
        public async Task <ActionResult <LichChieuModel> > PostLichChieuModel(LichChieuModel lichChieuModel)
        {
            _context.lichChieuModels.Add(lichChieuModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetLichChieuModel", new { id = lichChieuModel.IdLichChieu }, lichChieuModel));
        }
        public async Task <IActionResult> PutLichChieuModel(int id, LichChieuModel lichChieuModel)
        {
            if (id != lichChieuModel.IdLichChieu)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #5
0
        public async Task <IActionResult> Edit(int id, [Bind("IdLichChieu,NgayChieu,GioBatDau,GioKetThuc,GiaVe,MaPhong,MaPhim,MaGiamGia")] LichChieuModel lichChieuModel)
        {
            if (id != lichChieuModel.IdLichChieu)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lichChieuModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LichChieuModelExists(lichChieuModel.IdLichChieu))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaGiamGia"] = new SelectList(_context.giamGiaModels, "IdMaGiamGia", "IdMaGiamGia", lichChieuModel.MaGiamGia);
            return(View(lichChieuModel));
        }
Example #6
0
        public async Task <IActionResult> Create([Bind("Id,IdPhong,NgayChieu")] LichChieuModel lichChieuModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lichChieuModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdPhong"] = new SelectList(_context.Phong, "Id", "TenPhong", lichChieuModel.IdPhong);
            return(View(lichChieuModel));
        }
        public async Task <IActionResult> Create([Bind("ID,Ngay,Da_xoa,RapPhim_ID")] LichChieuModel lichChieuModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lichChieuModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RapPhim_ID"] = new SelectList(_context.Set <RapPhimModel>(), "ID", "ID", lichChieuModel.RapPhim_ID);
            return(View(lichChieuModel));
        }
Example #8
0
        public async Task <IActionResult> Create([Bind("IdLichChieu,NgayChieu,GioBatDau,GioKetThuc,GiaVe,MaPhong,MaPhim,MaGiamGia")] LichChieuModel lichChieuModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(lichChieuModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaGiamGia"] = new SelectList(_context.giamGiaModels, "IdMaGiamGia", "IdMaGiamGia", lichChieuModel.MaGiamGia);
            return(View(lichChieuModel));
        }
Example #9
0
        public IActionResult Index(int id, int phong = -1)
        {
            LichChieuModel mod = null;

            if (id != null)
            {
                mod = _context.LichChieu.FirstOrDefault(s => s.Id == id);
            }
            ViewBag.List = _context.LichChieu.Include(l => l.Phong);
            if (phong > 0)
            {
            }
            ViewData["IdPhong"] = new SelectList(_context.Phong, "Id", "TenPhong");
            return(View(mod));
        }
Example #10
0
        public async Task <IActionResult> Create([Bind("Id,IdPhong,NgayChieu")] LichChieuModel lichChieuModel)
        {
            var exit = from lc in _context.LichChieu
                       where lc.IdPhong == lichChieuModel.IdPhong &&
                       lc.NgayChieu == lichChieuModel.NgayChieu
                       select lc;

            if (exit.Count() != 0)
            {
                ViewData["IdPhong"] = new SelectList(_context.Phong, "Id", "TenPhong", lichChieuModel.IdPhong);
                return(View("Index"));
            }
            if (ModelState.IsValid)
            {
                _context.Add(lichChieuModel);
                await _context.SaveChangesAsync();
            }
            ViewData["IdPhong"] = new SelectList(_context.Phong, "Id", "TenPhong", lichChieuModel.IdPhong);
            return(View("Index"));

            return(View("Index"));
        }