Ejemplo n.º 1
0
        private static void UpdateStaffGroups(StaffDetail detail, Staff staff, Predicate <StaffGroupSummary> p1, Predicate <StaffGroup> p2,
                                              IPersistenceContext context)
        {
            // create a helper to sync staff group membership
            CollectionSynchronizeHelper <StaffGroup, StaffGroupSummary> helper =
                new CollectionSynchronizeHelper <StaffGroup, StaffGroupSummary>(
                    delegate(StaffGroup group, StaffGroupSummary summary)
            {
                return(group.GetRef().Equals(summary.StaffGroupRef, true));
            },
                    delegate(StaffGroupSummary groupSummary, ICollection <StaffGroup> groups)
            {
                StaffGroup group = context.Load <StaffGroup>(groupSummary.StaffGroupRef, EntityLoadFlags.Proxy);
                group.AddMember(staff);
            },
                    delegate
            {
                // do nothing
            },
                    delegate(StaffGroup group, ICollection <StaffGroup> groups)
            {
                group.RemoveMember(staff);
            }
                    );

            helper.Synchronize(
                CollectionUtils.Select(staff.Groups, p2),
                CollectionUtils.Select(detail.Groups, p1));
        }
        public void UpdateExternalPractitioner(ExternalPractitionerDetail detail, ExternalPractitioner prac, IPersistenceContext context)
        {
            // validate that only one contact point is specified as default
            var defaultPoints = CollectionUtils.Select(detail.ContactPoints, cp => cp.IsDefaultContactPoint);

            if (defaultPoints.Count > 1)
            {
                throw new RequestValidationException(SR.ExceptionOneDefaultContactPoint);
            }

            var assembler = new PersonNameAssembler();

            assembler.UpdatePersonName(detail.Name, prac.Name);

            prac.LicenseNumber = detail.LicenseNumber;
            prac.BillingNumber = detail.BillingNumber;
            prac.MarkDeactivated(detail.Deactivated);

            // update contact points collection
            var syncHelper = new CollectionSynchronizeHelper <ExternalPractitionerContactPoint, ExternalPractitionerContactPointDetail>(
                delegate(ExternalPractitionerContactPoint cp, ExternalPractitionerContactPointDetail cpDetail)
            {
                // ignore version in this comparison - deal with this issue in the update delegate
                return(cp.GetRef().Equals(cpDetail.ContactPointRef, true));
            },
                delegate(ExternalPractitionerContactPointDetail cpDetail, ICollection <ExternalPractitionerContactPoint> cps)
            {
                // create a new contact point
                var cp = new ExternalPractitionerContactPoint(prac);
                UpdateExternalPractitionerContactPoint(cpDetail, cp, context);
                cps.Add(cp);
            },
                (cp, cpDetail, cps) => UpdateExternalPractitionerContactPoint(cpDetail, cp, context),
                (cp, cps) => cps.Remove(cp));

            syncHelper.Synchronize(prac.ContactPoints, detail.ContactPoints);

            ExtendedPropertyUtils.Update(prac.ExtendedProperties, detail.ExtendedProperties);
        }
Ejemplo n.º 3
0
		public void UpdateExternalPractitioner(ExternalPractitionerDetail detail, ExternalPractitioner prac, IPersistenceContext context)
		{
			// validate that only one contact point is specified as default
			var defaultPoints = CollectionUtils.Select(detail.ContactPoints, cp => cp.IsDefaultContactPoint);
			if(defaultPoints.Count > 1)
				throw new RequestValidationException(SR.ExceptionOneDefaultContactPoint);

			var assembler = new PersonNameAssembler();
			assembler.UpdatePersonName(detail.Name, prac.Name);

			prac.LicenseNumber = detail.LicenseNumber;
			prac.BillingNumber = detail.BillingNumber;
			prac.MarkDeactivated(detail.Deactivated);

			// update contact points collection
			var syncHelper = new CollectionSynchronizeHelper<ExternalPractitionerContactPoint, ExternalPractitionerContactPointDetail>(
					delegate (ExternalPractitionerContactPoint cp, ExternalPractitionerContactPointDetail cpDetail)
					{
						// ignore version in this comparison - deal with this issue in the update delegate
						return cp.GetRef().Equals(cpDetail.ContactPointRef, true);
					},
					delegate (ExternalPractitionerContactPointDetail cpDetail, ICollection<ExternalPractitionerContactPoint> cps)
					{
						// create a new contact point
						var cp = new ExternalPractitionerContactPoint(prac);
						UpdateExternalPractitionerContactPoint(cpDetail, cp, context);
						cps.Add(cp);
					},
					(cp, cpDetail, cps) => UpdateExternalPractitionerContactPoint(cpDetail, cp, context),
					(cp, cps) => cps.Remove(cp));

			syncHelper.Synchronize(prac.ContactPoints, detail.ContactPoints);

			ExtendedPropertyUtils.Update(prac.ExtendedProperties, detail.ExtendedProperties);
		}
Ejemplo n.º 4
0
		private static void UpdateStaffGroups(StaffDetail detail, Staff staff, Predicate<StaffGroupSummary> p1, Predicate<StaffGroup> p2,
			IPersistenceContext context)
		{
			// create a helper to sync staff group membership
			CollectionSynchronizeHelper<StaffGroup, StaffGroupSummary> helper =
				new CollectionSynchronizeHelper<StaffGroup, StaffGroupSummary>(
					delegate(StaffGroup group, StaffGroupSummary summary)
					{
						return group.GetRef().Equals(summary.StaffGroupRef, true);
					},
					delegate(StaffGroupSummary groupSummary, ICollection<StaffGroup> groups)
					{
						StaffGroup group = context.Load<StaffGroup>(groupSummary.StaffGroupRef, EntityLoadFlags.Proxy);
						group.AddMember(staff);
					},
					delegate
					{
						// do nothing
					},
					delegate(StaffGroup group, ICollection<StaffGroup> groups)
					{
						group.RemoveMember(staff);
					}
				);

			helper.Synchronize(
				CollectionUtils.Select(staff.Groups, p2),
				CollectionUtils.Select(detail.Groups, p1));
		}