public async Task <ResponseEntity> ThongTinTaiKhoan()
        {
            var       accessToken = Request.Headers[HeaderNames.Authorization];
            userToken tttk        = commonService.getUserByToken(accessToken).Result;

            if (tttk == null)
            {
                return(new ResponseEntity(StatusCodeConstants.AUTHORIZATION, "Token đã hết hạn bạn hãy đăng nhập lại!", MessageConstant.MESSAGE_ERROR_401));
            }

            NguoiDung tt = db.NguoiDung.SingleOrDefault(n => n.TaiKhoan == tttk.taiKhoan);

            if (tt == null)
            {
                // I wish to return an error response how can i do that?
                //var response = await tbl.TBLoi(ThongBaoLoi.Loi400, "Tài khoản không hợp lệ!");
                //return response;
                return(new ResponseEntity(StatusCodeConstants.BAD_REQUEST, "Tài khoản không hợp lệ!", MessageConstant.BAD_REQUEST));
            }
            IEnumerable <DatVe>  lstDatVe         = db.DatVe.Where(n => n.TaiKhoanNguoiDung == tttk.taiKhoan).ToList();
            List <ThongTinDatVe> lstThongTinDatVe = new List <ThongTinDatVe>();

            if (lstDatVe.Count() != 0)
            {
                foreach (var item in lstDatVe.GroupBy(n => n.MaLichChieu))
                {
                    ThongTinDatVe ttdv = new ThongTinDatVe();
                    ttdv.MaVe = item.First().MaVe;
                    foreach (var ghe in item)
                    {
                        Ghe         gheNavigation = ghe.MaGheNavigation;
                        Rap         rap           = ghe.MaGheNavigation.MaRapNavigation;
                        CumRap      cumRap        = rap.MaCumRapNavigation;
                        HeThongRap  heThongRap    = cumRap.MaHeThongRapNavigation;
                        ThongTinGhe ttg           = new ThongTinGhe()
                        {
                            MaCumRap = rap.TenRap, TenCumRap = rap.TenRap, MaGhe = ghe.MaGhe, TenGhe = gheNavigation.TenGhe, MaRap = gheNavigation.MaRap, TenRap = rap.TenRap, MaHeThongRap = heThongRap.MaHeThongRap, TenHeThongRap = cumRap.TenCumRap
                        };
                        ttdv.DanhSachGhe.Add(ttg);
                    }
                    ttdv.NgayDat       = item.First().NgayDat.Value;
                    ttdv.HinhAnh       = DomainImage + item.First().MaLichChieuNavigation.MaPhimNavigation.HinhAnh;
                    ttdv.TenPhim       = item.First().MaLichChieuNavigation.MaPhimNavigation.TenPhim;
                    ttdv.GiaVe         = item.First().GiaVe.Value;
                    ttdv.ThoiLuongPhim = item.First().MaLichChieuNavigation.ThoiLuong.Value;
                    lstThongTinDatVe.Add(ttdv);
                }
            }

            ThongTinTaiKhoanVM ttTK = Mapper.Map <NguoiDung, ThongTinTaiKhoanVM>(tt);

            ttTK.ThongTinDatVe = lstThongTinDatVe;

            return(new ResponseEntity(StatusCodeConstants.OK, ttTK, MessageConstant.MESSAGE_SUCCESS_200));

            //return Ok(ttTK);
        }
 public void ThemHeThongRap(HeThongRap heThongRap)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         var p = new DynamicParameters();
         p.Add("@TENHETHONGRAP", heThongRap.TenHeThongRap);
         p.Add("@BIDANH", heThongRap.BiDanh);
         p.Add("@LOGO", heThongRap.Logo);
         connection.Query <HeThongRap>("HE_THONG_RAP_INSERT", p, commandType: CommandType.StoredProcedure);
     }
 }
