public ActionResult SaveReservation(ReservationModel ObjModel, string rdPaymentMethod)
        {
            TempData["ReservationModel"] = ObjModel;
            ObjModel._hotel = _context.JW_Hotels.Where(w => w.HotelCode == ObjModel._hotelCode).FirstOrDefault();

            string BookingID = ObjModel.BookingID;
            string userName = "******";
            string Password = "******";
            string customerName = ObjModel._delegate.Name;
            string email = ObjModel._delegate.EmailAddress;
            string ConventionCode = "JWCON";
            string Language = "en";
            string Currency = "USD";


            DateTime _fromDate = DateTime.ParseExact(ObjModel._fromDate, "dd/MM/yyyy", null);
            DateTime _toDate = DateTime.ParseExact(ObjModel._toDate, "dd/MM/yyyy", null);

            double _beforeDays = 0;
            int _packageDays = 0;
            double _afterDays = 0;
            double TotalCost = 0;

            DateTime _StartingDate = DateTime.ParseExact("04/07/2018", "dd/MM/yyyy", null);
            TimeSpan t = _StartingDate - _fromDate;
            //_beforeDays = t.TotalDays;

            DateTime _7dayPackage = DateTime.ParseExact("09/07/2018", "dd/MM/yyyy", null);
            DateTime _8dayPackage = DateTime.ParseExact("10/07/2018", "dd/MM/yyyy", null);
            DateTime _9dayPackage = DateTime.ParseExact("11/07/2018", "dd/MM/yyyy", null);
            DateTime _10dayPackage = DateTime.ParseExact("12/07/2018", "dd/MM/yyyy", null);

            int PackageId = 0;

            int roomType = Convert.ToInt32(ObjModel._roomType);

            _packageDays = (int)(_toDate - _fromDate).TotalDays;
            JW_RoomRate roomDetails = _context.JW_RoomRate.Where(w => w.RoomID == roomType && w.PackageId == 1 && w.Occupancy == ObjModel._Occupancy).FirstOrDefault();
            if (roomDetails != null)
            {
                TotalCost = (double)(roomDetails.RoomRate / 7) * _packageDays;
                //Allotment = (int)roomDetails.RemainingAllotment;
            }
            else
            {
                TotalCost = 0;
                //Allotment = 0;
            }

            //if (_toDate == _7dayPackage)
            //{
            //    _packageDays += 7;
            //    _afterDays = (_toDate - _7dayPackage).TotalDays;
            //    _packageDays += (int)_afterDays;
            //    _packageDays += (int)_beforeDays;
            //    TotalCost = (double)_context.JW_RoomRate.Where(w => w.PackageId == 1 && w.RoomID == roomType && w.Occupancy == ObjModel._Occupancy).FirstOrDefault().RoomRate;
            //    PackageId = 1;
            //}
            //else if (_toDate > _7dayPackage && _toDate <= _8dayPackage)
            //{
            //    _packageDays += 8;
            //    _afterDays = (_toDate - _8dayPackage).TotalDays;
            //    _packageDays += (int)_afterDays;
            //    _packageDays += (int)_beforeDays;
            //    TotalCost = (double)_context.JW_RoomRate.Where(w => w.PackageId == 2 && w.RoomID == roomType && w.Occupancy == ObjModel._Occupancy).FirstOrDefault().RoomRate;
            //    PackageId = 2;
            //}
            //else if (_toDate > _8dayPackage && _toDate <= _9dayPackage)
            //{
            //    _packageDays += 9;
            //    _afterDays = (_toDate - _9dayPackage).TotalDays;
            //    _packageDays += (int)_afterDays;
            //    _packageDays += (int)_beforeDays;
            //    TotalCost = (double)_context.JW_RoomRate.Where(w => w.PackageId == 3 && w.RoomID == roomType && w.Occupancy == ObjModel._Occupancy).FirstOrDefault().RoomRate;
            //    PackageId = 3;
            //}
            //else if (_toDate > _9dayPackage && _toDate <= _10dayPackage)
            //{
            //    _packageDays += 10;
            //    _afterDays = (_toDate - _10dayPackage).TotalDays;
            //    _packageDays += (int)_afterDays;
            //    _packageDays += (int)_beforeDays;
            //    TotalCost = (double)_context.JW_RoomRate.Where(w => w.PackageId == 4 && w.RoomID == roomType && w.Occupancy == ObjModel._Occupancy).FirstOrDefault().RoomRate;
            //    PackageId = 4;
            //}
            //else if (_toDate > _10dayPackage)
            //{
            //    _packageDays += 10;
            //    _afterDays = (_toDate - _10dayPackage).TotalDays;
            //    _packageDays += (int)_afterDays;
            //    _packageDays += (int)_beforeDays;
            //    TotalCost = (double)_context.JW_RoomRate.Where(w => w.PackageId == 4 && w.RoomID == roomType && w.Occupancy == ObjModel._Occupancy).FirstOrDefault().RoomRate;
            //    PackageId = 4;
            //}



            //if(_beforeDays > 0)
            //{
            //    double cost = (double)_context.JW_AdditionalRoomRates.Where(w=>w.RoomID == roomType && w.Occupancy == ObjModel._Occupancy).FirstOrDefault().RoomRate;
            //    TotalCost = TotalCost + (cost * _beforeDays);
            //}
            //if(_afterDays > 0)
            //{
            //    double cost = (double)_context.JW_AdditionalRoomRates.Where(w=> w.RoomID == roomType && w.Occupancy == ObjModel._Occupancy).FirstOrDefault().RoomRate;
            //    TotalCost = TotalCost + (cost * _afterDays);
            //}

            JW_Delegates _delegate = new JW_Delegates();
            _delegate.BookingID = ObjModel.BookingID;
            _delegate.ContactNo = ObjModel._delegate.ContactNo;
            _delegate.Country = ObjModel._delegate.Country;
            _delegate.DelegeteName = ObjModel._delegate.Name;
            _delegate.Email = ObjModel._delegate.EmailAddress;
            _delegate.Nationality = ObjModel._delegate.Nationality;
            _delegate.PassportNo = ObjModel._delegate.PassportNo;
            _delegate.Title = ObjModel._delegate.Title;
            _delegate.Address = ObjModel._delegate.DelegateAddress;

            _context.JW_Delegates.Add(_delegate);
            _context.SaveChanges();




            DateTime CheckInDate = DateTime.ParseExact(ObjModel._fromDate, "dd/MM/yyyy", null);
            DateTime CheckOutDate = DateTime.ParseExact(ObjModel._toDate, "dd/MM/yyyy", null);

            DateTime ArrivalDate = DateTime.ParseExact(ObjModel._ArrivalDate, "dd/MM/yyyy", null);
            DateTime DepartureDate = DateTime.ParseExact(ObjModel._DepartureDate, "dd/MM/yyyy", null);



            JW_Reservation _reservation = new JW_Reservation();
            _reservation.HotelName = ObjModel._hotel.HotelName;
            _reservation.BookingID = ObjModel.BookingID;
            _reservation.ArrivalFlightNo = ObjModel._ArrivalFlightNumber;
            _reservation.DepartureFlightNo = ObjModel._DepartureFlightNumber;
            _reservation.CheckInDate = CheckInDate;
            _reservation.CheckInTime = ObjModel._ArrivalTime;
            _reservation.CheckOutDate = CheckOutDate;
            _reservation.ArrivalDate = ArrivalDate;
            _reservation.DepartureDate = DepartureDate;
            _reservation.CheckOutTime = ObjModel._DepartureTime;
            _reservation.IsArrivalTransportRequired = ObjModel._isArrival;
            _reservation.IsDepartureTransportRequired = ObjModel._isDeparture;
            _reservation.Roomtype = Convert.ToInt32(ObjModel._roomType);
            _reservation.Occupancy = ObjModel._Occupancy;
            _reservation.BedPreference = ObjModel._BedPerferance;
            _reservation.TotalCost = TotalCost;
            _reservation.NightBefore = Convert.ToInt32(_beforeDays);
            _reservation.Package = Convert.ToInt32(_packageDays);
            _reservation.NightAfter = Convert.ToInt32(_afterDays);

            if (rdPaymentMethod == "Half")
            {
                _reservation.IsAdvancePayment = true;
            }
            else
            {
                _reservation.IsAdvancePayment = false;
            }

            _context.JW_Reservation.Add(_reservation);
            _context.SaveChanges();

            if (rdPaymentMethod == "Half")
            {
                TotalCost = TotalCost / 2;
            }

            Encryption encry = new Encryption();
            string _amount = encry.EncryptString(TotalCost.ToString(), "Amount");

            _reservation.PreHashKey = _amount;
            _context.Entry(_reservation).State = System.Data.Entity.EntityState.Modified;
            _context.SaveChanges();

            //string url = "http://payment.walkerstours.net/Payment/WebPortal";
            string url = "https://webportal.walkerstours.com/Events/Payment/WebPortal";

            Response.Clear();
            var sb = new System.Text.StringBuilder();
            sb.Append("<html>");
            sb.AppendFormat("<body onload='document.forms[0].submit()'>");
            sb.AppendFormat("<form action='{0}' method='post'>", url);
            sb.AppendFormat("<input type='hidden' id='CustomerRef' name='CustomerRef' value='" + BookingID + "'>", BookingID);
            sb.AppendFormat("<input type='hidden' id='Amount' name='Amount' value='" + TotalCost + "'>", TotalCost);
            sb.AppendFormat("<input type='hidden' id='UserName' name='UserName' value='" + userName + "'>", userName);
            sb.AppendFormat("<input type='hidden' id='Password' name='Password' value='" + Password + "'>", Password);
            sb.AppendFormat("<input type='hidden' id='customername' name='customername' value='" + customerName + "'>", customerName);
            sb.AppendFormat("<input type='hidden' id='email' name='email' value='" + email + "'>", email);
            sb.AppendFormat("<input type='hidden' id='conventioncode' name='conventioncode' value='" + ConventionCode + "'>", ConventionCode);
            sb.AppendFormat("<input type='hidden' id='language' name='language' value='" + Language + "'>", Language);
            sb.AppendFormat("<input type='hidden' id='_currency' name='_currency' value='" + Currency + "'>", Currency);
            sb.Append("</form>");
            sb.Append("</body>");
            sb.Append("</html>");
            //Response.Write(sb.ToString());
            //Response.End();

            return Content(sb.ToString());

            //  }

            //  return null;
            // return RedirectToAction("AddtionalAccomerdation", "Reservation");
        }
