/// <summary> /// Returns a one-line text-only representation of all the services /// included in the pricing summary /// </summary> /// <param name="pricingSummary"></param> /// <returns></returns> internal static string GetOneLineDescription(PricingSummary pricingSummary) { var servicePricings = LcEmailTemplate.ServicePricing.GetForPricingSummary(pricingSummary); var details = servicePricings.Select(v => LcRest.PricingSummaryDetail.GetOneLineDescription(v.service, v.pricing)); return(ASP.LcHelpers.JoinNotEmptyStrings("; ", details)); }
/// <summary> /// Save the given pricing summary and returns a copy of the record from database after /// that (so it includes any generated IDs, dates,..) /// </summary> /// <param name="data"></param> public static PricingSummary Set(PricingSummary data, Database sharedDb = null) { using (var db = new LcDatabase(sharedDb)) { PricingSummary newData = FromDB(db.QuerySingle(sqlInsertItem, data.pricingSummaryID, data.serviceDurationMinutes, data.firstSessionDurationMinutes, data.subtotalPrice, data.clientServiceFeePrice, data.totalPrice, data.serviceFeeAmount, data.cancellationDate, data.cancellationFeeCharged, data.firstTimeServiceFeeFixed, data.firstTimeServiceFeePercentage, data.paymentProcessingFeePercentage, data.paymentProcessingFeeFixed, data.firstTimeServiceFeeMaximum, data.firstTimeServiceFeeMinimum )); if (data.details != null) { // Set original with details, // since the saving needs to set-up the generated IDs newData.details = data.details; // After save it, gets the just generated records, with any timestamp. newData.details = SetDetails(newData, sharedDb); } return(newData); } }
public static IEnumerable <PricingSummaryDetail> SetDetails(PricingSummary summary, Database sharedDb = null) { var newDetails = new List <PricingSummaryDetail>(); foreach (var detail in summary.details) { // Enforce IDs to be up-to-date detail.pricingSummaryID = summary.pricingSummaryID; detail.pricingSummaryRevision = summary.pricingSummaryRevision; // Save each detail newDetails.Add(PricingSummaryDetail.Set(detail, sharedDb)); } return(newDetails); }
public static IEnumerable <ServicePricing> GetForPricingSummary(LcRest.PricingSummary pricingSummary) { if (pricingSummary.details != null && pricingSummary.details.Count() > 0) { var services = LcRest.ServiceProfessionalService.GetFromPricingSummary(pricingSummary.pricingSummaryID, pricingSummary.pricingSummaryRevision); if (services != null) { // Mix booking pricing details and service details in a list, by the common serviceProfessionaServiceID // so is easiest from templates to access all that info while we keep in one database call // the query for all the pricing details (rather than one call per each). foreach (var service in services) { var pricingDetail = pricingSummary.details.First(pd => pd.serviceProfessionalServiceID == service.serviceProfessionalServiceID); yield return(new ServicePricing { service = service, pricing = pricingDetail }); } } } }