コード例 #3
0
        public async Task <ActionResult> ThongTinTaiKhoan(LayThongTinCaNhanVM tttk)
        {
            NguoiDung tt = db.NguoiDung.SingleOrDefault(n => n.TaiKhoan == tttk.TaiKhoan);

            if (tt == null)
            {
                // I wish to return an error response how can i do that?
                var response = await tbl.TBLoi(ThongBaoLoi.Loi400, "Tài khoản không hợp lệ!");

                return(response);
            }
            IEnumerable <DatVe>  lstDatVe         = db.DatVe.Where(n => n.TaiKhoanNguoiDung == tttk.TaiKhoan).ToList();
            List <ThongTinDatVe> lstThongTinDatVe = new List <ThongTinDatVe>();

            if (lstDatVe.Count() != 0)
            {
                foreach (var item in lstDatVe.GroupBy(n => n.NgayDat))
                {
                    ThongTinDatVe ttdv = new ThongTinDatVe();
                    ttdv.MaVe = item.First().MaVe;
                    foreach (var ghe in item)
                    {
                        Ghe         gheNavigation = ghe.MaGheNavigation;
                        Rap         rap           = ghe.MaGheNavigation.MaRapNavigation;
                        CumRap      cumRap        = rap.MaCumRapNavigation;
                        HeThongRap  heThongRap    = cumRap.MaHeThongRapNavigation;
                        ThongTinGhe ttg           = new ThongTinGhe()
                        {
                            MaCumRap = rap.TenRap, TenCumRap = rap.TenRap, MaGhe = ghe.MaGhe, TenGhe = gheNavigation.TenGhe, MaRap = gheNavigation.MaRap, TenRap = rap.TenRap, MaHeThongRap = heThongRap.MaHeThongRap, TenHeThongRap = cumRap.TenCumRap
                        };
                        ttdv.DanhSachGhe.Add(ttg);
                    }
                    ttdv.NgayDat       = item.First().NgayDat.Value;
                    ttdv.TenPhim       = item.First().MaLichChieuNavigation.MaPhimNavigation.TenPhim;
                    ttdv.GiaVe         = item.First().GiaVe.Value;
                    ttdv.ThoiLuongPhim = item.First().MaLichChieuNavigation.ThoiLuong.Value;
                    lstThongTinDatVe.Add(ttdv);
                }
            }

            ThongTinTaiKhoanVM ttTK = Mapper.Map <NguoiDung, ThongTinTaiKhoanVM>(tt);

            ttTK.ThongTinDatVe = lstThongTinDatVe;


            return(Ok(ttTK));
        }
        public async Task <IEnumerable <HeThongRap> > LayThongTinHeThongRap(string maHeThongRap)
        {
            IEnumerable <HeThongRap> heThongRap = null;

            using (var connection = new SqlConnection(connectionString))
            {
                var p = new DynamicParameters();
                p.Add("@MAHETHONGRAP", maHeThongRap);
                heThongRap = connection.Query <HeThongRap>("HE_THONG_RAP_GET", p, commandType: CommandType.StoredProcedure);
                List <HeThongRap> dsHTR = new List <HeThongRap>();
                foreach (var item in heThongRap)
                {
                    HeThongRap heThongRapVM = new HeThongRap();
                    heThongRapVM.MaHeThongRap   = item.MaHeThongRap;
                    heThongRapVM.TenHeThongRap  = item.TenHeThongRap;
                    heThongRapVM.Logo           = item.Logo;
                    heThongRapVM.BiDanh         = item.BiDanh;
                    heThongRapVM.DanhSachCumRap = connection.Query <CumRap>("SELECT * FROM [dbo].[CUMRAP] WHERE MaHeThongRap = '" + item.MaHeThongRap + "'", commandType: CommandType.Text);
                    dsHTR.Add(heThongRapVM);
                }
                return(dsHTR);
            }
        }
