예제 #1
0
        public void AddLocation(LocationCommand locationCommand)
        {
            //var newStaff = new Nguoidung();
            var newLocation = new Diadiemdulich();

            {
                newLocation.Tendiadiem = locationCommand.Tendiadiem;
                newLocation.Mota       = locationCommand.Mota;
                newLocation.MienID     = locationCommand.MienID;
            }
            _db.Diadiemduliches.Add(newLocation);
            _db.SaveChanges();
        }
예제 #2
0
        public IActionResult OnePayResponseMienNam()
        {
            string hashValidateResult = "";

            //khởi tạo lớp thư viện
            VPCRequest conn = new VPCRequest(OnePayProperties.URL_ONEPAY_TEST);

            conn.SetSecureSecret(OnePayProperties.HASH_CODE);

            //lấy kết quả từ url được trả về từ cổng thanh toán
            hashValidateResult = conn.Process3rdPartyResponse(HttpUtility.ParseQueryString(Request.QueryString.ToString()));

            //lấy tham số trả về từ cổng thanh toán
            string vpc_TxnResponseCode = conn.GetResponseData("vpc_TxnResponseCode");
            string amount          = conn.GetResponseData("vpc_Amount");
            string localed         = conn.GetResponseData("vpc_Locale");
            string command         = conn.GetResponseData("vpc_Command");
            string version         = conn.GetResponseData("vpc_Version");
            string cardType        = conn.GetResponseData("vpc_Card");
            string orderInfo       = conn.GetResponseData("vpc_OrderInfo");
            string merchantID      = conn.GetResponseData("vpc_Merchant");
            string authorizeID     = conn.GetResponseData("vpc_AuthorizeId");
            string merchTxnRef     = conn.GetResponseData("vpc_MerchTxnRef");
            string transactionNo   = conn.GetResponseData("vpc_TransactionNo");
            string acqResponseCode = conn.GetResponseData("vpc_AcqResponseCode");
            string txnResponseCode = vpc_TxnResponseCode;
            string message         = conn.GetResponseData("vpc_Message");

            if (hashValidateResult == "CORRECTED" && txnResponseCode.Trim() == "0")
            {
                var hd = _hoaDonService.GetHoaDon();
                hd.Tinhtrang = 1;
                _db.Hoadons.Update(hd);
                _db.SaveChanges();
                return(RedirectToAction("ThanhToanTourMienNamThanhCong", "OnePay"));
            }
            else if (hashValidateResult == "INVALIDATED" && txnResponseCode.Trim() == "0")
            {
                return(View("/Views/OnePay/ThanhToanDangGiaiQuyet.cshtml"));
            }
            else
            {
                return(View("/Views/OnePay/ThanhToanKhongThanhCong.cshtml"));
            }
        }
예제 #3
0
        public void XoaTour(InsertTourCommand model)
        {
            var checkTour = _db.Tours.FirstOrDefault(n => n.ID == model.ID);

            {
                checkTour.Trangthai = "Xóa tour";
            }
            _db.SaveChanges();
        }
