Example #1
0
        void StartLoading(TVChannelModel tvChannel)
        {
            LichChieu.Items.Clear();
            string text = "";

            using (WebClient wc = new WebClient())
            {
                text = wc.DownloadString(new Uri(tvChannel.LinkLichChieu, UriKind.RelativeOrAbsolute));
                text = Regex.Unescape(text);
            }
            HtmlDocument doc = new HtmlDocument();

            doc.LoadHtml(text);
            var allNodes = doc.DocumentNode.SelectNodes("/p");

            if (allNodes.Any())
            {
                foreach (var node in allNodes)
                {
                    SuatChieuModel sc = new SuatChieuModel();
                    sc.Time = node.SelectSingleNode(node.XPath + "/strong").InnerText;
                    sc.Name = node.InnerText.Replace(sc.Time, "");
                    LichChieu.Items.Add(sc);
                }
            }
            LoadingGrid.Visibility = Visibility.Visible;
        }
        public async Task <bool> Edit(int id, [Bind("Id,NgayChieu,ThoiGianBatDau,TrangThai,MaPhong,MaPhim")] SuatChieuModel suatChieuModel)
        {
            if (id != suatChieuModel.Id)
            {
                return(false);
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(suatChieuModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SuatChieuModelExists(suatChieuModel.Id))
                    {
                        return(false);
                    }
                    else
                    {
                        throw;
                    }
                }
                return(true);
            }
            //ViewData["MaPhim"] = new SelectList(_context.tb_Phim, "Id", "HinhAnh", suatChieuModel.MaPhim);
            //ViewData["MaPhong"] = new SelectList(_context.tb_Phong, "Id", "TenPhong", suatChieuModel.MaPhong);
            return(false);
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdLoaiSuatChieu,IdPhim,IdLichChieu,GioChieu,TinhTrang")] SuatChieuModel suatChieuModel)
        {
            if (id != suatChieuModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(suatChieuModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SuatChieuModelExists(suatChieuModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdLichChieu"]     = new SelectList(_context.LichChieu, "Id", "Id", suatChieuModel.IdLichChieu);
            ViewData["IdPhim"]          = new SelectList(_context.Phim, "Id", "TenPhim", suatChieuModel.IdPhim);
            ViewData["IdLoaiSuatChieu"] = new SelectList(_context.LoaiSuatChieu, "Id", "Id", suatChieuModel.IdLoaiSuatChieu);
            return(View(suatChieuModel));
        }
Example #4
0
        public async Task <ActionResult <SuatChieuModel> > PostSuatChieuModel(SuatChieuModel suatChieuModel)
        {
            _context.tb_SuatChieu.Add(suatChieuModel);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSuatChieuModel", new { id = suatChieuModel.Id }, suatChieuModel));
        }
Example #5
0
        public async Task <IActionResult> PutSuatChieuModel(int id, SuatChieuModel suatChieuModel)
        {
            if (id != suatChieuModel.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <bool> Create([Bind("Id,NgayChieu,ThoiGianBatDau,TrangThai,MaPhong,MaPhim")] SuatChieuModel suatChieuModel)
        {
            if (ModelState.IsValid)
            {
                suatChieuModel.TrangThai = true;
                _context.Add(suatChieuModel);
                await _context.SaveChangesAsync();

                return(true);
            }
            return(false);
        }
Example #7
0
        public async Task <IActionResult> Create([Bind("Id,IdLoaiSuatChieu,IdPhim,IdLichChieu,GioChieu,TinhTrang")] SuatChieuModel suatChieuModel)
        {
            if (ModelState.IsValid)
            {
                suatChieuModel.TinhTrang = true;
                _context.Add(suatChieuModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdLichChieu"]     = new SelectList(_context.LichChieu, "Id", "Id", suatChieuModel.IdLichChieu);
            ViewData["IdPhim"]          = new SelectList(_context.Phim, "Id", "TenPhim", suatChieuModel.IdPhim);
            ViewData["IdLoaiSuatChieu"] = new SelectList(_context.LoaiSuatChieu, "Id", "Id", suatChieuModel.IdLoaiSuatChieu);
            return(View(suatChieuModel));
        }
        // GET: Admin/SuatChieu
        public async Task <IActionResult> Index(int?id)
        {
            ViewBag.ListSch = (from n in _context.tb_SuatChieu where n.TrangThai == true select n).ToList();
            foreach (var item in ViewBag.ListSch)
            {
                if (item.ThoiGianBatDau < DateTime.Now && item.NgayChieu == DateTime.Now)
                {
                    item.TrangThai = false;
                    _context.Update(item);
                }
            }
            await _context.SaveChangesAsync();

            SuatChieuModel suatChieu = null;

            if (id != null)
            {
                suatChieu = await _context.tb_SuatChieu.FirstOrDefaultAsync(m => m.Id == id && m.TrangThai == true);
            }
            return(View(suatChieu));
        }