public ActionResult CreateTraveller(TravellerGroupInsert travellerGroupInsert) { try { foreach (var name in db.GroupNames.Where(x => x.CreatedByID == CurrentUserID)) { if (travellerGroupInsert.GroupName == name.GroupName1) { travellerGroupInsert.TravellerList = db.TravellerLists.Where(s => s.CreatedByID == CurrentUserID && s.IsActive).ToList(); ModelState.AddModelError("GroupName", "GroupName ''" + travellerGroupInsert.GroupName + "'' already Exists."); return(View(travellerGroupInsert)); } } if (travellerGroupInsert.SelectedGrp == null) { travellerGroupInsert.TravellerList = db.TravellerLists.Where(s => s.CreatedByID == CurrentUserID && s.IsActive).ToList(); ModelState.AddModelError("Error", "No frequent traveller choosed"); return(View(travellerGroupInsert)); } SqlCommand command = new SqlCommand(); GroupName groupName = new GroupName(); groupName.GroupName1 = travellerGroupInsert.GroupName; groupName.CreatedByID = CurrentUserID; groupName.ModifiedByID = CurrentUserID; groupName.IsActive = true; MemberServiceController.InsertGroupName(groupName, command); command.Transaction.Commit(); SqlCommand command2 = new SqlCommand(); TravellerGroup travellerGroup = new TravellerGroup(); foreach (var find in db.GroupNames) { if (find.GroupName1 == travellerGroupInsert.GroupName && find.CreatedByID == CurrentUserID && find.IsActive == true) { travellerGroup.GroupID = find.GroupID; } } travellerGroup.CreatedByID = CurrentUserID; travellerGroup.ModifiedByID = CurrentUserID; travellerGroup.IsActive = true; foreach (var data in travellerGroupInsert.SelectedGrp) { travellerGroup.TravellerID = data; MemberServiceController.InsertTravellerGroup(travellerGroup, command2); } command2.Transaction.Commit(); } catch (Exception ex) { logger.Warn(ex, "Error when create new Traveller Group. - " + DateTime.Today.ToLoggerDateTime()); } return(RedirectToAction("TravellerGroup", "Tools")); }
/// <summary> /// Sets the given imageUrl to the related id's image /// This also sets the picture of the employee if there's any /// This should be called after the file uploaded to the system /// </summary> /// <param name="id">Id of the employee</param> /// <param name="imageUrl">Url of the Image</param> public void SetPicture(int id, String imageUrl) { IContent employee = Services.ContentService.GetById(id); if (imageUrl != null || !imageUrl.Equals("")) { MemberHelper memberHelper = new MemberHelper(); employee.SetValue("employeeImageUrl", imageUrl); IContent member = (IContent)memberHelper.GetByEmail(employee?.GetValue("employeeEmail")?.ToString()); try { MemberServiceController memberService = new MemberServiceController(); memberService.SetMemberImage(member.Id, imageUrl); } catch (NullReferenceException nullException) { CustomLogHelper.logHelper.Log( "This should be fixed. A new member can be created with the given properties. There's no member for the" + employee.Name + "Caught a null reference exception" + nullException.Message); } Services.ContentService.SaveAndPublishWithStatus(employee); } else { //TODO may return an error message later on } }
public ActionResult DeleteTraveller(string name) { if (name != null) { var modelCaller = new ModelInitialize(db); var model = modelCaller.DeleteAll(CurrentUserID).FirstOrDefault(x => x.GroupName == name); foreach (var item in model.TravallerGroup) { SqlCommand command2 = new SqlCommand(); model.TravellerGroupID = item.TravellerGroupID; MemberServiceController.DeleteTravellerGroup(model, command2); command2.Transaction.Commit(); } SqlCommand command = new SqlCommand(); MemberServiceController.DeleteGroupName(model, command); command.Transaction.Commit(); if (model == null) { return(HttpNotFound()); } } return(RedirectToAction("TravellerGroup", "Tools")); }
public ActionResult DeleteFrequentFlyer(int id) { var modelCaller = new ModelInitialize(db); var model = modelCaller.EditFlyerDetail().FirstOrDefault(x => x.TravellerID == id); MayFlower checkDb = new MayFlower(); foreach (var group in checkDb.TravellerGroups.Where(x => x.IsActive == true)) { if (group.TravellerID == model.TravellerID) { ModelState.AddModelError("Error", "This frequent traveller " + model.FullName + " added in Traveller Group!"); TempData["ModelStateDeleteError"] = ModelState; return(RedirectToAction("FrequentFlyer", "Tools", ModelState)); //throw new Exception("This frequent traveller added in traveller group!"); } } model.IsActive = false; SqlCommand command = new SqlCommand(); MemberServiceController.EditFrequentFlyer(id, CurrentUserID, model, command); command.Transaction.Commit(); if (model == null) { return(HttpNotFound()); } return(RedirectToAction("FrequentFlyer", "Tools")); }
public ActionResult EditFrequentFlyer(int id, FrequentFlyerEditModel model) { SqlCommand command = new SqlCommand(); model.IsActive = true; MemberServiceController.EditFrequentFlyer(id, CurrentUserID, model, command); command.Transaction.Commit(); return(RedirectToAction("FrequentFlyer", "Tools")); }
/// <summary> /// Tries to login with Google Auth /// </summary> public void Login() { string code = Request.QueryString["code"]; string error = Request.QueryString["error"]; string baseUrl = System.Configuration.ConfigurationManager.AppSettings["baseUrl"]; GoogleOAuthClient oauth = new GoogleOAuthClient { ClientId = "clientId", ClientSecret = "clientSecret", RedirectUri = baseUrl + "/umbraco/surface/auth/login" }; // Handle if an error occurs during the Google authentication (eg. if the user cancels the login) if (!String.IsNullOrWhiteSpace(error)) { return; } // Handle the state when the user is redirected back to our page after a successful login with the Google API if (!String.IsNullOrWhiteSpace(code)) { MemberServiceController memberService = new MemberServiceController(); // Exchange the authorization code for an access token GoogleAccessTokenResponse response = oauth.GetAccessTokenFromAuthorizationCode(code); string accessToken = response.AccessToken; // Initialize a new instance of the GoogleService class so we can make calls to the API GoogleService service = GoogleService.CreateFromAccessToken(accessToken); // Make a call to the API to get information about the authenticated user GoogleUserInfo user = service.GetUserInfo(); //Checks whether the user is logging in with a emakina account if (memberService.CreateNewMember(user.GivenName, user.FamilyName, user.Email, user.Id, user.Picture)) { FormsAuthentication.SetAuthCookie("google_" + user.Id, false); Response.Redirect("/"); } else { return; } } else { string redirect = (Request.QueryString["redirect"] ?? "/"); // Set the state (a unique/random value) string state = Guid.NewGuid().ToString(); Session["Google_" + state] = redirect; // Construct the authorization URL string authorizationUrl = oauth.GetAuthorizationUrl(state, GoogleScopes.Email + GoogleScopes.Profile, GoogleAccessType.Online, GoogleApprovalPrompt.Force); // Redirect the user to the OAuth dialog Response.Redirect(authorizationUrl); } }
public ActionResult NewFrequentFlyer(FrequentFlyerInsert frequentFlyerInsert) { SqlCommand command = new SqlCommand(); Alphareds.Module.Model.Database.TravellerList travellerList = new Alphareds.Module.Model.Database.TravellerList(); travellerList.TitleCode = frequentFlyerInsert.FlyerDetail.TitleCode; travellerList.FirstName = frequentFlyerInsert.FlyerDetail.FirstName; travellerList.FamilyName = frequentFlyerInsert.FlyerDetail.FamilyName; travellerList.DOB = frequentFlyerInsert.FlyerDetail.DOB ?? DateTime.Now; travellerList.Nationality = frequentFlyerInsert.FlyerDetail.Nationality; travellerList.Passport = frequentFlyerInsert.FlyerDetail.Passport; travellerList.PassportIssuePlace = frequentFlyerInsert.FlyerDetail.PassportIssuePlace; travellerList.PassportExpiryDate = frequentFlyerInsert.FlyerDetail.PassportExpiryDate ?? DateTime.MaxValue; travellerList.IsShared = frequentFlyerInsert.FlyerDetail.IsShared; travellerList.CreatedByID = CurrentUserID; travellerList.ModifiedByID = CurrentUserID; travellerList.IsActive = true; MemberServiceController.InsertFrequentFlyer(travellerList, command); command.Transaction.Commit(); return(RedirectToAction("FrequentFlyer", "Tools")); }
public ActionResult EditTraveller(TravellerGroupEditModel model) { SqlCommand command = new SqlCommand(); model.IsActiveGroupName = true; MayFlower db = new MayFlower(); bool nameIsAvailable = true; var groupNameList = db.GroupNames.Where(x => x.CreatedByID == CurrentUserID); var currentGroupName = groupNameList.FirstOrDefault(x => x.GroupID == model.GroupID); #region check/edit group name //if name is different if (model.GroupName != currentGroupName.GroupName1) { foreach (var item in groupNameList) { if (item.GroupName1 == model.GroupName) { nameIsAvailable = false; } } if (nameIsAvailable) { //edit name MemberServiceController.EditGroupName(CurrentUserID, model, command); command.Transaction.Commit(); } else { //return error model.FullTravellerList = db.TravellerLists.Where(s => s.CreatedByID == CurrentUserID && s.IsActive).ToList(); var tList = new List <TravellerList>(); if (model.SelectedGrp != null) { foreach (int selGroup in model.SelectedGrp) { var checkList = model.FullTravellerList.FirstOrDefault(x => x.TravellerID == selGroup); if (checkList != null) { tList.Add(checkList); } } model.TravellerList = tList; model.SelectedGrp.Clear(); } ModelState.AddModelError("GroupName", "GroupName ''" + model.GroupName + "'' Already Exist."); return(View(model)); } } #endregion #region old edit group name //foreach (var item in db.GroupNames) //{ // if (item.GroupID == model.GroupID && item.CreatedByID == CurrentUserID) // { // MemberServiceController.EditGroupName(CurrentUserID, model, command); // command.Transaction.Commit(); // } // else if (item.GroupID != model.GroupID && item.GroupName1 == model.GroupName && item.CreatedByID == CurrentUserID) // { // //when groupname exist at other travellergroup for same userID // model.FullTravellerList = db.TravellerLists.Where(s => s.CreatedByID == CurrentUserID && s.IsActive).ToList(); // var tList = new List<TravellerList>(); // if (model.SelectedGrp != null) // { // foreach (int selGroup in model.SelectedGrp) // { // var checkList = model.FullTravellerList.FirstOrDefault(x => x.TravellerID == selGroup); // if (checkList != null) // { // tList.Add(checkList); // } // } // model.TravellerList = tList; // } // model.SelectedGrp.Clear(); // ModelState.AddModelError("Error", "GroupName ''" + model.GroupName + "'' Already Exist."); // return View(model); // //throw new Exception("GroupName Exist"); // } //} #endregion var selectedTG = db.TravellerGroups.Where(x => x.GroupID == model.GroupID && x.CreatedByID == CurrentUserID); foreach (var tg in selectedTG)//choosed { bool checkDB = false; if (model.SelectedGrp != null) { foreach (var ti in model.SelectedGrp) //check equal { if (ti == tg.TravellerID) { SqlCommand command2 = new SqlCommand(); model.ModifiedByID = CurrentUserID; model.TravellerGroupID = tg.TravellerGroupID; model.TravellerID = ti; model.IsActiveTravellerName = true; MemberServiceController.EditTravellerGroup(CurrentUserID, model, command2); command2.Transaction.Commit(); checkDB = true; } } } else { // when no frequent traveller chosen when edit model.FullTravellerList = db.TravellerLists.Where(s => s.CreatedByID == CurrentUserID && s.IsActive).ToList(); var tList = new List <TravellerList>(); if (model.SelectedGrp == null) { //model.SelectedGrp.Clear(); ModelState.AddModelError("Error", "No frequent traveller choosed"); return(View(model)); } //} //foreach (int selGroup in model.SelectedGrp) //{ // var checkList = model.FullTravellerList.FirstOrDefault(x => x.TravellerID == selGroup); // if (checkList != null) // { // tList.Add(checkList); // } //} model.TravellerList = tList; model.SelectedGrp.Clear(); ModelState.AddModelError("Error", "No frequent traveller choosed"); return(View(model)); //throw new Exception("No frequent traveller choosed"); } if (!checkDB) { SqlCommand command2 = new SqlCommand(); model.ModifiedByID = CurrentUserID; model.TravellerGroupID = tg.TravellerGroupID; model.TravellerID = tg.TravellerID; model.IsActiveTravellerName = false; MemberServiceController.EditTravellerGroup(CurrentUserID, model, command2); command2.Transaction.Commit(); } } // foreach (var list in model.SelectedGrp) { bool checkModel = false; foreach (var tg in selectedTG) { if (list == tg.TravellerID) { checkModel = true; } } if (!checkModel) { SqlCommand command3 = new SqlCommand(); model.TravellerID = list; model.CreatedByID = CurrentUserID; model.ModifiedByID = CurrentUserID; model.IsActiveTravellerName = true; MemberServiceController.InsertTravellerGroupByEdit(model, command3); command3.Transaction.Commit(); } } return(RedirectToAction("TravellerGroup", "Tools")); }
public async Task <ActionResult> Checkout(PaymentCheckout payment, string paymentID = null) { string _pMethod = payment.PaymentMethod?.ToLower(); if (_pMethod != null && _pMethod.Contains("adyen")) { // Reflection get credit card property to remove model validation var ccModel = typeof(Alphareds.Module.Model.CreditCard); foreach (var item in ccModel.GetProperties()) { // Remove model validtion ModelState[item.Name]?.Errors.Clear(); } } // If member not verify email, block place booking. if (User.Identity.IsAuthenticated && !CustomPrincipal.IsProfileActive && !CustomPrincipal.IsAgent) { ModelState.AddModelError("Error", "Please verify your account first, before place order."); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Account inactive.")); } string _paymentInfo = null; Cryptography.AES.TryDecrypt(paymentID, out _paymentInfo); var _superPNR = db.SuperPNRs.FirstOrDefault(x => x.SuperPNRID.ToString() == _paymentInfo); // Check model error before postback if (!ModelState.IsValid) { if (_superPNR.MainProductType == ProductTypes.Flight) { return(RedirectToAction("OrderHistory", "Flight", new { tripid, bookingID = _superPNR.SuperPNRNo, status = "payment-fail" })); } else if (_superPNR.MainProductType == ProductTypes.Hotel) { return(RedirectToAction("OrderHistory", "Hotel", new { tripid, confirmid = _superPNR.SuperPNRNo, status = "payment-fail" })); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Product Undefined.")); } } var _paymentList = _superPNR.GetAllPaymentRecords(); string paymentCurrency = "MYR"; _superPNR.LoadPaymentDetailList(true, paymentCurrency); var paymentDtlList = _superPNR.PaymentDetailsList.FirstOrDefault(); // take converted rate, only one result SqlCommand command = new SqlCommand(); // Can pass in user preferred currency code into ChkCreditAmtRemin, with optional parameter // Use this method to handle multi currency code in different order issues. decimal creditUserAvail = MemberServiceController.ChkCreditAmtRemain.ByUserId(CustomPrincipal.UserId, CustomPrincipal.UserTypeCode, command, paymentCurrency); decimal cashWalletUserAvail = MemberServiceController.GetUserCashCredit(CustomPrincipal.UserId, command); CheckoutController checkoutCtl = new CheckoutController(ControllerContext); decimal thisBookUsableAmt = checkoutCtl.CalcTravelCreditUsable(paymentDtlList.TotalPendingAmount, creditUserAvail, cashWalletUserAvail, DiscountType.TC); if (creditUserAvail >= thisBookUsableAmt && payment.UseCredit && (paymentDtlList.TotalPendingAmount <= thisBookUsableAmt)) { payment.PaymentMethod = CustomPrincipal.IsAgent ? "AC" : "SC"; } payment = new PaymentCheckout { AvailableCredit = creditUserAvail, CreditUsed = payment.UseCredit ? thisBookUsableAmt : 0m, PaymentMethod = string.IsNullOrWhiteSpace(payment.PaymentMethod) ? CustomPrincipal.IsAgent ? "AC" : "SC" : payment.PaymentMethod, Policy = payment.Policy, TnC = payment.TnC, UseCredit = payment.UseCredit, CreditCard = payment.CreditCard, CreditTerm = CustomPrincipal.CreditTerm, PaymentCurrencyCode = paymentDtlList.CurrencyCode, GrandTotalForPayment = paymentDtlList.TotalPendingAmount }; PromoCodeFunctions promoCodeFunctions = new PromoCodeFunctions(_superPNR._MainPromoID, db); decimal ttlOrderUsedTCAmountUseable = payment.CreditUsed; decimal ttlTCAmtUsed = 0m; List <PaymentOrder> paymentOrderToInsert = new List <PaymentOrder>(); foreach (var _orderId in paymentDtlList.OrdersPendingPayment) { var _orders = _superPNR.SuperPNROrders.FirstOrDefault(x => x.OrderID == _orderId); #region Insert/Update Processing Fee var feeChargeOrder = _orders.FeeChargeOrders.FirstOrDefault(); ProcessingFee pf = new ProcessingFee(payment.PaymentMethod, _orders.PendingPaymentAmt, _superPNR.MainProductType, promoCodeFunctions, paymentCurrency); var latestFeeCharge = new FeeChargeOrder { OrderID = _orders.OrderID, CreatedByID = _superPNR.CreatedByID, CurrencyCode = _orders.CurrencyCode, FeeChargeAmount = pf.Amt, FeeCode = string.IsNullOrWhiteSpace(pf.FeeCode) ? payment.PaymentMethod : pf.FeeCode, TaxCode = string.IsNullOrWhiteSpace(pf.TaxCode) ? "ES" : pf.TaxCode, TaxAmount = pf.GST, ModifiedByID = CurrentUserID, SuperPNROrder = _orders, }; if (feeChargeOrder == null) { _orders.FeeChargeOrders.Add(latestFeeCharge); // for model calculation PaymentServiceController.InsertFeeChargeOrder(latestFeeCharge, command); } else { // For model calculation only feeChargeOrder.CurrencyCode = _orders.CurrencyCode; feeChargeOrder.FeeChargeAmount = pf.Amt; feeChargeOrder.FeeCode = string.IsNullOrWhiteSpace(pf.FeeCode) ? payment.PaymentMethod : pf.FeeCode; feeChargeOrder.TaxCode = string.IsNullOrWhiteSpace(pf.TaxCode) ? "ES" : pf.TaxCode; feeChargeOrder.TaxAmount = pf.GST; PaymentServiceController.UpdateFeeChargeOrder(latestFeeCharge, command); } #endregion if (payment != null && payment.UseCredit && payment.CreditUsed > 0 && (payment.PaymentMethod != "SC" && payment.PaymentMethod != "AC")) { decimal _thisTransAmt = _orders.PendingPaymentAmt; decimal _thisTransUseTCAmt = ttlOrderUsedTCAmountUseable; bool usedAllTC = ttlTCAmtUsed == payment.CreditUsed; if (ttlOrderUsedTCAmountUseable > _thisTransAmt && !usedAllTC) { _thisTransUseTCAmt = _thisTransAmt; } if (ttlOrderUsedTCAmountUseable > 0 && !usedAllTC) { ttlOrderUsedTCAmountUseable -= _thisTransUseTCAmt; ttlTCAmtUsed += _thisTransUseTCAmt; PaymentOrder tcPaymentOrder = new PaymentOrder { OrderID = _orders.OrderID, PaymentDate = DateTime.Now, PaymentMethodCode = CustomPrincipal.IsAgent ? "AC" : "SC", PaymentStatusCode = "PEND", CurrencyCode = _orders.CurrencyCode, PaymentAmount = _thisTransUseTCAmt, ImagePath = string.Empty, Ipay88RefNo = string.Empty, Ipay88TransactionID = string.Empty, CreatedByID = CurrentUserID, ModifiedByID = CurrentUserID }; paymentOrderToInsert.Add(tcPaymentOrder); // Update SuperPNR Order indicated is Credit Used. _orders.CreditAmount += _thisTransUseTCAmt; _orders.IsCreditUsed = _orders.CreditAmount > 0; HotelServiceController.UpdateSuperPNROrder(_orders, command); } } else { // Update SuperPNR Order indicated is Credit Used. _orders.CreditAmount = _orders.PaymentOrders.Where(x => (x.PaymentMethodCode == "AC" || x.PaymentMethodCode == "SC") && x.PaymentStatusCode == "PAID").Sum(s => s.PaymentAmount); _orders.IsCreditUsed = _orders.CreditAmount > 0; HotelServiceController.UpdateSuperPNROrder(_orders, command); } decimal paymentPrepareToInsert = paymentOrderToInsert.Where(x => x.OrderID == _orders.OrderID).Sum(s => s.PaymentAmount); if (paymentPrepareToInsert < _orders.PendingPaymentAmt) { PaymentOrder normalPayment = new PaymentOrder { OrderID = _orders.OrderID, PaymentDate = DateTime.Now, PaymentMethodCode = payment.PaymentMethod, PaymentStatusCode = "PEND", CurrencyCode = _orders.CurrencyCode, PaymentAmount = _orders.PendingPaymentAmt - paymentPrepareToInsert, ImagePath = string.Empty, Ipay88RefNo = string.Empty, Ipay88TransactionID = string.Empty, CreatedByID = CurrentUserID, ModifiedByID = CurrentUserID }; paymentOrderToInsert.Add(normalPayment); } } decimal ttlAmtPOSTGateway = paymentOrderToInsert.Where(x => x.PaymentMethodCode != "SC" && x.PaymentMethodCode != "AC").Sum(s => s.PaymentAmount); List <int> paymentOrderInserted = new List <int>(); #region Insert SupperPNROrders records into DB try { foreach (var paymentRecord in paymentOrderToInsert) { paymentOrderInserted.Add(PaymentServiceController.InsertPaymentOrder(paymentRecord, command)); } #region Payment Gateway Redirect _superPNR.GetContactPerson(); var contactPerson = _superPNR.ContactPerson; PaymentSubmitModels iPayModel = PaymentController.PopulatePaymentSubmitModel(DateTime.Now, _superPNR.SuperPNRID, _superPNR.SuperPNRNo, paymentCurrency, ttlAmtPOSTGateway, payment.PaymentMethod, contactPerson.Phone1, contactPerson.Email, contactPerson.FullName); // Save transaction before redirect command.Transaction.Commit(); string clientIP = HttpContext.Request.UserHostAddress; string paymentMethod = payment.PaymentMethod.ToUpper(); string token = _superPNR.SuperPNRID.ToString() + "," + _superPNR.SuperPNRNo; string encToken = General.CustomizeBaseEncoding.CodeBase64(token); string encPaymentOrderIDList = Cryptography.AES.Encrypt(paymentOrderInserted.JoinToString(",")); FormCollection form = new FormCollection(); adyenCaptureResponseModels captureResponseModels2 = new adyenCaptureResponseModels(); iPayCaptureResponseModels captureResponseModels = new iPayCaptureResponseModels { Status = "1", Amount = iPayModel.PaymentAmount, TransId = "" }; switch (payment.PaymentMethod.ToLower()) { case "sc": form.Add("Status", captureResponseModels.Status); form.Add("Amount", captureResponseModels.Amount.ToString("n2")); return(await checkoutCtl.PaymentCheckOut(form, captureResponseModels, captureResponseModels2, encToken, tripid, encPaymentOrderIDList, true)); case "ac": form.Add("Status", captureResponseModels.Status); form.Add("Amount", captureResponseModels.Amount.ToString("n2")); return(await checkoutCtl.PaymentCheckOut(form, captureResponseModels, captureResponseModels2, encToken, tripid, encPaymentOrderIDList, true)); case "ipacc": return(iPay88CheckOut(Url.Action("PaymentCheckOut", "Checkout", new { token = encToken, tripid, paymentOdToken = encPaymentOrderIDList, fromRepay = true }, Request.Url.Scheme), iPayModel, true)); case "ipafpx": return(iPay88CheckOut(Url.Action("PaymentCheckOut", "Checkout", new { token = encToken, tripid, paymentOdToken = encPaymentOrderIDList, fromRepay = true }, Request.Url.Scheme), iPayModel)); case "adyenc": AdyenCardPaymentModels adyenModel = PaymentController.PopulateAdyenPaymentSubmitModel(_superPNR.SuperPNRID, Request.Url.Scheme, _superPNR.SuperPNRNo, paymentCurrency, ttlAmtPOSTGateway, contactPerson.Email, payment.CreditCard); return(AdyenCheckOut(Url.Action("PaymentCheckOut", "Checkout", new { token = encToken, tripid, paymentOdToken = encPaymentOrderIDList, fromRepay = true }, Request.Url.Scheme), adyenModel, Request.Form)); default: ModelState.AddModelError("Error", "Payment Method Not Found."); break; } #endregion } catch (Exception ex) { // Insert payment record failed. command?.Transaction?.Rollback(); // Handle redirect back to OrderHistory Page ViewBag.PaymentDetails = payment; ModelState.AddModelError("Error", "Unexpected error occured, please try again later."); string errorMsg = $"Insert Payment Order record failed on OrderHistory repayment."; logger.Fatal(ex, errorMsg); if (_superPNR.MainProductType == ProductTypes.Flight) { return(RedirectToAction("OrderHistory", "Flight", new { tripid, bookingID = _superPNR.SuperPNRNo, status = "payment-fail" })); } else if (_superPNR.MainProductType == ProductTypes.Hotel) { return(RedirectToAction("OrderHistory", "Hotel", new { tripid, confirmid = _superPNR.SuperPNRNo, status = "payment-fail" })); } else { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, "Product Undefined.")); } } #endregion return(null); }