예제 #4
0
        public void AddStaff(NhanvienViewModel nhanvien, Taikhoan taikhoan)
        {
            var newStaff   = new Nguoidung();
            var newaccount = new Taikhoan();

            {
                newStaff.Hoten     = nhanvien.Hoten;
                newStaff.Sdt       = nhanvien.Sdt;
                newStaff.Email     = nhanvien.Email;
                newStaff.Gioitinh  = nhanvien.Gioitinh;
                newaccount.Email   = newStaff.Email;
                newaccount.Matkhau = taikhoan.Matkhau;
                newaccount.Vaitro  = taikhoan.Vaitro;
            }
            _db.Taikhoans.Add(newaccount);
            _db.Nguoidungs.Add(newStaff);
            _db.SaveChanges();
        }
        public void LienHe(LienHeViewModel lh)
        {
            var newLH = new LienHeViewModel
            {
                LoaiThongTin = lh.LoaiThongTin,
                HoTen        = lh.HoTen,
                Email        = lh.Email,
                Sdt          = lh.Sdt,
                TenCongTy    = lh.TenCongTy,
                SoKhach      = lh.SoKhach,
                TieuDe       = lh.TieuDe,
                NoiDung      = lh.NoiDung,
                XacNhan      = 0
            };
            var newLienHe = new LienHe(newLH);

            _db.LienHes.Add(newLienHe);
            _db.SaveChanges();
        }
        public void EditTour(TourViewModel command)
        {
            var checkTour = _db.Tours.FirstOrDefault(n => n.ID == command.ID);

            {
                checkTour.Tentour         = command.Tentour;
                checkTour.Diadiemkhoihanh = command.Diadiemkhoihanh;
                checkTour.Diemden         = command.Diemden;
                checkTour.Thuocmien       = command.Thuocmien;
                checkTour.Songuoi         = command.Songuoi;
                checkTour.Gianguoilon     = command.Gianguoilon;
                //checkTour.Giatreem = command.Giatreem;
                checkTour.Mota   = command.Mota;
                checkTour.Ngaydi = command.Ngaydi;
                //checkTour.Ngayve = command.Ngayve;
                checkTour.TenHDV     = command.TenHDV;
                checkTour.Thoigiandi = command.Thoigiandi;
                //checkTour.Trangthai = command.Trangthai;
            }
            _db.SaveChanges();
        }
        public void DatTourMienNam(DatTourValidation validation)
        {
            var tour = _db.Tours.FirstOrDefault(n => n.ID == validation.TourID);
            var kh   = _db.Khachhangs.FirstOrDefault(n => n.Cmnd == validation.Cmnd);

            if (kh == null)
            {
                var newKH = new Khachhang(validation);
                _db.Khachhangs.Add(newKH);
                _db.SaveChanges();

                //thêm thông tin tour miền Nam
                //thêm hóa đơn

                HoadonViewModel hd = new HoadonViewModel
                {
                    KhachhangID = newKH.ID,
                    Ngaylaphd   = DateTime.Now,
                    Ptthanhtoan = validation.Ptthanhtoan,
                    Tongtien    = validation.Tongtien,
                    Ghichu      = validation.Ghichu
                };
                var newHD = new Hoadon(hd);
                _db.Hoadons.Add(newHD);
                _db.SaveChanges();

                //update số chỗ của tour

                var cho = tour.Songuoi - validation.Songuoidi;
                if (cho == 0)
                {
                    tour.Trangthai = "hết chỗ";
                    _db.SaveChanges();
                }
                else
                {
                    tour.Songuoi = cho;
                    _db.SaveChanges();
                }

                //thêm chi tiết hóa đơn

                CTHoadonNamViewModel cthd = new CTHoadonNamViewModel
                {
                    Hotenkhachhang = newKH.Hoten,
                    Sdt            = newKH.Sdt,
                    Email          = newKH.Email,
                    Hoadoncode     = RandomString(),
                    Songuoidi      = validation.Songuoidi,
                    HoadonID       = newHD.ID,
                    TourID         = tour.ID
                };
                var newCTHD = new CTHoadonNam(cthd);
                _db.CTHoadonNams.Add(newCTHD);
                _db.SaveChanges();

                //send mail

                var webRoot    = _hostingEnvironment.WebRootPath;
                var body       = string.Empty;
                var pathToFile = _hostingEnvironment.WebRootPath
                                 + Path.DirectorySeparatorChar.ToString()
                                 + "templates"
                                 + Path.DirectorySeparatorChar.ToString()
                                 + "email"
                                 + Path.DirectorySeparatorChar.ToString()
                                 + "bookingdetail.html";
                using (StreamReader reader = new StreamReader(pathToFile))
                {
                    body = reader.ReadToEnd();
                }
                body = body.Replace("{{TourName}}", tour.Tentour);
                body = body.Replace("{{Code}}", tour.Code);
                body = body.Replace("{{Noixuatphat}}", tour.Diadiemkhoihanh);
                body = body.Replace("{{Diemden}}", tour.Diemden);
                body = body.Replace("{{Ngaydi}}", tour.Ngaydi.ToString());
                body = body.Replace("{{Sobooking}}", cthd.Hoadoncode);
                body = body.Replace("{{Tongtien}}", hd.Tongtien.ToString());
                body = body.Replace("{{Ngaydangky}}", hd.Ngaylaphd.ToString());
                body = body.Replace("{{Hinhthucthanhtoan}}", hd.Ptthanhtoan);
                //int day = hd.Ngaylaphd.Date + 7;
                body = body.Replace("{{Thoihanthanhtoan}}", "Vui lòng thanh toán trước khi tour khởi hành 3 ngày");
                body = body.Replace("{{Hoten}}", validation.Hoten);
                body = body.Replace("{{Diachi}}", validation.Diachi);
                body = body.Replace("{{Sdt}}", validation.Sdt);
                body = body.Replace("{{Email}}", validation.Email);
                body = body.Replace("{{Songuoidi}}", validation.Songuoidi.ToString());
                var mailHelper = new MailHelpers();
                mailHelper.SendMail(validation.Email, "Thông tin booking tour", body);
            }
            else
            {
                //thêm thông tin tour miền Nam
                //thêm hóa đơn

                HoadonViewModel hd = new HoadonViewModel
                {
                    KhachhangID = kh.ID,
                    Ngaylaphd   = DateTime.Now,
                    Ptthanhtoan = validation.Ptthanhtoan,
                    Tongtien    = validation.Tongtien,
                    Ghichu      = validation.Ghichu
                };
                var newHD = new Hoadon(hd);
                _db.Hoadons.Add(newHD);
                _db.SaveChanges();

                if (tour.Songuoi > 1)
                {
                    tour.Songuoi = tour.Songuoi - validation.Songuoidi;
                    _db.SaveChanges();
                }
                else
                {
                    tour.Songuoi   = tour.Songuoi - validation.Songuoidi;
                    tour.Trangthai = "hết chỗ";
                    _db.SaveChanges();
                }

                //thêm chi tiết hóa đơn

                CTHoadonNamViewModel cthd = new CTHoadonNamViewModel
                {
                    Hotenkhachhang = kh.Hoten,
                    Sdt            = kh.Sdt,
                    Email          = kh.Email,
                    Hoadoncode     = RandomString(),
                    Songuoidi      = validation.Songuoidi,
                    HoadonID       = newHD.ID,
                    TourID         = tour.ID
                };
                var newCTHD = new CTHoadonNam(cthd);
                _db.CTHoadonNams.Add(newCTHD);
                _db.SaveChanges();

                //send mail

                var webRoot    = _hostingEnvironment.WebRootPath;
                var body       = string.Empty;
                var pathToFile = _hostingEnvironment.WebRootPath
                                 + Path.DirectorySeparatorChar.ToString()
                                 + "templates"
                                 + Path.DirectorySeparatorChar.ToString()
                                 + "email"
                                 + Path.DirectorySeparatorChar.ToString()
                                 + "bookingdetail.html";
                using (StreamReader reader = new StreamReader(pathToFile))
                {
                    body = reader.ReadToEnd();
                }
                body = body.Replace("{{TourName}}", tour.Tentour);
                body = body.Replace("{{Code}}", tour.Code);
                body = body.Replace("{{Noixuatphat}}", tour.Diadiemkhoihanh);
                body = body.Replace("{{Diemden}}", tour.Diemden);
                body = body.Replace("{{Ngaydi}}", tour.Ngaydi.ToString());
                body = body.Replace("{{Sobooking}}", cthd.Hoadoncode);
                body = body.Replace("{{Tongtien}}", hd.Tongtien.ToString());
                body = body.Replace("{{Ngaydangky}}", hd.Ngaylaphd.ToString());
                body = body.Replace("{{Hinhthucthanhtoan}}", hd.Ptthanhtoan);
                //int day = hd.Ngaylaphd.Date + 7;
                body = body.Replace("{{Thoihanthanhtoan}}", "Vui lòng thanh toán trước khi tour khởi hành 3 ngày");
                body = body.Replace("{{Hoten}}", validation.Hoten);
                body = body.Replace("{{Diachi}}", validation.Diachi);
                body = body.Replace("{{Sdt}}", validation.Sdt);
                body = body.Replace("{{Email}}", validation.Email);
                body = body.Replace("{{Songuoidi}}", validation.Songuoidi.ToString());
                var mailHelper = new MailHelpers();
                mailHelper.SendMail(validation.Email, "Thông tin booking tour", body);
            }
        }