コード例 #5
0
        public async Task <object> TaoLichChieu(LichChieuInsertVM lichChieuInsert)
        {
            var connection = new SqlConnection(connectionString);

            if (connection.State == ConnectionState.Closed)
            {
                connection.Open();
            }
            Phim phim = connection.QuerySingleOrDefault <Phim>("SELECT * FROM [dbo].[PHIM] WHERE MaPhim = " + lichChieuInsert.MaPhim, commandType: CommandType.Text);

            if (phim == null)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Mã phim không hợp lệ!"));
            }

            LichChieu lichModel = new LichChieu();

            //DateTime temp;
            //try
            //{
            //    if (DateTime.TryParse(lichChieuInsert.NgayChieuGioChieu, out temp))
            //    {
            //        lichModel.NgayChieuGioChieu = DateTimes.ConvertDateHour(lichChieuInsert.NgayChieuGioChieu);
            //    }
            //    else
            //    {
            //        return await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Ngày chiếu giờ chiếu không hợp lệ (có định dạng dd/MM/yyyy hh:mm:ss) !");
            //    }
            //}
            //catch (Exception ex)
            //{
            //    return await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Ngày chiếu giờ chiếu  không hợp lệ (có định dạng dd/MM/yyyy hh:mm:ss) !");
            //}
            lichModel.NgayChieuGioChieu = lichChieuInsert.NgayChieuGioChieu;

            Rap kiemTraRap = connection.QuerySingleOrDefault <Rap>("SELECT * FROM [dbo].[RAP] WHERE MaRap = " + lichChieuInsert.MaRap, commandType: CommandType.Text);

            if (kiemTraRap == null)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Mã rạp không tồn tại !"));
            }

            CumRap kiemTraCumRap = connection.QuerySingleOrDefault <CumRap>("SELECT * FROM [dbo].[CUMRAP] WHERE MaCumRap = '" + kiemTraRap.MaCumRap + "'", commandType: CommandType.Text);

            if (kiemTraCumRap == null)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Mã cụm rạp không tồn tại !"));
            }

            HeThongRap kiemTraHeThongRap = connection.QuerySingleOrDefault <HeThongRap>("SELECT * FROM [dbo].[HETHONGRAP] WHERE MaHeThongRap = '" + kiemTraCumRap.MaHeThongRap + "'", commandType: CommandType.Text);

            if (kiemTraHeThongRap == null)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Mã hệ thống rạp không tồn tại !"));
            }

            var listLichChieu    = connection.Query <LichChieu>("SELECT * FROM [dbo].[View_LICH_CHIEU_COMMON]", commandType: CommandType.Text);
            var kiemTraLichChieu = listLichChieu.Where(n => n.NgayChieuGioChieu.Date == lichModel.NgayChieuGioChieu.Date && n.MaPhim == phim.MaPhim && n.MaCumRap == kiemTraCumRap.MaCumRap && n.MaHeThongRap == kiemTraHeThongRap.MaHeThongRap && n.MaRap == lichChieuInsert.MaRap);
            //Trường hợp thời gian bắt đầu + thời lượng phim

            int      count      = 0;
            DateTime tgBDInsert = lichChieuInsert.NgayChieuGioChieu;
            DateTime tgKTInsert = lichChieuInsert.NgayChieuGioChieu.AddMinutes(phim.ThoiLuong);

            foreach (LichChieu lc in listLichChieu)
            {
                DateTime thoiGianBatDau  = lc.NgayChieuGioChieu;
                DateTime thoiGianKetThuc = lc.NgayChieuGioChieu.AddMinutes(phim.ThoiLuong);
                if (lichChieuInsert.MaRap == lc.MaRap)
                {
                    if ((tgBDInsert == thoiGianBatDau && tgKTInsert == thoiGianKetThuc) || (tgBDInsert > thoiGianBatDau && tgBDInsert < thoiGianKetThuc) || (tgKTInsert > thoiGianBatDau && tgKTInsert < thoiGianKetThuc) || tgBDInsert == thoiGianKetThuc || tgKTInsert == thoiGianBatDau)
                    {
                        count = count + 1;
                    }
                }
            }

            if (count > 0)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Lịch chiếu đã bị trùng !"));
            }

            //if (lichChieuInsert.GiaVe > 200000 || lichChieuInsert.GiaVe <= 45000)
            //{
            //    return await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Giá từ 45.000 - 200.000");
            //}
            //Lấy mã rạp ngẫu nhiên không có trong lst đó

            var param = new DynamicParameters();

            param.Add("@MARAP", lichChieuInsert.MaRap);
            param.Add("@MAPHIM", lichChieuInsert.MaPhim);
            param.Add("@NGAYCHIEUGIOCHIEU", lichModel.NgayChieuGioChieu);
            param.Add("@GIAVE", lichChieuInsert.GiaVe);
            param.Add("@GIAMGIA", lichChieuInsert.GiamGia);

            await connection.QueryAsync("LICH_CHIEU_INSERT", param, commandType : CommandType.StoredProcedure);

            return("Thêm lịch chiếu thành công !");
            //return tgKTInsert;
        }
