Ejemplo n.º 1
0
        public ActionResult SendInquiry(InquiryModel objModel)
        {
            try
            {
                IPGConfig ipg = _context.IPGConfigs.Where(w => w.ConventionCode == "JWCON").FirstOrDefault();

                EmailModel em = new EmailModel();
                em.FullName    = objModel.FullName;
                em.EmailTo     = ipg.EmailTo;
                em.ClientEmail = objModel.Email;
                em.ContactNo   = objModel.ContactNo;
                em.Message     = objModel.Message;
                em.TourName    = objModel.TourName.Replace("_", " ");
                em.EmailCC     = ipg.EmailCC;
                em.EmailBCC    = ipg.EmailBCC;

                em.SendInquiry(em, "Inquiry");

                EmailModel clientCopy = new EmailModel();
                clientCopy.FullName    = objModel.FullName;
                em.EmailTo             = objModel.Email;
                clientCopy.ClientEmail = objModel.Email;
                clientCopy.ContactNo   = objModel.ContactNo;
                clientCopy.Message     = objModel.Message;
                clientCopy.TourName    = objModel.TourName.Replace("_", " ");
                clientCopy.EmailCC     = ipg.EmailCC;
                clientCopy.EmailBCC    = ipg.EmailBCC;
                clientCopy.EmailTo     = objModel.Email;

                clientCopy.SendInquiry(clientCopy, "InquiryCustomer");

                return(RedirectToAction("TourSummary", "Tours"));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public ActionResult Confirmation()
        {
            try
            {
                //string _result = (Request.Form["_result"]).ToString();
                //string _orderID = (Request.Form["_orderID"]).ToString();
                //string _response = (Request.Form["_response"]).ToString();
                //string _currency = (Request.Form["_currency"]).ToString();
                //string _conventionCode = (Request.Form["_conventionCode"]).ToString();
                //string _amount = (Request.Form["_amount"]).ToString();

                //Encryption _decrypt = new Encryption();
                //_result = _decrypt.DecryptString(_result, "Result");
                //_orderID = _decrypt.DecryptString(_orderID, "CustomerRef");
                //_response = _decrypt.DecryptString(_response, "ResponseString");
                //_conventionCode = _decrypt.DecryptString(_conventionCode, "ConventionCode");
                //_amount = _decrypt.DecryptString(_amount, "Amount");

                string _result = "1";
                string _orderID = "JW18722";
                string _response = "";
                string _currency = "USD";
                string _conventionCode = "JWCON";
                string _amount = "1705";

                if (_result == "1")
                {
                    string BookingId = _orderID;

                    EmailModel em = new EmailModel();
                    em.BookingRef = _orderID;

                    IPGConfig _ipgConfig = _context.IPGConfigs.Where(w => w.ConventionCode == _conventionCode).FirstOrDefault();

                    JW_Delegates del = _context.JW_Delegates.Where(w => w.BookingID == BookingId).FirstOrDefault();
                    JW_Reservation reservation = _context.JW_Reservation.Where(w => w.BookingID == BookingId).FirstOrDefault();

                    reservation.BankRespond = true;
                    reservation.BankRespondValue = Convert.ToDouble(_amount);

                    Encryption encry = new Encryption();
                    string hashKey = encry.EncryptString(_amount, "Amount");
                    reservation.PostHashKey = hashKey;

                    //if (reservation.IsAdvancePayment == true)
                    //{
                    //    em.Amount = Convert.ToDouble(reservation.TotalCost / 2);
                    //}
                    //else
                    //{
                    //    em.Amount = Convert.ToDouble(reservation.TotalCost);
                    //}

                    em.Amount = Convert.ToDouble(_amount);
                    em.InvoiceAmount = Convert.ToDouble(reservation.TotalCost);

                    em.ClientEmail = del.Email;
                    em.ClientName = del.DelegeteName;
                    em.InvoiceNo = _orderID;
                    em.DateofPayment = DateTime.ParseExact("04/12/2017", "dd/MM/yyyy", null);//DateTime.Today;
                    em.CheckIn = reservation.CheckInDate.GetValueOrDefault().ToString("dd/MMMM/yyyy");
                    em.CheckOut = reservation.CheckOutDate.GetValueOrDefault().ToString("dd/MMMM/yyyy");
                    em.EmailCC = _ipgConfig.EmailCC;
                    em.EmailBCC = _ipgConfig.EmailBCC;
                    em.From =  _ipgConfig.EmailFrom;
                    em.HotelName = reservation.HotelName;
                    em.RoomCategory = reservation.JW_Rooms.RoomType;

                    string Package = "";
                    int totalNights = 0;

                    if(reservation.NightBefore > 0)
                    {
                        // Package += reservation.Package + " Night Before + ";
                        totalNights += (int)reservation.NightBefore;
                    }

                    // Package += reservation.Package + " Night Package + ";
                    totalNights += (int)reservation.Package;


                    if(reservation.NightAfter > 0)
                    {
                        // Package += reservation.NightAfter + " Night After ";
                        totalNights +=  (int)reservation.NightAfter;
                    }

                    //em.PackageType = Package;
                    em.PackageType = totalNights.ToString() + " Night Package";

                    em.SendEmail(em, "CustomerInvoice");

                    IQueryable<JW_RoomRate> roomRate = _context.JW_RoomRate.Where(w => w.RoomID == reservation.JW_Rooms.RoomID);

                    foreach(JW_RoomRate item in roomRate)
                    {
                        int newAllotment = (int)item.RemainingAllotment;
                        newAllotment = newAllotment - 1;
                        item.RemainingAllotment = newAllotment;
                    }

                    //_context.Entry(stud).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();

                    return View("PaymentComplete");
                }
                else
                {
                    return View("PaymentIssue");
                }
            }
            catch (Exception ex)
            {
                return RedirectToAction("Test", "Reservation", new { id = ex.Message });
            }
        }