public AmendResponseHolder DoAddProductAmendment(String subscriptionId, DateTime effectiveDate, String productRatePlanId, AmendOptions ao = null, PreviewOptions po = null) { AmendRequest amendRequest = new AmendRequest(); Amendment amendment = new Amendment(); amendment.Name = "Add Product Amendment"; amendment.Type = "NewProduct"; amendment.ContractEffectiveDate = effectiveDate; amendment.ContractEffectiveDateSpecified = true; amendment.SubscriptionId = subscriptionId; RatePlanData ratePlanData = new RatePlanData(); RatePlan ratePlan = new RatePlan(); ratePlan.ProductRatePlanId = productRatePlanId; ratePlanData.RatePlan = ratePlan; amendment.RatePlanData = ratePlanData; if (ao != null) { amendRequest.AmendOptions = ao; } if (po != null) { amendRequest.PreviewOptions = po; } amendRequest.Amendments = new Amendment[] { amendment }; return zs.Amend(new List<AmendRequest> { amendRequest })[0]; }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (BaseAmount == null) { throw new ValidationException(ValidationRules.CannotBeNull, "BaseAmount"); } if (RatePlan == null) { throw new ValidationException(ValidationRules.CannotBeNull, "RatePlan"); } if (TotalGrossAmount == null) { throw new ValidationException(ValidationRules.CannotBeNull, "TotalGrossAmount"); } if (UnitGroup == null) { throw new ValidationException(ValidationRules.CannotBeNull, "UnitGroup"); } if (Actions != null) { foreach (var element in Actions) { if (element != null) { element.Validate(); } } } if (BaseAmount != null) { BaseAmount.Validate(); } if (IncludedServices != null) { foreach (var element1 in IncludedServices) { if (element1 != null) { element1.Validate(); } } } if (RatePlan != null) { RatePlan.Validate(); } if (TotalGrossAmount != null) { TotalGrossAmount.Validate(); } if (Unit != null) { Unit.Validate(); } if (UnitGroup != null) { UnitGroup.Validate(); } }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (GrossDailyRate == null) { throw new ValidationException(ValidationRules.CannotBeNull, "GrossDailyRate"); } if (Group == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Group"); } if (Id == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Id"); } if (Property == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Property"); } if (RatePlan == null) { throw new ValidationException(ValidationRules.CannotBeNull, "RatePlan"); } if (UnitGroup == null) { throw new ValidationException(ValidationRules.CannotBeNull, "UnitGroup"); } if (Actions != null) { foreach (var element in Actions) { if (element != null) { element.Validate(); } } } if (GrossDailyRate != null) { GrossDailyRate.Validate(); } if (Group != null) { Group.Validate(); } if (Property != null) { Property.Validate(); } if (RatePlan != null) { RatePlan.Validate(); } if (UnitGroup != null) { UnitGroup.Validate(); } }
public void TestSerialization() { var sut = new RatePlan(); JsonHelper.GetSerializedKeys(sut).Should().BeEquivalentTo(new SortedSet <string> { "id", "public_name", "currency", "scope", "sets", "is_contract", "externally_managed" }); }
public async Task <IActionResult> CreateRatePlan(RatePlan rateplan) { if (rateplan == null) { return(BadRequest("Folio object is null")); } await _repoWrapper.RatePlan.CreateRatePlanAsync(rateplan); _repoWrapper.Save(); return(CreatedAtRoute("GetRatePlan", new { id = rateplan.Id }, rateplan)); }
private void ProcessRatePlan(string hoteId, IList <OTA_HotelRatePlanRS.RatePlansLocalType.RatePlanLocalType> ratePlans, bool ifNeedUpdateRatePlan, bool isInitilize) { if (Check(ratePlans)) { foreach (var item in ratePlans) { int RatePlanId = -1; using (var context = new TravelDBContext()) { int ratePlanCode = Convert.ToInt32(item.RatePlanCode); EfRepository <RatePlan> ratePlanContext = new EfRepository <RatePlan>(context); var rpCheck = (from r in ratePlanContext.Table where r.HoteID == hoteId && r.RatePlanCode == ratePlanCode select r).ToList(); if (rpCheck.Count > 0) { RatePlanId = rpCheck.First().Id; } else { RatePlan rp = new RatePlan(); rp.RatePlanCategory = item.RatePlanCategory; rp.IsCommissionable = Convert.ToBoolean(item.IsCommissionable); rp.LastModifyTime = DateTime.Now; rp.MarketCode = item.MarketCode; rp.RatePlanCode = ratePlanCode; rp.RateReturn = Convert.ToBoolean(item.RateReturn); rp.HoteID = hoteId; ratePlanContext.Insert(rp); RatePlanId = rp.Id; } } InsertRate(RatePlanId, item.Rates, !isInitilize); InsertOffers(RatePlanId, item.Offers); InsertBookingRules(Convert.ToInt32(RatePlanId), item.BookingRules); } } }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (CancellationFee == null) { throw new ValidationException(ValidationRules.CannotBeNull, "CancellationFee"); } if (NoShowFee == null) { throw new ValidationException(ValidationRules.CannotBeNull, "NoShowFee"); } if (PrePaymentAmount == null) { throw new ValidationException(ValidationRules.CannotBeNull, "PrePaymentAmount"); } if (RatePlan == null) { throw new ValidationException(ValidationRules.CannotBeNull, "RatePlan"); } if (TaxDetails == null) { throw new ValidationException(ValidationRules.CannotBeNull, "TaxDetails"); } if (TimeSlices == null) { throw new ValidationException(ValidationRules.CannotBeNull, "TimeSlices"); } if (TotalGrossAmount == null) { throw new ValidationException(ValidationRules.CannotBeNull, "TotalGrossAmount"); } if (UnitGroup == null) { throw new ValidationException(ValidationRules.CannotBeNull, "UnitGroup"); } if (CancellationFee != null) { CancellationFee.Validate(); } if (CityTax != null) { CityTax.Validate(); } if (NoShowFee != null) { NoShowFee.Validate(); } if (PrePaymentAmount != null) { PrePaymentAmount.Validate(); } if (RatePlan != null) { RatePlan.Validate(); } if (TaxDetails != null) { foreach (var element in TaxDetails) { if (element != null) { element.Validate(); } } } if (TimeSlices != null) { foreach (var element1 in TimeSlices) { if (element1 != null) { element1.Validate(); } } } if (TotalGrossAmount != null) { TotalGrossAmount.Validate(); } if (UnitGroup != null) { UnitGroup.Validate(); } if (ValidationMessages != null) { foreach (var element2 in ValidationMessages) { if (element2 != null) { element2.Validate(); } } } }
public SubscribeRequest CreatSubscriptionRequest(DateTime date) { String rateplanid = CreateRatePlanToSubscribe(); SubscribeRequest subrequest = new SubscribeRequest(); subrequest.Account = MakeTestAccount(); subrequest.BillToContact = MakeTestContact(); subrequest.PaymentMethod = MakeTestPaymentMethod(); SubscriptionData sd = new SubscriptionData(); sd.Subscription = MakeTestSubscription(date); RatePlanData rpd = new RatePlanData(); RatePlan rp = new RatePlan(); rp.ProductRatePlanId = rateplanid; rpd.RatePlan = rp; sd.RatePlanData = new RatePlanData[] { rpd }; subrequest.SubscriptionData = sd; return subrequest; }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (UniqueName != null) { p.Add(new KeyValuePair <string, string>("UniqueName", UniqueName)); } if (CallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CallbackMethod", CallbackMethod.ToString())); } if (CallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallbackUrl", CallbackUrl.AbsoluteUri)); } if (FriendlyName != null) { p.Add(new KeyValuePair <string, string>("FriendlyName", FriendlyName)); } if (RatePlan != null) { p.Add(new KeyValuePair <string, string>("RatePlan", RatePlan.ToString())); } if (Status != null) { p.Add(new KeyValuePair <string, string>("Status", Status.ToString())); } if (CommandsCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("CommandsCallbackMethod", CommandsCallbackMethod.ToString())); } if (CommandsCallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CommandsCallbackUrl", CommandsCallbackUrl.AbsoluteUri)); } if (SmsFallbackMethod != null) { p.Add(new KeyValuePair <string, string>("SmsFallbackMethod", SmsFallbackMethod.ToString())); } if (SmsFallbackUrl != null) { p.Add(new KeyValuePair <string, string>("SmsFallbackUrl", SmsFallbackUrl.AbsoluteUri)); } if (SmsMethod != null) { p.Add(new KeyValuePair <string, string>("SmsMethod", SmsMethod.ToString())); } if (SmsUrl != null) { p.Add(new KeyValuePair <string, string>("SmsUrl", SmsUrl.AbsoluteUri)); } if (VoiceFallbackMethod != null) { p.Add(new KeyValuePair <string, string>("VoiceFallbackMethod", VoiceFallbackMethod.ToString())); } if (VoiceFallbackUrl != null) { p.Add(new KeyValuePair <string, string>("VoiceFallbackUrl", VoiceFallbackUrl.AbsoluteUri)); } if (VoiceMethod != null) { p.Add(new KeyValuePair <string, string>("VoiceMethod", VoiceMethod.ToString())); } if (VoiceUrl != null) { p.Add(new KeyValuePair <string, string>("VoiceUrl", VoiceUrl.AbsoluteUri)); } return(p); }
public SubscribeResponseHolder SubscribeWithExisitingAccount(String accountId, List<ProductRatePlanHolder> productRatePlans, Subscription sub, PreviewOptions po, SubscribeOptions so) { SubscribeRequest subscribeRequest = new SubscribeRequest(); subscribeRequest.SubscribeOptions = so; subscribeRequest.PreviewOptions = po; Account acc = new Account(); acc.Id = accountId; subscribeRequest.Account = acc; SubscriptionData subData = new SubscriptionData(); sub.AccountId = accountId; subData.Subscription = sub; List<RatePlanData> rpdList = new List<RatePlanData>(); foreach (ProductRatePlanHolder prph in productRatePlans) { RatePlanData ratePlanData = new RatePlanData(); RatePlan ratePlan = new RatePlan(); ratePlan.ProductRatePlanId = prph.ProductRatePlan.Id; ratePlanData.RatePlan = ratePlan; List<RatePlanChargeData> rpcData = new List<RatePlanChargeData>(); foreach(ProductRatePlanChargeHolder prpch in prph.ProductRatePlanCharges) { ProductRatePlanCharge prpc = prpch.ProductRatePlanCharge; //set quantity and add chargeData if applicable if ((prpc.ChargeModel.Equals("Per Unit Pricing") || prpc.ChargeModel.Equals("Tiered Pricing") || prpc.ChargeModel.Equals("Volume Pricing"))) { RatePlanChargeData ratePlanChargeData = new RatePlanChargeData(); RatePlanCharge ratePlanCharge = new RatePlanCharge(); ratePlanCharge.ProductRatePlanChargeId = prpc.Id; ratePlanCharge.QuantitySpecified = true; ratePlanCharge.Quantity = prpc.DefaultQuantity; ratePlanChargeData.RatePlanCharge = ratePlanCharge; rpcData.Add(ratePlanChargeData); } } if (rpcData.Count != 0) { ratePlanData.RatePlanChargeData = rpcData.ToArray(); } rpdList.Add(ratePlanData); } subData.RatePlanData = rpdList.ToArray(); subscribeRequest.SubscriptionData = subData; return zs.Subscribe(new List<SubscribeRequest>{subscribeRequest})[0]; }
/*public ResponseHolder GetCurrentSubscription(String subscriptionId) { String subscriptionQuery = "SELECT Id,Name,Status,Version,PreviousSubscriptionId,ContractEffectiveDate,TermStartDate FROM Subscription WHERE AccountId='" + subscriptionId + "' AND Status='Active'AND Status='Active'"; Subscription activeSubscription = (Subscription)zs.Query(subscriptionQuery).Objects[0]; String RatePlanString = "SELECT Id,Name,ProductRatePlanId FROM RatePlan WHERE SubscriptionId='" + activeSubscription.Id + "'"; ResponseHolder ratePlans = zs.Query(RatePlanString); foreach (zObject ratePlan in ratePlans.Objects) { } }*/ public SubscribeResponseHolder Subscribe(Account acc, Contact con, PaymentMethod pay, List<ProductRatePlanHolder> productRatePlans, Subscription sub, PreviewOptions po, SubscribeOptions so) { SubscribeRequest subscribeRequest = new SubscribeRequest(); subscribeRequest.SubscribeOptions = so; subscribeRequest.PreviewOptions = po; subscribeRequest.Account = acc; subscribeRequest.BillToContact = con; //Payment Method isn't required to subscribe if (pay != null) { subscribeRequest.PaymentMethod = pay; } SubscriptionData subData = new SubscriptionData(); sub.AccountId = acc.Id; subData.Subscription = sub; List<RatePlanData> rpdList = new List<RatePlanData>(); foreach (ProductRatePlanHolder prph in productRatePlans) { RatePlanData ratePlanData = new RatePlanData(); RatePlan ratePlan = new RatePlan(); ratePlan.ProductRatePlanId = prph.ProductRatePlan.Id; ratePlanData.RatePlan = ratePlan; List<RatePlanChargeData> rpcData = new List<RatePlanChargeData>(); if (prph.ProductRatePlanCharges != null) { foreach (ProductRatePlanChargeHolder prpch in prph.ProductRatePlanCharges) { ProductRatePlanCharge prpc = prpch.ProductRatePlanCharge; //set quantity and add chargeData if applicable if ((prpc.ChargeModel.Equals("Per Unit Pricing") || prpc.ChargeModel.Equals("Tiered Pricing") || prpc.ChargeModel.Equals("Volume Pricing"))) { RatePlanChargeData ratePlanChargeData = new RatePlanChargeData(); RatePlanCharge ratePlanCharge = new RatePlanCharge(); ratePlanCharge.ProductRatePlanChargeId = prpc.Id; ratePlanCharge.QuantitySpecified = true; ratePlanCharge.Quantity = prpc.DefaultQuantity; ratePlanChargeData.RatePlanCharge = ratePlanCharge; rpcData.Add(ratePlanChargeData); } } } if (rpcData.Count != 0) { ratePlanData.RatePlanChargeData = rpcData.ToArray(); } rpdList.Add(ratePlanData); } subData.RatePlanData = rpdList.ToArray(); subscribeRequest.SubscriptionData = subData; return zs.Subscribe(new List<SubscribeRequest> { subscribeRequest })[0]; }
protected RatePlanData[] makeRatePlanData(ProductRatePlanCharge[] charges) { RatePlanData[] data = new RatePlanData[charges.Length]; for (int i = 0; i < charges.Length; i++) { ProductRatePlanCharge charge = charges[i]; RatePlanData ratePlanData = new RatePlanData(); RatePlan ratePlan = new RatePlan(); ratePlanData.RatePlan = ratePlan; ratePlan.AmendmentType = "NewProduct"; ratePlan.ProductRatePlanId = charge.ProductRatePlanId; RatePlanChargeData ratePlanChargeData = new RatePlanChargeData(); ratePlanData.RatePlanChargeData = new RatePlanChargeData[] { ratePlanChargeData }; RatePlanCharge ratePlanCharge = new RatePlanCharge(); ratePlanChargeData.RatePlanCharge = ratePlanCharge; ratePlanCharge.ProductRatePlanChargeId = charge.Id; // if it has a default quantity, default to 1 if (charge.DefaultQuantitySpecified) { ratePlanCharge.Quantity = 1; } ratePlanCharge.QuantitySpecified = true; ratePlanCharge.TriggerEvent = "ServiceActivation"; data[i] = ratePlanData; } return data; }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (CancellationFee == null) { throw new ValidationException(ValidationRules.CannotBeNull, "CancellationFee"); } if (Id == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Id"); } if (Property == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Property"); } if (RatePlan == null) { throw new ValidationException(ValidationRules.CannotBeNull, "RatePlan"); } if (TotalGrossAmount == null) { throw new ValidationException(ValidationRules.CannotBeNull, "TotalGrossAmount"); } if (UnitGroup == null) { throw new ValidationException(ValidationRules.CannotBeNull, "UnitGroup"); } if (CancellationFee != null) { CancellationFee.Validate(); } if (Company != null) { Company.Validate(); } if (PaymentAccount != null) { PaymentAccount.Validate(); } if (Property != null) { Property.Validate(); } if (RatePlan != null) { RatePlan.Validate(); } if (Services != null) { foreach (var element in Services) { if (element != null) { element.Validate(); } } } if (TotalGrossAmount != null) { TotalGrossAmount.Validate(); } if (UnitGroup != null) { UnitGroup.Validate(); } }
private RatePlanData[] makeRatePlanData(ProductRatePlanCharge charge) { var ratePlanData = new RatePlanData(); var ratePlan = new RatePlan(); ratePlanData.RatePlan = ratePlan; ratePlan.AmendmentType = "NewProduct"; ratePlan.ProductRatePlanId = charge.ProductRatePlanId; var ratePlanChargeData = new RatePlanChargeData(); ratePlanData.RatePlanChargeData = new[] {ratePlanChargeData}; var ratePlanCharge = new RatePlanCharge(); ratePlanChargeData.RatePlanCharge = ratePlanCharge; ratePlanCharge.ProductRatePlanChargeId = charge.Id; ratePlanCharge.Quantity = 1; ratePlanCharge.QuantitySpecified = true; ratePlanCharge.TriggerEvent = "ServiceActivation"; return new[] {ratePlanData}; }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (Balance == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Balance"); } if (BookingId == null) { throw new ValidationException(ValidationRules.CannotBeNull, "BookingId"); } if (CancellationFee == null) { throw new ValidationException(ValidationRules.CannotBeNull, "CancellationFee"); } if (Id == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Id"); } if (NoShowFee == null) { throw new ValidationException(ValidationRules.CannotBeNull, "NoShowFee"); } if (PrimaryGuest == null) { throw new ValidationException(ValidationRules.CannotBeNull, "PrimaryGuest"); } if (Property == null) { throw new ValidationException(ValidationRules.CannotBeNull, "Property"); } if (RatePlan == null) { throw new ValidationException(ValidationRules.CannotBeNull, "RatePlan"); } if (TotalGrossAmount == null) { throw new ValidationException(ValidationRules.CannotBeNull, "TotalGrossAmount"); } if (UnitGroup == null) { throw new ValidationException(ValidationRules.CannotBeNull, "UnitGroup"); } if (Actions != null) { foreach (var element in Actions) { if (element != null) { element.Validate(); } } } if (AdditionalGuests != null) { foreach (var element1 in AdditionalGuests) { if (element1 != null) { element1.Validate(); } } } if (AssignedUnits != null) { foreach (var element2 in AssignedUnits) { if (element2 != null) { element2.Validate(); } } } if (Balance != null) { Balance.Validate(); } if (Booker != null) { Booker.Validate(); } if (CancellationFee != null) { CancellationFee.Validate(); } if (CityTax != null) { CityTax.Validate(); } if (Commission != null) { Commission.Validate(); } if (Company != null) { Company.Validate(); } if (NoShowFee != null) { NoShowFee.Validate(); } if (PaymentAccount != null) { PaymentAccount.Validate(); } if (PrimaryGuest != null) { PrimaryGuest.Validate(); } if (Property != null) { Property.Validate(); } if (RatePlan != null) { RatePlan.Validate(); } if (Services != null) { foreach (var element3 in Services) { if (element3 != null) { element3.Validate(); } } } if (TimeSlices != null) { foreach (var element4 in TimeSlices) { if (element4 != null) { element4.Validate(); } } } if (TotalGrossAmount != null) { TotalGrossAmount.Validate(); } if (Unit != null) { Unit.Validate(); } if (UnitGroup != null) { UnitGroup.Validate(); } if (ValidationMessages != null) { foreach (var element5 in ValidationMessages) { if (element5 != null) { element5.Validate(); } } } }