コード例 #6
0
        public async Task <object> TaoLichChieu(LichChieuInsertVM lichChieuInsert)
        {
            var connection = new SqlConnection(connectionString);

            if (connection.State == ConnectionState.Closed)
            {
                connection.Open();
            }
            Phim phim = connection.QuerySingleOrDefault <Phim>("SELECT * FROM [dbo].[PHIM] WHERE MaPhim = " + lichChieuInsert.MaPhim, commandType: CommandType.Text);

            if (phim == null)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Mã phim không hợp lệ!"));
            }

            LichChieu lichModel = new LichChieu();

            //DateTime temp;
            //try
            //{
            //    if (DateTime.TryParse(lichChieuInsert.NgayChieuGioChieu, out temp))
            //    {
            //        lichModel.NgayChieuGioChieu = DateTimes.ConvertDateHour(lichChieuInsert.NgayChieuGioChieu);
            //    }
            //    else
            //    {
            //        return await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Ngày chiếu giờ chiếu không hợp lệ (có định dạng dd/MM/yyyy hh:mm:ss) !");
            //    }
            //}
            //catch (Exception ex)
            //{
            //    return await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Ngày chiếu giờ chiếu  không hợp lệ (có định dạng dd/MM/yyyy hh:mm:ss) !");
            //}
            lichModel.NgayChieuGioChieu = lichChieuInsert.NgayChieuGioChieu;

            Rap kiemTraRap = connection.QuerySingleOrDefault <Rap>("SELECT * FROM [dbo].[RAP] WHERE MaRap = " + lichChieuInsert.MaRap, commandType: CommandType.Text);

            if (kiemTraRap == null)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Mã rạp không tồn tại !"));
            }

            CumRap kiemTraCumRap = connection.QuerySingleOrDefault <CumRap>("SELECT * FROM [dbo].[CUMRAP] WHERE MaCumRap = '" + kiemTraRap.MaCumRap + "'", commandType: CommandType.Text);

            if (kiemTraCumRap == null)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Mã cụm rạp không tồn tại !"));
            }

            HeThongRap kiemTraHeThongRap = connection.QuerySingleOrDefault <HeThongRap>("SELECT * FROM [dbo].[HETHONGRAP] WHERE MaHeThongRap = '" + kiemTraCumRap.MaHeThongRap + "'", commandType: CommandType.Text);

            if (kiemTraHeThongRap == null)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Mã hệ thống rạp không tồn tại !"));
            }

            var listLichChieu    = connection.Query <LichChieu>("SELECT * FROM [dbo].[LICHCHIEU]", commandType: CommandType.Text);
            var kiemTraLichChieu = listLichChieu.Where(n => n.NgayChieuGioChieu.Date == lichModel.NgayChieuGioChieu.Date && n.MaPhim == phim.MaPhim && n.MaCumRap == kiemTraCumRap.MaCumRap && n.MaHeThongRap == kiemTraHeThongRap.MaHeThongRap && n.MaRap == lichChieuInsert.MaRap);

            if (kiemTraLichChieu.Count() > 0)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Lịch chiếu đã bị trùng !"));
            }

            if (lichChieuInsert.GiaVe > 200000 || lichChieuInsert.GiaVe < 75000)
            {
                return(await thongBaoLoi.thongBaoLoi(ThongBaoLoi.Loi500, "Giá từ 75.000 - 200.000"));
            }
            //Lấy mã rạp ngẫu nhiên không có trong lst đó

            var param = new DynamicParameters();

            param.Add("@MARAP", lichChieuInsert.MaRap);
            param.Add("@MAPHIM", lichChieuInsert.MaPhim);
            param.Add("@NGAYCHIEUGIOCHIEU", lichModel.NgayChieuGioChieu);
            param.Add("@GIAVE", lichChieuInsert.GiaVe);
            param.Add("@MAHETHONGRAP", kiemTraHeThongRap.MaHeThongRap);
            param.Add("@MACUMRAP", kiemTraCumRap.MaCumRap);

            await connection.QueryAsync("LICH_CHIEU_INSERT", param, commandType : CommandType.StoredProcedure);

            return("Thêm lịch chiếu thành công !");
            //return lichModel.NgayChieuGioChieu.Date;
        }
 public async Task <IActionResult> CapNhatHeThongRap(HeThongRap heThongRapCapNhat)
 {
     _quanLyHeThongRapRespository.CapNhatHeThongRap(heThongRapCapNhat);
     return(Ok());
 }
 public async Task <IActionResult> ThemHeThongRap(HeThongRap heThongRap)
 {
     _quanLyHeThongRapRespository.ThemHeThongRap(heThongRap);
     return(Ok());
 }