public string Get(int id, string tp, string qh, int rp, DateTime nc, DateTime gc, int p, int idnd, int lg, string ghe, DateTime nd, decimal gv)
        {
            JArray array = JsonConvert.DeserializeObject <JArray>(ghe);
            LinkedList <VeModel> list = new LinkedList <VeModel>();

            for (int i = 0; i < array.Count; i++)
            {
                VeModel veModel = new VeModel
                {
                    IdPhim      = id,
                    ThanhPho    = tp,
                    QuanHuyen   = qh,
                    IdRap       = rp,
                    NgayChieu   = nc,
                    GioChieu    = gc,
                    IdPhong     = p,
                    IdNguoiDung = idnd,
                    IdLoaiGhe   = lg,
                    TenGhe      = array[i].ToString(),
                    NgayDat     = nd,
                    GiaVe       = gv,
                };
                list.AddLast(veModel);
                _context.Add(veModel);
                _context.SaveChanges();
            }
            return(JsonConvert.SerializeObject(list));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdNguoiDung,IdLoaiGhe,IdPhong,IdPhim,ThanhPho,QuanHuyen,IdRap,NgayChieu,GioChieu,TenGhe,NgayDat,GiaVe")] VeModel veModel)
        {
            if (id != veModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(veModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VeModelExists(veModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdLoaiGhe"]   = new SelectList(_context.LoaiGhe, "Id", "TenLoaiGhe", veModel.IdLoaiGhe);
            ViewData["IdNguoiDung"] = new SelectList(_context.NguoiDung, "Id", "TaiKhoan", veModel.IdNguoiDung);
            ViewData["IdPhim"]      = new SelectList(_context.Phim, "Id", "TenPhim", veModel.IdPhim);
            ViewData["IdPhong"]     = new SelectList(_context.Phong, "Id", "TenPhong", veModel.IdPhong);
            return(View(veModel));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Gia,MaHoaDon,MaGhe,MaSuat,TrangThai")] VeModel veModel)
        {
            if (id != veModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(veModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VeModelExists(veModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaGhe"]    = new SelectList(_context.tb_Ghe, "Id", "Id", veModel.MaGhe);
            ViewData["MaHoaDon"] = new SelectList(_context.tb_HoaDon, "Id", "Id", veModel.MaHoaDon);
            ViewData["MaSuat"]   = new SelectList(_context.tb_SuatChieu, "Id", "Id", veModel.MaSuat);
            return(View(veModel));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("Id,Gia,MaHoaDon,MaGhe,MaSuat,TrangThai")] VeModel veModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(veModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MaGhe"]    = new SelectList(_context.tb_Ghe, "Id", "Id", veModel.MaGhe);
            ViewData["MaHoaDon"] = new SelectList(_context.tb_HoaDon, "Id", "Id", veModel.MaHoaDon);
            ViewData["MaSuat"]   = new SelectList(_context.tb_SuatChieu, "Id", "Id", veModel.MaSuat);
            return(View(veModel));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create([Bind("Id,IdNguoiDung,IdLoaiGhe,IdPhong,IdPhim,ThanhPho,QuanHuyen,IdRap,NgayChieu,GioChieu,TenGhe,NgayDat,GiaVe")] VeModel veModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(veModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdLoaiGhe"]   = new SelectList(_context.LoaiGhe, "Id", "TenLoaiGhe", veModel.IdLoaiGhe);
            ViewData["IdNguoiDung"] = new SelectList(_context.NguoiDung, "Id", "TaiKhoan", veModel.IdNguoiDung);
            ViewData["IdPhim"]      = new SelectList(_context.Phim, "Id", "TenPhim", veModel.IdPhim);
            ViewData["IdPhong"]     = new SelectList(_context.Phong, "Id", "TenPhong", veModel.IdPhong);
            return(Json(veModel));
        }
Esempio n. 6
0
        public async Task <string> PostVe(Ve ve)
        {
            var tt = from r in _context.RapChieuPhim
                     join p in _context.Phong on r.Id equals p.IdRapChieu
                     join lc in _context.LichChieu on p.Id equals lc.IdPhong
                     join sc in _context.SuatChieu on lc.Id equals sc.IdLichChieu
                     where sc.Id == ve.id
                     select new
            {
                Tp  = r.ThanhPho,
                qh  = r.QuanHuyen,
                idr = r.Id,
                nd  = DateTime.Now.Date,
            };
            JObject        nguoidung = JObject.Parse(HttpContext.Session.GetString("nguoidung"));
            NguoiDungModel mem       = new NguoiDungModel();

            mem.Id = (int)nguoidung.SelectToken("Id");
            decimal Gia = 0;

            if (tt != null)
            {
                foreach (string ghe in ve.dsghe.Split(","))
                {
                    VeModel Ve = new VeModel();
                    Ve.IdSuatChieu = (int)ve.id;
                    Ve.TenGhe      = ghe;
                    Ve.ThanhPho    = tt.Select(t => t.Tp).FirstOrDefault();
                    Ve.QuanHuyen   = tt.Select(t => t.qh).FirstOrDefault();
                    Ve.IdRap       = tt.Select(t => t.idr).FirstOrDefault();
                    Ve.NgayDat     = tt.Select(t => t.nd).FirstOrDefault();
                    Ve.IdLoaiGhe   = LoaiGhe(ghe);
                    Ve.GiaVe       = TinhTien(Ve.IdSuatChieu, Ve.IdLoaiGhe);
                    Ve.IdNguoiDung = mem.Id;

                    try
                    {
                        _context.Add(Ve);
                        await _context.SaveChangesAsync();

                        Gia += Ve.GiaVe;
                    }
                    catch { return("{\"result\":\"" + false + "\"}"); }
                }
            }
            return("{\"result\":\"" + Gia + "vnd\"}");
        }