示例#2
0
        public virtual JsonResult DateCheck(string fromDate, string endDate, string roomID, string Occupancy)
        {
            try
            {
                DateTime _fromDate = DateTime.ParseExact(fromDate, "dd/MM/yyyy", null);
                DateTime _toDate   = DateTime.ParseExact(endDate, "dd/MM/yyyy", null);

                int    days         = 0;
                double _beforeDays  = 0;
                int    _packageDays = 0;
                double _afterDays   = 0;
                double TotalCost    = 0;
                int    Allotment    = 0;
                int    RoomId       = Convert.ToInt32(roomID);
                string Message      = "";


                DateTime ConventionDate1 = DateTime.ParseExact("05/07/2018", "dd/MM/yyyy", null);
                DateTime ConventionDate2 = DateTime.ParseExact("06/07/2018", "dd/MM/yyyy", null);
                DateTime ConventionDate3 = DateTime.ParseExact("07/07/2018", "dd/MM/yyyy", null);

                if (_toDate == ConventionDate1 || _toDate == ConventionDate2 || _toDate == ConventionDate3 || _fromDate == ConventionDate1 || _fromDate == ConventionDate2 || _fromDate == ConventionDate3)
                {
                    return(Json(new { BeforeDays = _beforeDays, PackageDays = _packageDays, AfterDays = _afterDays, TotalCost = TotalCost, Allotment = Allotment, Message = "Convention Dates" }, JsonRequestBehavior.AllowGet));
                }

                if ((_toDate - _fromDate).TotalDays < 7)
                {
                    return(Json(new { BeforeDays = _beforeDays, PackageDays = _packageDays, AfterDays = _afterDays, TotalCost = TotalCost, Allotment = Allotment, Message = "Failed" }, JsonRequestBehavior.AllowGet));
                }


                DateTime _StartingDate = DateTime.ParseExact("04/07/2018", "dd/MM/yyyy", null);
                TimeSpan t             = _StartingDate - _fromDate;
                //_beforeDays = t.TotalDays;

                DateTime _7dayPackage  = DateTime.ParseExact("11/07/2018", "dd/MM/yyyy", null);
                DateTime _8dayPackage  = DateTime.ParseExact("12/07/2018", "dd/MM/yyyy", null);
                DateTime _9dayPackage  = DateTime.ParseExact("13/07/2018", "dd/MM/yyyy", null);
                DateTime _10dayPackage = DateTime.ParseExact("14/07/2018", "dd/MM/yyyy", null);


                _packageDays = (int)(_toDate - _fromDate).TotalDays;
                JW_RoomRate roomDetails = _context.JW_RoomRate.Where(w => w.RoomID == RoomId && w.PackageId == 1 && w.Occupancy == Occupancy).FirstOrDefault();
                if (roomDetails != null)
                {
                    TotalCost = (double)(roomDetails.RoomRate / 7) * _packageDays;
                    Allotment = (int)roomDetails.RemainingAllotment;
                }
                else
                {
                    TotalCost = 0;
                    Allotment = 0;
                }

                //if (_toDate ==_7dayPackage)
                //{
                //    _packageDays += 7;
                //    _afterDays = (_toDate - _7dayPackage).TotalDays;
                //    _packageDays += (int)_afterDays;
                //    _packageDays += (int)_beforeDays;
                //    JW_RoomRate roomDetails = _context.JW_RoomRate.Where(w => w.RoomID == RoomId && w.PackageId == 1 && w.Occupancy == Occupancy).FirstOrDefault();
                //    if (roomDetails != null)
                //    {
                //        TotalCost = (double)roomDetails.RoomRate;
                //        Allotment = (int)roomDetails.RemainingAllotment;
                //    }
                //    else
                //    {
                //        TotalCost = 0;
                //        Allotment = 0;
                //    }
                //}
                //else if(_toDate > _7dayPackage && _toDate <= _8dayPackage)
                //{
                //    _packageDays += 8;
                //    _afterDays = (_toDate - _8dayPackage).TotalDays;
                //    _packageDays += (int)_afterDays;
                //    _packageDays += (int)_beforeDays;
                //    JW_RoomRate roomDetails = _context.JW_RoomRate.Where(w => w.RoomID == RoomId && w.PackageId == 2 && w.Occupancy == Occupancy).FirstOrDefault();
                //    if (roomDetails != null)
                //    {
                //        TotalCost = (double)roomDetails.RoomRate;
                //        Allotment = (int)roomDetails.RemainingAllotment;
                //    }
                //    else
                //    {
                //        TotalCost = 0;
                //        Allotment = 0;
                //    }
                //}
                //else if (_toDate > _8dayPackage && _toDate <= _9dayPackage)
                //{
                //    _packageDays += 9;
                //    _afterDays = (_toDate - _9dayPackage).TotalDays;
                //    _packageDays += (int)_afterDays;
                //    _packageDays += (int)_beforeDays;
                //    JW_RoomRate roomDetails = _context.JW_RoomRate.Where(w => w.RoomID == RoomId && w.PackageId == 3 && w.Occupancy == Occupancy).FirstOrDefault();
                //    if (roomDetails != null)
                //    {
                //        TotalCost = (double)roomDetails.RoomRate;
                //        Allotment = (int)roomDetails.RemainingAllotment;
                //    }
                //    else
                //    {
                //        TotalCost = 0;
                //        Allotment = 0;
                //    }
                //}
                //else if (_toDate > _9dayPackage && _toDate <= _10dayPackage)
                //{
                //    _packageDays += 10;
                //    _afterDays = (_toDate - _10dayPackage).TotalDays;
                //    _packageDays += (int)_afterDays;
                //    _packageDays += (int)_beforeDays;
                //    JW_RoomRate roomDetails = _context.JW_RoomRate.Where(w => w.RoomID == RoomId && w.PackageId == 4 && w.Occupancy == Occupancy).FirstOrDefault();
                //    if (roomDetails != null)
                //    {
                //        TotalCost = (double)roomDetails.RoomRate;
                //        Allotment = (int)roomDetails.RemainingAllotment;
                //    }
                //    else
                //    {
                //        TotalCost = 0;
                //        Allotment = 0;
                //    }
                //}
                //else if(_toDate > _10dayPackage)
                //{
                //    _packageDays += 10;
                //    _afterDays = (_toDate - _10dayPackage).TotalDays;
                //    _packageDays += (int)_afterDays;
                //    _packageDays += (int)_beforeDays;
                //    JW_RoomRate roomDetails = _context.JW_RoomRate.Where(w => w.RoomID == RoomId && w.PackageId == 4 && w.Occupancy == Occupancy).FirstOrDefault();
                //    if (roomDetails != null)
                //    {
                //        TotalCost = (double)roomDetails.RoomRate;
                //        Allotment = (int)roomDetails.RemainingAllotment;
                //    }
                //    else
                //    {
                //        TotalCost = 0;
                //        Allotment = 0;
                //    }
                //}

                //if (_beforeDays > 0)
                //{
                //    var result = _context.JW_AdditionalRoomRates.Where(w => w.RoomID == RoomId && w.Occupancy == Occupancy).FirstOrDefault().RoomRate;
                //    if(result != null)
                //    {
                //        double cost = (double)result;
                //        TotalCost = TotalCost + (cost * _beforeDays);
                //    }
                //}
                //if (_afterDays > 0)
                //{
                //    var result = _context.JW_AdditionalRoomRates.Where(w => w.RoomID == RoomId && w.Occupancy == Occupancy).FirstOrDefault().RoomRate;
                //    if (result != null)
                //    {
                //        double cost = (double)result;
                //        TotalCost = TotalCost + (cost * _afterDays);
                //    }
                //}

                return(Json(new { BeforeDays = _beforeDays, PackageDays = _packageDays, AfterDays = _afterDays, TotalCost = TotalCost, Allotment = Allotment, Message = "Sucess" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }
        }