예제 #8
0
        public IActionResult InsertTour(InsertTourCommand tourCommand, Diadiemdulich diadiem, Mien mien)
        {
            List <Diadiemdulich> listDiadiem = new List <Models.db.Diadiemdulich>();

            listDiadiem = (from t in _db.Diadiemduliches
                           //where t.MienID == SelectedValue2
                           select t).ToList();
            ViewBag.ListDiaDiem = listDiadiem;
            List <Mien> listMien = new List <Models.db.Mien>();

            listMien         = (from t in _db.Miens select t).ToList();
            ViewBag.ListMien = listMien;
            string getNameLichTrinh = null;
            string getNamePicture   = null;

            if (ModelState.IsValid)
            {
                if (tourCommand != null)
                {
                    getNameLichTrinh = Path.GetFileName(tourCommand.Lichtrinh.FileName);
                    var uploadFolderLT       = Path.Combine(this._hostingEnvironment.WebRootPath, "docs/lichtrinh");
                    var getLichtrinhToFolder = Path.Combine(uploadFolderLT, getNameLichTrinh);
                    getNamePicture = Path.GetFileName(tourCommand.Hinhanh.FileName);
                    var uploadFolder       = Path.Combine(this._hostingEnvironment.WebRootPath, "images/tour_images");
                    var getPictureToFolder = Path.Combine(uploadFolder, getNamePicture);
                    if (System.IO.File.Exists(getPictureToFolder))
                    {
                        ViewBag.Picture = "Hinh anh da ton tai";
                        return(View());
                    }
                    else
                    {
                        var filestream2 = new FileStream(getLichtrinhToFolder, FileMode.Create);
                        tourCommand.Lichtrinh.CopyTo(filestream2);
                        var filestream = new FileStream(getPictureToFolder, FileMode.Create);
                        tourCommand.Hinhanh.CopyTo(filestream);
                        var newTour = new Tour();
                        {
                            //newTour.ID = _db.Tours.Count() + 1;
                            newTour.Tentour         = tourCommand.Tentour;
                            newTour.Code            = tourCommand.Code;
                            newTour.Diadiemkhoihanh = tourCommand.Diadiemkhoihanh;
                            newTour.Diemden         = tourCommand.Diemden;
                            newTour.Ngaydi          = tourCommand.Ngaydi;
                            newTour.Thuocmien       = tourCommand.Thuocmien;
                            if (tourCommand.Loaitour == "Trong nước")
                            {
                                newTour.Loaitour = "Trong nước";
                            }
                            else
                            {
                                newTour.Loaitour = "Nước ngoài";
                            }
                            newTour.Thoigiandi  = tourCommand.Thoigiandi;
                            newTour.Lichtrinh   = getNameLichTrinh;
                            newTour.Gianguoilon = tourCommand.Gianguoilon;
                            newTour.Hinhanh     = getNamePicture /*+ DateTime.Now.ToString()*/;
                            newTour.Mota        = tourCommand.Mota;
                            newTour.Songuoi     = tourCommand.Songuoi;
                            //newTour.Loaitour = tourCommand.Loaitour;
                            newTour.TenHDV    = tourCommand.TenHDV;
                            newTour.Trangthai = "Còn chỗ";
                            //foreach (var selectedId in tourCommand.MultiDiaDiem)
                            //{
                            //    _db.DiadiemTours.Add(new DiadiemTour
                            //    {
                            //        TourID = newTour.ID,
                            //        DiadiemdulichID = selectedId,
                            //    });
                            //}
                            //_db.SaveChanges();
                        }
                        _db.Tours.Add(newTour);
                        _db.SaveChanges();
                        RedirectToAction("Index", "Admin");
                    }
                }
            }
            return(View());
        }