コード例 #1
0
        /// <summary>
        /// Gets the registration template fee report.
        /// </summary>
        /// <param name="registrationInstanceId">The registration instance identifier.</param>
        /// <returns></returns>
        public IEnumerable <TemplateFeeReport> GetRegistrationTemplateFeeReport(int registrationInstanceId)
        {
            var qry = new RegistrationRegistrantFeeService(this.Context as RockContext).Queryable();

            qry = qry.Where(a => a.RegistrationRegistrant.Registration.RegistrationInstanceId == registrationInstanceId);

            var result = qry.Select(a => new TemplateFeeReport
            {
                RegistrationId   = a.RegistrationRegistrant.RegistrationId,
                RegistrationDate = a.RegistrationRegistrant.Registration.CreatedDateTime ?? DateTime.MinValue,
                RegisteredByName = a.RegistrationRegistrant.Registration.FirstName + " " + a.RegistrationRegistrant.Registration.LastName,
                RegistrantPerson = a.RegistrationRegistrant.PersonAlias.Person,
                RegistrantId     = a.RegistrationRegistrantId,
                FeeName          = a.RegistrationTemplateFee.Name,
                FeeItemOption    = a.Option,
                FeeItem          = a.RegistrationTemplateFeeItem,
                Quantity         = a.Quantity,
                Cost             = a.Cost
            }).ToList();

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// If this fee has a <see cref="MaximumUsageCount" />, returns the number of allowed usages remaining for the specified <see cref="RegistrationInstance" />
        /// </summary>
        /// <param name="registrationInstance">The registration instance.</param>
        /// <param name="otherRegistrants">The other registrants that have been registered so far in this registration</param>
        /// <returns></returns>
        public int?GetUsageCountRemaining(RegistrationInstance registrationInstance, List <RegistrantInfo> otherRegistrants)
        {
            if (!this.MaximumUsageCount.HasValue || registrationInstance == null)
            {
                return(null);
            }

            int?usageCountRemaining;
            var registrationInstanceId        = registrationInstance.Id;
            var registrationInstanceFeesQuery = new RegistrationRegistrantFeeService(new RockContext()).Queryable().Where(a => a.RegistrationRegistrant.Registration.RegistrationInstanceId == registrationInstanceId);

            var feeUsedCount = registrationInstanceFeesQuery.Where(a => a.RegistrationTemplateFeeItemId == this.Id).Sum(a => ( int? )a.Quantity) ?? 0;

            // get a list of fees that the other registrants in this registrant entry have incurred so far
            List <FeeInfo> otherRegistrantsFees = otherRegistrants?.SelectMany(a => a.FeeValues).Where(a => a.Value != null && a.Key == this.RegistrationTemplateFeeId).SelectMany(a => a.Value).ToList();

            // get the count of fees of this same fee item for other registrants
            int otherRegistrantsUsedCount = otherRegistrantsFees?.Where(a => a.RegistrationTemplateFeeItemId == this.Id).Sum(f => f.Quantity) ?? 0;

            usageCountRemaining = this.MaximumUsageCount.Value - feeUsedCount - otherRegistrantsUsedCount;
            return(usageCountRemaining);
        }