Пример #1
0
        public XElement ToXml()
        {
            var xRoleType = new XElement(RoleTypeXNames.RoleType,
                                         new XAttribute(RoleTypeXNames.Id, Id),
                                         new XAttribute(RoleTypeXNames.Role, Role),
                                         new XElement(RoleTypeXNames.Definition, Definition)
                                         );

            xRoleType.Add(UsedOn.Select(uo => new XElement(RoleTypeXNames.UsedOn, uo)));

            return(xRoleType);
        }
Пример #2
0
        private void AssertCredits <T>(IUser administrator, IEmployer employer, UsedOn usedOn, ICreditOwner owner, bool hasExercisedCredit, Allocation allocation, Allocation[] allAllocations)
            where T : Credit
        {
            LogIn(administrator);

            // Check who the employer has exercised credits on.

            AssertEmployerCreditUsage <T>(employer, owner, hasExercisedCredit, usedOn);

            if (owner is Employer)
            {
                // Check their credits.

                AssertEmployerCredits(employer, allAllocations);

                // Check the allocation.

                if (allocation != null)
                {
                    AssertEmployerCreditUsage(employer, allocation, hasExercisedCredit, usedOn);
                }
            }
            else if (owner is Organisation)
            {
                var organisation = owner as Organisation;

                // Check their credits.

                AssertOrganisationCredits(organisation, allAllocations);

                // Check who has used the organisation's credits.

                AssertOrganisationCreditUsage <T>(organisation, employer, hasExercisedCredit, usedOn);

                // Check the allocation.

                if (allocation != null)
                {
                    AssertOrganisationCreditUsage(organisation, employer, allocation, hasExercisedCredit, usedOn);
                }
            }

            LogOut();
        }