예제 #1
0
        /// <inheritdoc/>
        public async Task <IOrganisationWithCommittees> GetOrganisationByIdWithCommitteesAsync(
            IWho who,
            Guid organisationId)
        {
            this.logger.ReportEntry(
                who,
                new { OrganisationId = organisationId });

            IOrganisationWithCommittees organisationWithCommittees = (await this.context.Organisations
                                                                      .AsNoTracking()
                                                                      .TagWith(this.Tag(who))
                                                                      .Include(o => o.Committees)
                                                                      .FirstOrDefaultAsync(o => o.Id == organisationId)
                                                                      .ConfigureAwait(false))
                                                                     .ToDomainWithCommittees();

            this.logger.ReportExit(
                who,
                new
            {
                OrganisationWithCommittees = organisationWithCommittees
            });

            return(organisationWithCommittees);
        }
예제 #2
0
        /// <summary>
        /// Display committees for the specified organisation.
        /// </summary>
        /// <param name="organisationId">The organisation identifier.</param>
        /// <returns>View.</returns>
        public async Task <IActionResult> Index(Guid organisationId)
        {
            IWho who = this.Who();

            this.logger.ReportEntry(
                who,
                new { OrganisationId = organisationId });

            IOrganisationWithCommittees organisation = await this.service
                                                       .GetOrganisationByIdWithCommitteesAsync(
                who : who,
                organisationId : organisationId)
                                                       .ConfigureAwait(false);

            IndexViewModel model = IndexViewModel.Create(organisation);

            ViewResult view = this.View(model);

            this.logger.ReportExitView(
                who,
                view.ViewName,
                view.Model,
                view.StatusCode);

            return(view);
        }
예제 #3
0
        /// <summary>
        /// Creates the Index view model.
        /// </summary>
        /// <param name="organisation">The organisation.</param>
        /// <returns>Index view model.</returns>
        public static IndexViewModel Create(IOrganisationWithCommittees organisation)
        {
            if (organisation == null)
            {
                throw new ArgumentNullException(nameof(organisation));
            }

            return(new IndexViewModel(
                       organisationId: organisation.Id,
                       organisationName: organisation.Name,
                       committeeViewModels: organisation.Committees.Select(CommitteeViewModel.Create).ToList()));
        }
예제 #4
0
        public void Test_With_Valid_List_Of_Committees()
        {
            // ARRANGE
            Guid         paramId       = Guid.NewGuid();
            const string paramCode     = "CBC";
            const string paramName     = "County Bridge Club";
            const string paramBgColour = "000000";

            OrganisationDto organisationDto = new OrganisationDto(
                id: paramId,
                code: paramCode,
                name: paramName,
                bgColour: paramBgColour);

            IList <CommitteeDto> paramCommittees = new List <CommitteeDto>
            {
                new CommitteeDto(
                    id: Guid.NewGuid(),
                    organisationId: organisationDto.Id,
                    name: "TSC",
                    description: "Tournament Sub-Committee",
                    organisation: organisationDto)
            };

            organisationDto.SetPrivatePropertyValue(
                propName: nameof(OrganisationDto.Committees),
                value: paramCommittees);

            // ACT
            IOrganisationWithCommittees organisationWithCommittees =
                organisationDto.ToDomainWithCommittees();

            // ASSERT
            Assert.AreEqual(paramId, organisationWithCommittees.Id);
            Assert.AreEqual(paramCode, organisationWithCommittees.Code);
            Assert.AreEqual(paramName, organisationWithCommittees.Name);
            Assert.AreEqual(paramBgColour, organisationWithCommittees.BgColour);
            Assert.IsNotNull(organisationWithCommittees.Committees);
            Assert.AreEqual(1, organisationWithCommittees.Committees.Count);

            ICommittee committee = organisationWithCommittees.Committees[0];

            Assert.IsNotNull(committee);
            Assert.IsNotNull(committee.Organisation);
            Assert.AreEqual(paramId, committee.Organisation.Id);
        }
예제 #5
0
        /// <inheritdoc/>
        public async Task <IOrganisationWithCommittees> GetOrganisationByIdWithCommitteesAsync(
            IWho who,
            Guid organisationId)
        {
            this.logger.ReportEntry(
                who,
                new { OrganisationId = organisationId });

            IOrganisationWithCommittees organisationWithCommittees = await this.data
                                                                     .GetOrganisationByIdWithCommitteesAsync(
                who : who,
                organisationId : organisationId)
                                                                     .ConfigureAwait(false);

            this.logger.ReportExit(
                who,
                new { OrganisationWithCommittees = organisationWithCommittees });

            return(organisationWithCommittees);
        }