/// <summary> /// Payment Reminder Message /// </summary> /// <returns>View from </returns> // GET: Payments public ActionResult PaymentReminder() { AccountsBalanceHelper accountsBalanceHelper = new AccountsBalanceHelper(); BlueGreenContext bg = new BlueGreenContext(); if (bg?.bxgOwner == null) { return(Redirect(UrlMapper.Map(SiteSettings.SignInPage.Url))); } if (bg.IsInstallmentPlan()) { return(RedirectToActionPermanent("AccountsBalance")); } var model = accountsBalanceHelper.GetPaymentContentFromPaymentConfig(bg); return(View(model)); }
public ActionResult ShowWidget() { var model = GetLayoutItem <SideWidget>(); BlueGreenContext userContext = new BlueGreenContext(); if (SitecoreUtils.EvaluateRules(model.RestrictionRule, model.InnerItem)) { foreach (var item in model.WidgetContents) { item.isVisible = true; if (SitecoreUtils.EvaluateRules(item.RestrictionRule, item.InnerItem)) { if (item.WidgetLink != null) { item.WidgetLink.Url = UrlMapper.Map(item.WidgetLink.Url); } if (item.SubWidgetLink != null) { item.SubWidgetLink.Url = UrlMapper.Map(item.SubWidgetLink.Url); } if (item.SubWidgetText != null) { item.SubWidgetText = UpdateText(item.SubWidgetText, userContext); } if (item.SubWidgetLink != null && !string.IsNullOrEmpty(item.SubWidgetLink.Text)) { item.SubWidgetLink.Text = UpdateText(item.SubWidgetLink.Text, userContext); } } else { item.isVisible = false; } } } else { model.WidgetContents = null; //model = null; } return(View(model)); }
public ActionResult PointsProtectionPlan() { var model = GetLayoutItem <PointsProtectionPlan>(); if (Request.QueryString["reservationNo"] == null) { ReservationParameters reservationContext = ReservationUtils.GetContextReservation(); if (reservationContext == null) { ReservationUtils.HandelMissingReservationContext(); } else { model.payment = reservationContext.PPPCost.ToString(); model.points = reservationContext.PointsRequired; } } else { //Get the reservation details from service call BlueGreenContext bgcontext = new BlueGreenContext(); var ActiveReservation = bgcontext.GetActiveReservation(Request.QueryString["reservationNo"], ResortService.RESERVATION_TYPE_FUTURE); model.payment = ActiveReservation.PolicyPrice; model.points = FormatUtils.ConvertStringToInt(ActiveReservation.Points); Session["ReservationNumber"] = ActiveReservation.ReservationNumber; ReservationParameters reservationContext = new ReservationParameters(); reservationContext.PPPCost = Convert.ToDecimal(model.payment); reservationContext.PointsRequired = FormatUtils.ConvertStringToInt(ActiveReservation.Points); Session["ReservationContext"] = reservationContext; } if (Session["PPPUiError"] != null) { var allPreviousError = (List <RuleViolation>)Session["PPPUiError"]; foreach (RuleViolation item in allPreviousError) { ModelState.AddModelError("", item.ErrorMessage); } Session["PPPUiError"] = null; } return(View(model)); }
public ActionResult GetRightPanel() { var rightPanel = GetLayoutItem <RightPanel>(); foreach (RightSection section in rightPanel.RightSections) { bool showUsingRules = true; if (section.InnerItem.Fields[BaseComponent.RestrictionRuleId] != null) { string rule = section.InnerItem.Fields[BaseComponent.RestrictionRuleId].Value; if (!string.IsNullOrEmpty(rule)) { var rules = RuleFactory.ParseRules <RuleContext>(section.InnerItem.Database, XElement.Parse(rule)); var ruleContext = new RuleContext() { Item = section.InnerItem }; if (rule.Any() && rules.Rules.Count() > 0) { showUsingRules = rules.Rules.First().Evaluate(ruleContext); } } } section.HideSection = !showUsingRules; if (showUsingRules) { BlueGreenContext bgContext = new BlueGreenContext(); if (bgContext != null && bgContext.bxgOwner != null && bgContext.IsAuthenticated) { int cartItemsQuantityCount = DBManager.GetAllCartItems(bgContext.bxgOwner.Arvact).AsEnumerable().Sum(x => x.Field <int>("Quantity")); rightPanel.RewardCartItemCount = cartItemsQuantityCount; } else { rightPanel.RewardCartItemCount = 0; } } } return(View(rightPanel)); }
public ActionResult Feedback(ArticleRating Articlerating) { JsonResponse jsonResponse = new JsonResponse(); var context = new SitecoreContext(); bool success = false; try { Articlerating.FeedbackSaved = false; Sitecore.Data.Items.Item FAQItem = context.Database.GetItem((new ID(new Guid(Articlerating.FeedbackReference)))); BlueGreenContext bgContext = new BlueGreenContext(); if (bgContext != null && bgContext.bxgOwner != null) { Articlerating.UserReference = bgContext.bxgOwner.Email; Articlerating.UserName = bgContext.bxgOwner.fullName; Articlerating.UserType = bgContext.GetOwnerType(); } Articlerating.ArticleTitle = FAQItem["Title"]; Articlerating.ArticlePath = FAQItem.Paths.GetPath(Sitecore.Data.Items.ItemPathType.DisplayName); success = DBManager.InsertArticleFeedback(Articlerating); if (success) { jsonResponse.RetCode = "0"; } } catch (Exception Ex) { jsonResponse.RetCode = "1"; jsonResponse.errors.Add("Error while saving the data, please Try later"); return(Json(jsonResponse, JsonRequestBehavior.AllowGet)); } return(Json(jsonResponse, JsonRequestBehavior.AllowGet)); }
private void CheckForTravelerPlusMembershipAndRedirect(RewardsSections model) { // Check for Travelerplus Expiry .Copied Logic from Legacy TravelerPlus Home page if (model.InnerItem.ID.ToString().Equals("{536E4650-A734-4D8B-AFF6-62518271C2B5}", StringComparison.CurrentCultureIgnoreCase)) { BlueGreenContext bgContext = new BlueGreenContext(); string targetUrl = string.Empty; if (bgContext != null && bgContext.GetOwnerType() == "Travelerplus") { if (bgContext.IsTPExpired && bgContext.IsAccountExpired) { targetUrl = UrlMapper.Map("https://www.bluegreenowner.com/TravelerPlus/owner/ownerrenewal.aspx"); Response.RedirectPermanent(targetUrl, true); } } else { targetUrl = UrlMapper.Map("https://www.bluegreenowner.com/owner/vcTravelerPlus.aspx"); Response.RedirectPermanent(targetUrl, true); } } }
public void OwnerWebStats(BookReservationRequest request, BookReservationResponse reservationResponse) { try { OwnerWebStatsRequest ownerRequest = new OwnerWebStatsRequest(); string cursession = string.Empty; string ownerID = string.Empty; var searchtabvalue = string.Empty; var SearchTab = "Dest"; BlueGreenContext bgContext = new BlueGreenContext(); //if (searchtype = "2") //{ // SearchTab = "Dest"; // SearchTabSubVal = Session("SearchCity") // } //else if searchtype = "3" Then // SearchTab = "Exp" // SearchTabSubVal = Session("SearchCity") // searchtabvalue = Session("experience") //End If if (HttpContext.Session != null) { cursession = HttpContext.Session.SessionID; ownerID = bgContext.OwnerId; } ownerRequest.WebSessionID = cursession; ownerRequest.SiteID = "7"; ownerRequest.OwnerID = request.OwnerID.ToString(); ownerRequest.SearchTab = ""; ownerRequest.SearchTabSubVal = ""; ownerRequest.SearchTabValue = ""; ownerRequest.ResortID = request.ResortID.ToString(); ownerRequest.BGOUnitType = request.UnitTypeCode; ownerRequest.ProjectNumber = request.ReservationProjectNumber; ownerRequest.UnitType = request.UnitTypeCode; DateTime checkinDate = DateTime.Parse(request.CheckInDate); ownerRequest.CheckInDate = checkinDate.ToString("MM/dd/yyyy"); ownerRequest.CheckOutDate = checkinDate.AddDays(request.LengthOfStay).ToString(); ownerRequest.NumberOfGuests = request.NumberOfAdults.ToString(); ownerRequest.SumBal = request.Points.ToString(); ownerRequest.PPPEligible = ""; ownerRequest.PPPFee = ""; ownerRequest.ReservationNumber = reservationResponse.ConfirmReservation.ReservationNumber.ToString(); ownerRequest.Phase = "3"; ownerRequest.RecordReturnCode = ""; ownerRequest.ExtendedResort = "0"; ownerRequest.ExtendedStay = "0"; ownerRequest.Handycap = ""; ownerRequest.QryTime = ""; ownerRequest.CreatedDate = DateTime.Now.Date.ToString("MM/dd/yyyy"); ownerRequest.CreatedBy = "Web"; ownerRequest.UnitType = request.UnitTypeCode; ProfileService profileService = new ProfileService(); profileService.OwnerWebStats(ownerRequest); } catch (Exception ex) { Sitecore.Diagnostics.Log.Error("Unexpected exception calling OwnerWebStats", ex, "reservationcontroller.OwnerWebStats"); } }
private BookReservationResponse ExecuteBook(ReservationParameters reservationContext) { // bool statusExecuteBook = false; BlueGreenContext bgContext = new BlueGreenContext(); BookReservationRequest request = new BookReservationRequest(); request.ReservationProjectNumber = reservationContext.ProjectNumber.ToString(); request.OwnerID = reservationContext.OwnerId; request.UnitTypeCode = reservationContext.UnitType; request.CheckInDate = reservationContext.CheckInDate.ToString("MM/dd/yyyy"); request.LengthOfStay = Convert.ToInt16((reservationContext.CheckOutDate - reservationContext.CheckInDate).TotalDays); request.NumberOfAdults = int.Parse(reservationContext.Guest_NumberOfGuest); //TODO get value from context request.AccountNumber = bgContext.GetPrimaryAccountNumber(); request.OwnerProjectNumber = bgContext.GetOwnerAccountProject().ToString(); //Changed to Enclose Special Requests with Special Request for BGO only string specialCharacter = Sitecore.Configuration.Settings.GetSetting("IdentifierForSpecialRequestFromBGO"); request.Comments = (reservationContext.text_SpecialRequests == null) ? "" : specialCharacter + reservationContext.text_SpecialRequests + specialCharacter; if (!string.IsNullOrEmpty(reservationContext.wheelchairaccessible) && reservationContext.wheelchairaccessible == "1") { request.HandicapAccessible = "Y"; request.Comments = "REQHANDICAP " + request.Comments; } if (reservationContext.ReservationType == SearchParameters.RESERVATION_TYPE_BONUSTIME) { request.ReservationType = "B"; request.SiteName = "BonusTime"; } else { request.ReservationType = "P"; request.SiteName = "onlinepoints"; request.Points = reservationContext.PointsRequired; } if (reservationContext.hasCreditcard) { request.Payment = new Models.ResortService.BookReservationRequest.Payment(); request.Payment.CreditCardAuthorization = reservationContext.CreditCard_VerificationNumber; request.Payment.CreditCardName = reservationContext.CreditCard_Name; request.Payment.CreditCardNumber = reservationContext.CreditCard_Number; request.Payment.CreditCardType = FormatUtils.ConvertCreditCard(reservationContext.CreditCard_Type); request.Payment.CreditCardExpirationDate = ReservationUtils.GetExpDate(reservationContext.CreditCard_ExpDateMonth, reservationContext.CreditCard_ExpDateYear); request.Payment.CreditCardTotal = Convert.ToDouble(reservationContext.BT_TotalCost); request.Payment.NonTaxTotal = Convert.ToDouble(Convert.ToDecimal(reservationContext.DailyPrice) * reservationContext.NumberOfNightChanged); } if (reservationContext.hasGuest) { request.Guests = new List <Models.ResortService.BookReservationRequest.Guest>(); var guestOld = new Models.ResortService.BookReservationRequest.Guest(); guestOld.GuestType = "Primary"; guestOld.GuestID = ""; guestOld.FirstName = reservationContext.Guest_FirstName; guestOld.LastName = reservationContext.Guest_LastName; guestOld.Relationship = reservationContext.Guest_Relationship; request.Guests.Add(guestOld); if (!string.IsNullOrEmpty(reservationContext.Guest_Email)) { guestOld.EmailAddresses = new List <Models.ResortService.BookReservationRequest.EmailAddress>(); var email = new Models.ResortService.BookReservationRequest.EmailAddress(); email.AddressType = "Home"; email.Email = reservationContext.Guest_Email; guestOld.EmailAddresses.Add(email); } else { guestOld.EmailAddresses = new List <Models.ResortService.BookReservationRequest.EmailAddress>(); var email = new Models.ResortService.BookReservationRequest.EmailAddress(); email.AddressType = "Home"; email.Email = bgContext.bxgOwner.Email; guestOld.EmailAddresses.Add(email); } if (reservationContext.Guest_AddNew != "AddNew") { if (!string.IsNullOrEmpty(reservationContext.Guest_PhoneNumber)) { guestOld.Phones = new List <Models.ResortService.BookReservationRequest.Phone>(); var phone = new Models.ResortService.BookReservationRequest.Phone(); phone.PhoneNumberType = "Home"; phone.PhoneNumber = reservationContext.Guest_PhoneNumber; guestOld.Phones.Add(phone); } if (!string.IsNullOrEmpty(reservationContext.Guest_City)) { guestOld.Addresses = new List <Models.ResortService.BookReservationRequest.Address>(); var address = new Models.ResortService.BookReservationRequest.Address(); address.AddressLine1 = " "; address.AddressLine2 = " "; address.CountryCode = " "; address.PostalCode = " "; address.AddressType = "Home"; address.City = reservationContext.Guest_City; // Here I'm assuming that no one will select state without city (they are both required fields anyway) if (!string.IsNullOrEmpty(reservationContext.Guest_State)) { address.ProvinceCode = reservationContext.Guest_State; } guestOld.Addresses.Add(address); } } else { var guest = new Models.ResortService.BookReservationRequest.Guest(); guest.GuestType = "GuestOnPrimary"; guest.FirstName = reservationContext.Guest_FirstName; guest.LastName = reservationContext.Guest_LastName; guest.Relationship = reservationContext.Guest_Relationship; guest.GuestID = ""; if (!string.IsNullOrEmpty(reservationContext.Guest_Email)) { guest.EmailAddresses = new List <Models.ResortService.BookReservationRequest.EmailAddress>(); var email = new Models.ResortService.BookReservationRequest.EmailAddress(); email.AddressType = "Home"; email.Email = reservationContext.Guest_Email; guest.EmailAddresses.Add(email); } if (!string.IsNullOrEmpty(reservationContext.Guest_City)) { guest.Addresses = new List <Models.ResortService.BookReservationRequest.Address>(); var address = new Models.ResortService.BookReservationRequest.Address(); address.AddressLine1 = " "; address.AddressLine2 = " "; address.CountryCode = " "; address.PostalCode = " "; address.AddressType = "Home"; address.City = reservationContext.Guest_City; // Here I'm assuming that no one will select state without city (they are both required fields anyway) if (!string.IsNullOrEmpty(reservationContext.Guest_State)) { address.ProvinceCode = reservationContext.Guest_State; } guest.Addresses.Add(address); } if (!string.IsNullOrEmpty(reservationContext.Guest_PhoneNumber)) { guest.Phones = new List <Models.ResortService.BookReservationRequest.Phone>(); var phone = new Models.ResortService.BookReservationRequest.Phone(); phone.PhoneNumberType = "Home"; phone.PhoneNumber = reservationContext.Guest_PhoneNumber; guest.Phones.Add(phone); } request.Guests.Add(guest); } } if (reservationContext.hasAddress) { } if (Session["AgentLoginID"] == null) { request.Agent = "OWNER"; } else { request.Agent = (string)Session["AgentLoginID"]; } ResortService resortService = new ResortService(); var reservationResponse = resortService.BookReservation(request); OwnerWebStats(request, reservationResponse); return(reservationResponse); }
public ActionResult ReservationConfirmation() { var model = GetLayoutItem <ReservationConfirmation>(); BlueGreenContext bgcontext = new BlueGreenContext(); var reservationNo = Request.QueryString["reservationNo"]; if (!string.IsNullOrEmpty(reservationNo)) { var reservationType = Request.QueryString["type"]; model.ActiveReservation = bgcontext.GetActiveReservation(reservationNo, reservationType); model.BxgOwner = bgcontext.bxgOwner; if (model.ActiveReservation != null) { model.taxTotal = ReservationUtils.CalculateReservationTax(model.ActiveReservation); model.ActiveReservation.Amount = model.taxTotal + model.ActiveReservation.AmountDue; model.Guest_NumberOfGuest = model.ActiveReservation.NumberOfAdults; string specialCharacter = Sitecore.Configuration.Settings.GetSetting("IdentifierForSpecialRequestFromBGO"); model.ActiveReservation.Comments = StringUtils.Between(model.ActiveReservation.Comments, specialCharacter, specialCharacter); Session["ActiveReservation"] = model.ActiveReservation; Session["instanceResort"] = ResortUtils.GetResortInfoDetails(FormatUtils.ConvertStringToInt(model.ActiveReservation.ProjectStay), model.ActiveReservation.MaximumOccupancy); //setup session object requied by the Cancel page ReservationHistoryItem tmp = new ReservationHistoryItem(); //This is the object cancel expect in the session DateTime DateConfirmed = DateTime.Parse(FormatUtils.GetDate(model.ActiveReservation.DateConfirmed)); tmp._DateConfirmed = DateConfirmed.ToString("yyyyMMdd"); tmp._Points = model.ActiveReservation.Points; DateTime checkinDate = DateTime.Parse(FormatUtils.GetDate(model.ActiveReservation.CheckInDate)); tmp._CheckInDate = checkinDate.ToString("yyyyMMdd"); tmp._ReservationType = model.ActiveReservation.ReservationType; tmp._NumberOfNights = model.ActiveReservation.NumberOfNights.ToString(); tmp._Amount = model.ActiveReservation.Amount.ToString(); tmp._AmountDue = model.ActiveReservation.AmountDue.ToString(); tmp._ReservationNumber = model.ActiveReservation.ReservationNumber; tmp._ReservationStatus = model.ActiveReservation.ReservationStatus; tmp._GuestFullName = model.ActiveReservation.Guests[0].FullName; tmp._NumberOfAdults = model.ActiveReservation.NumberOfAdults; tmp._MaximumOccupancy = model.ActiveReservation.MaximumOccupancy; tmp._Handicap = model.ActiveReservation.Handicap; var Room = ResortManager.GetRoom(Convert.ToInt16(model.ActiveReservation.ProjectStay), model.ActiveReservation.AS400UnitType); if (Room != null) { tmp._VillaDescription = Room.ViewTitle; } tmp._PolicyStatus = FormatUtils.PolicyStatus(model.ActiveReservation.PolicyStatus, model.ActiveReservation.EligibleDate, reservationType, model.ActiveReservation.ReservationNumber, model.ActiveReservation.ExchangeCode, model.ActiveReservation.ReservationType); Session["ReservationSelected4Details"] = tmp; Session["PPPStatus"] = tmp._PolicyStatus; Session["PPPFee"] = model.ActiveReservation.PolicyPrice; Session["resConfNum"] = model.ActiveReservation.ReservationNumber; //Only get the Guests when reservation is Points if (model.ActiveReservation.ReservationType == "P") { BGSitecore.Services.ResortService resortService = new BGSitecore.Services.ResortService(); var allGuest = resortService.OwnerGuestList(bgcontext.OwnerId); if (allGuest != null && allGuest.Guests != null && allGuest.Guests.Count() > 0) { if (model.allGuest == null) { model.allGuest = new List <BGSitecore.Models.ResortService.ScreeningBookReservationResponse.Guest>(); } foreach (BGSitecore.Models.ResortService.OwnerGuestList.Guest guest in allGuest.Guests) { if (model.ActiveReservation.Guests != null && model.ActiveReservation.Guests.Count > 0) { if (guest.GuestID == model.ActiveReservation.Guests[0].GuestID) { //Email and phone number are not return with the reservation. We need to get those values from the list or guests if (guest.Emails != null && guest.Emails.Count > 0) { model.ActiveReservation.Guests[0].Emails = new List <Models.ResortService.ReservationsList.Email>(); Models.ResortService.ReservationsList.Email email = new Models.ResortService.ReservationsList.Email(); email.EmailAddress = guest.Emails[0].EmailAddress; model.ActiveReservation.Guests[0].Emails.Add(email); } if (guest.Phones != null && guest.Phones.Count > 0) { model.ActiveReservation.Guests[0].Phones = new List <Models.ResortService.ReservationsList.Phone>(); Models.ResortService.ReservationsList.Phone phone = new Models.ResortService.ReservationsList.Phone(); phone.PhoneNumber = guest.Phones[0].PhoneNumber; model.ActiveReservation.Guests[0].Phones.Add(phone); } } } var findExistingGuest = from existingGuest in model.ActiveReservation.Guests where existingGuest.FullName == guest.LastName + " ," + guest.FirstName && existingGuest.GuestID == "0" select existingGuest; if (findExistingGuest != null && findExistingGuest.Count() > 0) { findExistingGuest.First().GuestID = guest.GuestID; } else { model.allGuest.Add(ReservationUtils.MapOwnerGuestToReservationGuest(guest)); } } } } } return(View(model)); } else { return(null); } }
public ActionResult UpdateReservation(string ReservationNumber, string ReservationType, string AS400UnitType, string CheckInDate, string ProjectStay, string NumberOfNights, string DropDownName, string newGuest, string NumberOfGuest, string FirstName, string LastName, string Email, string Phone, string City, string State, string Relationship, string MaxOccupancy, string GuestID) { JsonResponse jsonResponse = new JsonResponse(); jsonResponse.errors = new List <string>(); jsonResponse.RetCode = "0"; //default to error ReservationHistoryItem sessionObject = (ReservationHistoryItem)Session["ReservationSelected4Details"]; if (jsonResponse.errors.Count <= 0) { ModifyReservationRequest request = new ModifyReservationRequest(); if (ReservationType == "P") { request.SiteName = "onlinepoints"; request.ReservationType = "P"; request.Points = sessionObject._Points; } else { request.SiteName = "BonusTime"; request.ReservationType = "B"; } BlueGreenContext bgContext = new BlueGreenContext(); request.OwnerID = FormatUtils.ConvertStringToInt(bgContext.OwnerId); request.ReservationProjectNumber = ProjectStay; request.UnitTypeCode = AS400UnitType; DateTime checkIn = DateTime.Parse(FormatUtils.GetDate(CheckInDate)); request.CheckInDate = checkIn.ToString("MM/dd/yyyy"); request.LengthOfStay = FormatUtils.ConvertStringToInt(NumberOfNights); request.ReservationNumber = ReservationNumber; request.NumberOfAdults = FormatUtils.ConvertStringToInt(NumberOfGuest); request.Guests = new List <Models.ResortService.ModifyReservationRequest.Guest>(); if (newGuest == "OwnerSelected") { Models.ResortService.ModifyReservationRequest.Guest guest = new Models.ResortService.ModifyReservationRequest.Guest(); guest.GuestType = "Primary"; //guest.GuestID = FormatUtils.ConvertStringToInt(GuestID); guest.FirstName = FirstName; guest.LastName = LastName; request.Guests.Add(guest); } else { Models.ResortService.ModifyReservationRequest.Guest guest = new Models.ResortService.ModifyReservationRequest.Guest(); guest.GuestType = "GuestOnPrimary"; guest.GuestID = FormatUtils.ConvertStringToInt(GuestID); guest.FirstName = FirstName; guest.LastName = LastName; guest.Relationship = Relationship; if (!string.IsNullOrEmpty(Email)) { guest.EmailAddresses = new List <Models.ResortService.ModifyReservationRequest.EmailAddress>(); var email = new Models.ResortService.ModifyReservationRequest.EmailAddress(); email.AddressType = "Home"; email.Email = Email; guest.EmailAddresses.Add(email); } guest.Addresses = new List <Models.ResortService.ModifyReservationRequest.Address>(); var address = new Models.ResortService.ModifyReservationRequest.Address(); address.AddressType = "Home"; address.City = City; address.ProvinceCode = State; guest.Addresses.Add(address); if (!string.IsNullOrEmpty(Phone)) { guest.Phones = new List <Models.ResortService.ModifyReservationRequest.Phone>(); var phone = new Models.ResortService.ModifyReservationRequest.Phone(); phone.PhoneNumberType = "Home"; phone.PhoneNumber = Phone; guest.Phones.Add(phone); } request.Guests.Add(guest); } ResortService resortService = new Services.ResortService(); var response = resortService.ModifyReservation(request); if (response.Errors == null) { sessionObject._GuestFullName = LastName + ", " + FirstName; sessionObject._NumberOfAdults = NumberOfGuest; Session["ReservationSelected4Details"] = sessionObject; jsonResponse.RetCode = "0"; } else { jsonResponse.errors.Add("Error updating the reservation"); } } return(Json(jsonResponse)); }
public ActionResult CalculateMaintenenceCalculate(string amountwithdividents) { bool bIsValid = true; double dblDollarAmountWithDividends = 0; double dblAmountPaidWithDividends = 0; double dblBalanceDue = 0; bool validateInputStatus = true; string cashvalue = ""; double lblMaintenanceBalanceDue = 0; JsonResponse jsonResponse = new JsonResponse(); jsonResponse.errors = new List <string>(); jsonResponse.RetCode = "0"; //default to error BlueGreenContext bgContext = new BlueGreenContext(); try { // Null Check + Invalid characters + numbers < 1 // Invalid Input if (string.IsNullOrEmpty(amountwithdividents) || !double.TryParse(amountwithdividents, out dblDollarAmountWithDividends) || Convert.ToDouble(amountwithdividents) < 1) { jsonResponse.RetCode = "10"; jsonResponse.errors.Add("Please enter only numbers (0-9) in this field."); validateInputStatus = false; } else { amountwithdividents = amountwithdividents.Replace("$", ""); //if (!isCartItemValid(Convert.ToDecimal(amountwithdividents))) //{ // jsonResponse.RetCode = "15"; // Invalid Input // jsonResponse.errors.Add("The selected item cannot be added to your cart because the total required rewards exceeds the amount of available rewards you have earned."); //} //else //{ dblDollarAmountWithDividends = Convert.ToDouble(amountwithdividents); //Amount Paid With Dividends dblAmountPaidWithDividends = dblDollarAmountWithDividends / 100; cashvalue = dblAmountPaidWithDividends.ToString("#0.00"); //Balance Due if (bgContext.bxgOwner.PaymentBalance > 0) { dblBalanceDue = bgContext.bxgOwner.PaymentBalance; lblMaintenanceBalanceDue = dblBalanceDue - dblAmountPaidWithDividends; } //} } } catch (Exception ex) { jsonResponse.RetCode = "11"; // Invalid Input validateInputStatus = false; jsonResponse.errors.Add("Unexpected exception occured ,Please try again "); } return(Json(new { JsonResponse = jsonResponse, MaintenanceBalanceDue = lblMaintenanceBalanceDue, cashvalue = cashvalue }, JsonRequestBehavior.AllowGet)); }
///<summary> ///Compares Validity of each item from itemsTobeValidated to sourceData List With Sitecore Values ///</summary> ///<param name="itemsTobeValidated"></param> ///<param name="sourceData"></param> /// <returns>JsonResponse</returns> public JsonResponse validateCartItems(List <CartItem> itemsTobeValidated, List <CartItem> sourceData, bool isUpdate = false) { JsonResponse jsonResponse = new JsonResponse(); jsonResponse.errors = new List <string>(); jsonResponse.RetCode = "1"; Sitecore.Data.Database dbContext = Sitecore.Context.Database; BlueGreenContext bgContext = new BlueGreenContext(); var encoreAvailRewards = (bgContext != null && bgContext.bxgOwner != null && bgContext.bxgOwner.EncoreBenefits != null) ? bgContext.bxgOwner.EncoreBenefits.DividendsBalance : 0; CartTotal CartTotal = new CartTotal() { AvailableRewards = encoreAvailRewards, TotalRewardsinCart = (sourceData.Count > 0) ? sourceData.Select(t => t.SubTotal).Sum() : 0, AvailablePoints = encoreAvailRewards - ((sourceData.Count > 0) ? sourceData.Select(t => t.SubTotal).Sum() : 0) }; //Loop to check Whether each item has Actual price listed in Sitecore foreach (CartItem itemToBeAdded in itemsTobeValidated) { // If the item price/SubTotal is zero do not allow to add to reward cart if (!isUpdate && (itemToBeAdded.UnitPrice == 0 || itemToBeAdded.SubTotal == 0)) { jsonResponse.RetCode = "1"; jsonResponse.errors.Add("Please try to add/update valid cart item"); } if (!itemToBeAdded.ItemID.Equals("MF")) { // verify that the unit price matches the actual unit price defined in Sitecore and has not been altered Sitecore.Data.Items.Item thisItem = dbContext.GetItem(itemToBeAdded.ItemID); string itemUnitPrice = thisItem.Fields["Item Value"].Value.Replace(",", ""); if (!itemToBeAdded.UnitPrice.Equals(Convert.ToDecimal(itemUnitPrice))) { // somebody tampered with the data manipulating the unit price jsonResponse.RetCode = "1"; jsonResponse.errors.Add("Validation error: Unit Price Invalid"); } } if (itemToBeAdded.SubTotal != itemToBeAdded.Quantity * itemToBeAdded.UnitPrice) { // somebody tampered with the data manipulating the unit price jsonResponse.RetCode = "1"; jsonResponse.errors.Add("Validation error: Sub Total Tampered"); } // Check whether you already have one Error generated if so , break loop to avoid duplicate Error on Page if (jsonResponse.errors.Any()) { break; } } // Execute the Code Only if there are no Errors from previous checks // This Code is for Case where List of Items come in through Update Process and Available points go as negative if (!jsonResponse.errors.Any()) { if (CartTotal.AvailablePoints >= 0 && !isUpdate) { decimal subTotalOfSingleItem = 0; var itemInCartAlready = sourceData.Where(x => itemsTobeValidated.Any(item => x.ItemID.Contains(item.ItemID))); if (itemInCartAlready.Any() && itemsTobeValidated.Any() && !itemsTobeValidated.First().ItemID.Equals("MF")) { // Hotfix Issue : Not enuf points - subTotalOfSingleItem = (subtotalOfItemWhichIsbeingAdded -subTotalFromDatabaseForThatItem) var sumOfTotalFromIncomingList = itemsTobeValidated.Select(t => t.SubTotal).Sum(); var sumOfTotalFromDb = itemInCartAlready.Select(z => z.SubTotal).Sum(); subTotalOfSingleItem = sumOfTotalFromIncomingList > sumOfTotalFromDb ? sumOfTotalFromIncomingList - sumOfTotalFromDb : sumOfTotalFromDb - sumOfTotalFromIncomingList; } else { subTotalOfSingleItem = (itemsTobeValidated.Count > 0) ? itemsTobeValidated.Select(t => t.SubTotal).Sum() : 0; } if (subTotalOfSingleItem <= CartTotal.AvailablePoints) { jsonResponse.RetCode = "0"; } else { jsonResponse.RetCode = "1"; string customError = isUpdate ? "Your cart cannot be updated because the total required rewards exceeds the amount of available rewards you have earned. The quantity in cart has been adjusted to the prior quantity submitted." : "The selected item cannot be added to your cart because the total required rewards exceeds the amount of available rewards you have earned."; jsonResponse.errors.Add(customError); } } else if (CartTotal.AvailablePoints >= 0 && isUpdate) { jsonResponse.RetCode = "0"; } else { string customError = string.Empty; jsonResponse.RetCode = "1"; // This is to match JS message customError = isUpdate ? "Your cart cannot be updated because the total required rewards exceeds the amount of available rewards you have earned. The quantity in cart has been adjusted to the prior quantity submitted." : "The selected item cannot be added to your cart because the total required rewards exceeds the amount of available rewards you have earned."; jsonResponse.errors.Add(customError); } } return(jsonResponse); }
public ActionResult SubmitSaveMyPoint(string CCName, string CCNumber, string CVV, string ExpMonth, string ExpYear, string ZipCode, string cctype, bool InternationalZipCode) { SaveMyPointsResponse response = new SaveMyPointsResponse(); ReservationParameters model = new ReservationParameters(); model.CreditCard_ExpDateMonth = ExpMonth; model.CreditCard_ExpDateYear = ExpYear; model.CreditCard_Name = CCName; model.CreditCard_Number = CCNumber; model.CreditCard_VerificationNumber = CVV; model.CreditCard_ZipCode = ZipCode; model.CreditCard_InternationalZipCode = InternationalZipCode; BlueGreenContext bgContext = new BlueGreenContext(); model.CreditCard_Type = FormatUtils.ConvertCreditCard(cctype); var listOfError = ValidationUtils.GetCreditCardViolations(model); if (listOfError.Count() <= 0) { BGSitecore.Models.OwnerService.OwnerSavePointsElectRequest.OwnerSavePointsElectRequest request = new BGSitecore.Models.OwnerService.OwnerSavePointsElectRequest.OwnerSavePointsElectRequest(); request.Identifier = bgContext.OwnerId; request.AgentID = "OWNER"; request.NameOnCard = model.CreditCard_Name; request.Amount = bgContext.GetSavePointsFee; request.CreditCardInfo = new BGSitecore.Models.OwnerService.OwnerSavePointsElectRequest.CreditCardInfo(); request.CreditCardInfo.CreditCardNumber = model.CreditCard_Number; request.CreditCardInfo.CreditCardExpirationDate = ReservationUtils.GetExpDate(model.CreditCard_ExpDateMonth, model.CreditCard_ExpDateYear); request.CreditCardInfo.CreditCardType = model.CreditCard_Type; request.CreditCardInfo.CreditCardCVV = model.CreditCard_VerificationNumber; ProfileService service = new ProfileService(); var pointResponse = service.OwnerSavePointsElect(request); if (pointResponse != null && pointResponse.RetCode == "0") { response.RetCode = "0"; //TODO move this code bgContext.bxgOwner.AnnualPointsExpiration.SavePointsEligible = false; bgContext.bxgOwner.AnnualPointsExpiration.SavePointsFee = "0.00"; bgContext.bxgOwner.AnnualPointsExpiration.SavePointsMessage = ""; //save owner object with updated annualpoints expiration Session["BXGOwner"] = bgContext.bxgOwner; response.AuthorizationNumber = pointResponse.AuthorizationNumber; OwnerUtils.SetContextToReloadPalett(); } else { response.RetCode = "-1"; response.errors = new List <string>(); response.errors.Add("Internal error try again later."); } } else { response.RetCode = "-1"; response.errors = new List <string>(); foreach (var item in listOfError) { response.errors.Add(item.ErrorMessage); } return(Json(response)); } return(Json(response)); }