Exemplo n.º 1
0
        /// <inheritdoc/>
        public async Task CreateCommitteeAsync(
            IWho who,
            AuditEvent auditEvent,
            ICommittee committee)
        {
            this.logger.ReportEntry(
                who,
                new { Committee = committee });

            try
            {
                IAuditHeaderWithAuditDetails auditHeader = this.data.BeginTransaction(auditEvent, who);

                await this.data.CreateCommitteeAsync(
                    who : who,
                    auditHeader : auditHeader,
                    committee : committee)
                .ConfigureAwait(false);

                await this.data.CommitTransactionAsync(auditHeader)
                .ConfigureAwait(false);
            }
            catch (Exception)
            {
                this.data.RollbackTransaction();
                throw;
            }

            this.logger.ReportExit(who);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update Committee.
        /// </summary>
        /// <param name="who">Who Details.</param>
        /// <param name="model">Edit view model.</param>
        /// <returns>Nothing.</returns>
        private async Task UpdateRecordAsync(
            IWho who,
            EditViewModel model)
        {
            this.logger.ReportEntry(
                who,
                new { Model = model });

            ICommittee originalCommittee = await this.service
                                           .GetCommitteeByIdAsync(
                who : who,
                committeeId : model.CommitteeId)
                                           .ConfigureAwait(false);

            ICommittee committee = model.ToDomain(originalCommittee.Organisation);

            await this.service
            .UpdateCommitteeAsync(
                who : who,
                auditEvent : AuditEvent.CommitteeMaintenance,
                committee : committee)
            .ConfigureAwait(false);

            this.logger.ReportExit(who);
        }
Exemplo n.º 3
0
        public void Test_Passing_Valid_Values()
        {
            // ARRANGE
            OrganisationDto organisationDto = new OrganisationDto(
                id: Guid.NewGuid(),
                code: "CBC",
                name: "County Bridge Club",
                bgColour: "000000");
            CommitteeDto committeeDto = new CommitteeDto(
                id: Guid.NewGuid(),
                organisationId: organisationDto.Id,
                name: "TSC",
                description: "Tournament Sub-Committee",
                organisation: organisationDto);

            // ACT
            ICommittee committee = committeeDto.ToDomain();

            // ASSERT
            Assert.IsNotNull(committee);
            Assert.AreEqual(committeeDto.Id, committee.Id);
            Assert.IsNotNull(committee.Organisation);
            Assert.AreEqual(committeeDto.OrganisationId, committee.Organisation.Id);
            Assert.AreEqual(committeeDto.Name, committee.Name);
            Assert.AreEqual(committeeDto.Description, committee.Description);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Meeting"/> class.
 /// </summary>
 /// <param name="id">Meeting Id.</param>
 /// <param name="committee">Committee.</param>
 /// <param name="meetingDateTime">Date and Time of Meeting.</param>
 public Meeting(
     Guid id,
     ICommittee committee,
     DateTime meetingDateTime)
 {
     this.Id              = id;
     this.Committee       = committee;
     this.MeetingDateTime = meetingDateTime;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Creates the view model.
        /// </summary>
        /// <param name="committee">Committee.</param>
        /// <returns>View model.</returns>
        public static CommitteeViewModel Create(ICommittee committee)
        {
            if (committee == null)
            {
                throw new ArgumentNullException(nameof(committee));
            }

            return(new CommitteeViewModel(
                       committeeId: committee.Id,
                       name: committee.Name,
                       description: committee.Description));
        }
Exemplo n.º 6
0
        public static CommitteeDto ToDto(ICommittee committee)
        {
            if (committee == null)
            {
                throw new ArgumentNullException(nameof(committee));
            }

            return(new CommitteeDto(
                       id: committee.Id,
                       organisationId: committee.Organisation.Id,
                       name: committee.Name,
                       description: committee.Description));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates the view model.
        /// </summary>
        /// <param name="committee">Committee.</param>
        /// <returns>Edit view model.</returns>
        public static EditViewModel Create(ICommittee committee)
        {
            if (committee == null)
            {
                throw new ArgumentNullException(nameof(committee));
            }

            return(new EditViewModel(
                       formState: FormState.Initial,
                       committeeId: committee.Id,
                       organisationId: committee.Organisation.Id,
                       organisationName: committee.Organisation.Name,
                       name: committee.Name,
                       description: committee.Description));
        }
Exemplo n.º 8
0
        public static Committee FromICommittee(ICommittee committee)
        {
            var newCommittee = new Committee
            {
                Chamber           = committee.Chamber,
                Id                = committee.Id,
                IsSubcommittee    = committee.IsSubcommittee,
                Name              = committee.Name,
                ParentCommitteeId = committee.ParentCommitteeId,
                Phone             = committee.Phone,
                Url               = committee.Url
            };

            return(newCommittee);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Converts instance to Committee domain object.
        /// </summary>
        /// <param name="committee">Committee.</param>
        /// <returns>Committee domain object.</returns>
        public IMeeting ToDomain(
            ICommittee committee)
        {
            CultureInfo cultureInfo     = new CultureInfo("en-GB");
            DateTime    meetingDateTime = DateTime.Parse(this.MeetingDate, cultureInfo);

            string[] timeParts = this.MeetingTime.Split(":");
            meetingDateTime = meetingDateTime.AddHours(int.Parse(timeParts[0], cultureInfo));
            meetingDateTime = meetingDateTime.AddMinutes(int.Parse(timeParts[1], cultureInfo));

            return(new Domain.DomainObjects.Meetings.Meeting(
                       id: this.MeetingId,
                       committee: committee,
                       meetingDateTime: meetingDateTime));
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Create instance of AddNewModel.
        /// </summary>
        /// <param name="committee">Committee.</param>
        /// <returns>AddNewModel.</returns>
        public static AddViewModel Create(
            ICommittee committee)
        {
            if (committee == null)
            {
                throw new ArgumentNullException(nameof(committee));
            }

            return(new AddViewModel(
                       formState: FormState.Initial,
                       committeeId: committee.Id,
                       organisationId: committee.Organisation.Id,
                       organisationName: committee.Organisation.Name,
                       committeeName: committee.Name,
                       meetingDate: string.Empty,
                       meetingTime: string.Empty));
        }
Exemplo n.º 12
0
        /// <inheritdoc/>
        public async Task CreateCommitteeAsync(
            IWho who,
            IAuditHeaderWithAuditDetails auditHeader,
            ICommittee committee)
        {
            this.logger.ReportEntry(
                who,
                new { Committee = committee });

            CommitteeDto dto = CommitteeDto.ToDto(committee);

            this.context.Committees.Add(dto);
            await this.context.SaveChangesAsync().ConfigureAwait(false);

            Audit.AuditCreate(auditHeader, dto, dto.Id);

            this.logger.ReportExit(who);
        }
Exemplo n.º 13
0
        /// <inheritdoc/>
        public async Task UpdateCommitteeAsync(
            IWho who,
            IAuditHeaderWithAuditDetails auditHeader,
            ICommittee committee)
        {
            this.logger.ReportEntry(
                who,
                new { Committee = committee });

            CommitteeDto dto      = CommitteeDto.ToDto(committee);
            CommitteeDto original = await this.context.FindAsync <CommitteeDto>(committee.Id);

            Audit.AuditUpdate(auditHeader, dto.Id, original, dto);

            this.context.Entry(original).CurrentValues.SetValues(dto);
            await this.context.SaveChangesAsync().ConfigureAwait(false);

            this.logger.ReportExit(who);
        }
Exemplo n.º 14
0
        /// <inheritdoc/>
        public async Task <ICommittee> GetCommitteeByIdAsync(
            IWho who,
            Guid committeeId)
        {
            this.logger.ReportEntry(
                who,
                new { CommitteeId = committeeId });

            ICommittee committee = await this.data
                                   .GetCommitteeByIdAsync(
                who : who,
                committeeId : committeeId)
                                   .ConfigureAwait(false);

            this.logger.ReportExit(
                who,
                new { Committee = committee });

            return(committee);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Insert Committee.
        /// </summary>
        /// <param name="who">Who Details.</param>
        /// <param name="model">Add view model.</param>
        /// <returns>Nothing.</returns>
        private async Task InsertRecordAsync(
            IWho who,
            AddViewModel model)
        {
            this.logger.ReportEntry(
                who,
                new { Model = model });

            IOrganisation organisation = await this.service.GetOrganisationByIdAsync(
                who,
                model.OrganisationId)
                                         .ConfigureAwait(false);

            ICommittee committee = model.ToDomain(organisation);

            await this.service
            .CreateCommitteeAsync(who, AuditEvent.CommitteeMaintenance, committee)
            .ConfigureAwait(false);

            this.logger.ReportExit(who);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Insert Meeting.
        /// </summary>
        /// <param name="who">Who Details.</param>
        /// <param name="model">Add view model.</param>
        /// <returns>Nothing.</returns>
        private async Task InsertRecordAsync(
            IWho who,
            AddViewModel model)
        {
            this.logger.ReportEntry(
                who,
                new { Model = model });

            ICommittee committee = await this.service.GetCommitteeByIdAsync(
                who : who,
                committeeId : model.CommitteeId)
                                   .ConfigureAwait(false);

            IMeeting meeting = model.ToDomain(
                committee: committee);

            await this.service
            .CreateMeetingAsync(who, AuditEvent.MeetingMaintenance, meeting)
            .ConfigureAwait(false);

            this.logger.ReportExit(who);
        }
Exemplo n.º 17
0
        /// <inheritdoc/>
        public async Task <ICommittee> GetCommitteeByIdAsync(
            IWho who,
            Guid committeeId)
        {
            this.logger.ReportEntry(
                who,
                new { CommitteeId = committeeId });

            ICommittee committee = (await this.context.Committees
                                    .AsNoTracking()
                                    .TagWith(this.Tag(who))
                                    .Include(c => c.Organisation)
                                    .FirstOrDefaultAsync(c => c.Id == committeeId)
                                    .ConfigureAwait(false))
                                   .ToDomain();

            this.logger.ReportExit(
                who,
                new { Committee = committee });

            return(committee);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Starts the edit.
        /// </summary>
        /// <param name="committeeId">The Committee id.</param>
        /// <param name="ajaxMode">AJAX mode(0=No; 1=Yes).</param>
        /// <returns>View.</returns>
        public async Task <IActionResult> StartEdit(
            Guid committeeId,
            int ajaxMode)
        {
            IWho who = this.Who();

            this.logger.ReportEntry(
                who,
                new
            {
                CommitteeId = committeeId,
                AjaxMode    = ajaxMode
            });

            ICommittee committee = await this.service
                                   .GetCommitteeByIdAsync(who, committeeId)
                                   .ConfigureAwait(false);

            EditViewModel model = EditViewModel.Create(committee);

            switch (ajaxMode)
            {
            case 0:
                ViewResult view = this.View("Edit", model);

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

                return(view);

            default:
                throw new NotImplementedException($"AjaxMode {ajaxMode} not implemented yet.");
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Starts the add.
        /// </summary>
        /// <param name="committeeId">Committee Id.</param>
        /// <returns>Redirect To Action.</returns>
        public async Task <IActionResult> StartAdd(Guid committeeId)
        {
            IWho who = this.Who();

            this.logger.ReportExit(
                who,
                new { CommitteeId = committeeId });

            ICommittee committee = await this.service
                                   .GetCommitteeByIdAsync(who, committeeId)
                                   .ConfigureAwait(false);

            AddViewModel model = AddViewModel.Create(committee);

            RedirectToActionResult redirect = this.RedirectToAction("Add", model);

            this.logger.ReportExitRedirectToAction(
                who,
                redirect.ControllerName,
                redirect.ActionName,
                redirect.RouteValues);

            return(redirect);
        }
    /// <summary>
    ///   <para>Specifies responsible committee.</para>
    /// </summary>
    /// <param name="committee">Instance of committee.</param>
    /// <param name="call">API call instance to use.</param>
    /// <returns>Back reference to the provided <paramref name="call"/> instance.</returns>
    /// <exception cref="ArgumentNullException">If either <paramref name="call"/> or <paramref name="committee"/> is a <c>null</c> reference.</exception>
    public static ILawsLawApiCall ResponsibleCommittee(this ILawsLawApiCall call, ICommittee committee)
    {
      Assertion.NotNull(call);
      Assertion.NotNull(committee);

      return call.ResponsibleCommittee(committee.Id);
    }
    /// <summary>
    ///   <para>Specifies so-executor committee.</para>
    /// </summary>
    /// <param name="call">API call instance to use.</param>
    /// <param name="committee">Instance of committee.</param>
    /// <returns>Back reference to the provided <paramref name="call"/> instance.</returns>
    /// <exception cref="ArgumentNullException">If either <paramref name="call"/> or <paramref name="committee"/> is a <c>null</c> reference.</exception>
    public static ILawsLawApiCall SoExecutorCommittee(this ILawsLawApiCall call, ICommittee committee)
    {
      Assertion.NotNull(call);
      Assertion.NotNull(committee);

      return call.SoExecutorCommittee(committee.Id);
    }