예제 #1
0
        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);
        }
 /// <summary>
 /// Save the given pricing summary detail and returns a copy of the record from database after
 /// that (so it includes andy generated values)
 /// </summary>
 /// <param name="data"></param>
 public static PricingSummaryDetail Set(PricingSummaryDetail data, Database sharedDb = null)
 {
     using (var db = new LcDatabase(sharedDb))
     {
         return(FromDB(db.QuerySingle(sqlInsertItem,
                                      data.pricingSummaryID, data.pricingSummaryRevision,
                                      data.serviceProfessionalServiceID,
                                      data.serviceProfessionalDataInput,
                                      data.clientDataInput,
                                      data.hourlyPrice,
                                      data.price,
                                      data.serviceDurationMinutes, data.firstSessionDurationMinutes,
                                      data.serviceName, data.serviceDescription,
                                      data.numberOfSessions
                                      )));
     }
     // TODO PricingMod/PricingVariables -> part of code ate SetDataInput, complete and call here?
 }
예제 #3
0
        /// <summary>
        /// Generates the pricing details list (List of PricingSummaryDetail)
        /// for a given list service professional services, fetching from database
        /// the data for each service and computing it as a PricingSummaryDetail.
        /// It replaces any previous details list.
        /// Its recommended a manual call of Calculate* methods to update the summary after this
        ///
        /// TODO Add possibility to include serviceProfessional defined price per service (it allows for
        /// serviceProfessional bookings to set a different price than the default one for the service)
        ///
        /// TODO Add calculation delegation for ProviderPackageMods and support
        /// for fields clientDataInput/serviceProfessionalDataInput (special pricings like housekeeper)
        /// </summary>
        /// <param name="serviceProfessionalUserID"></param>
        /// <param name="services"></param>
        /// <returns>Returns the jobTitleID shared by the given services. 0 if no services.
        /// An exceptions happens if services from different jobTitles are provided</returns>
        public int SetDetailServices(int serviceProfessionalUserID, IEnumerable <int> services)
        {
            var details    = new List <PricingSummaryDetail>();
            var jobTitleID = 0;

            foreach (var service in ServiceProfessionalService.GetListByIds(serviceProfessionalUserID, services))
            {
                if (jobTitleID == 0)
                {
                    jobTitleID = service.jobTitleID;
                }

                details.Add(PricingSummaryDetail.FromServiceProfessionalService(service));
            }

            this.details = details;

            return(jobTitleID);
        }
예제 #4
0
 /// <summary>
 /// Load from database all the links data
 /// </summary>
 public void FillLinks()
 {
     details = PricingSummaryDetail.GetList(pricingSummaryID, pricingSummaryRevision);
 }