コード例 #1
0
        internal async Task <(int, AcceptPunchOutDto)> CreateValidAcceptPunchOutDtoAsync(List <CreateParticipantsDto> participants)
        {
            var(invitationToCompleteAndAcceptId, completePunchOutDto) = await CreateValidCompletePunchOutDtoAsync(participants);

            await InvitationsControllerTestsHelper.CompletePunchOutAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToCompleteAndAcceptId,
                completePunchOutDto);

            var completedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToCompleteAndAcceptId);

            var accepterParticipant = completedInvitation.Participants
                                      .Single(p => p.Organization == Organization.ConstructionCompany);

            var acceptPunchOutDto = new AcceptPunchOutDto
            {
                InvitationRowVersion  = completedInvitation.RowVersion,
                ParticipantRowVersion = accepterParticipant.RowVersion,
                Participants          = new List <ParticipantToUpdateNoteDto>
                {
                    new ParticipantToUpdateNoteDto
                    {
                        Id         = accepterParticipant.Id,
                        Note       = $"Some note about the punch round or attendee {Guid.NewGuid():B}",
                        RowVersion = accepterParticipant.RowVersion
                    }
                }
            };

            return(invitationToCompleteAndAcceptId, acceptPunchOutDto);
        }
        public static async Task <string> AcceptPunchOutAsync(
            UserType userType,
            string plant,
            int id,
            AcceptPunchOutDto dto,
            HttpStatusCode expectedStatusCode  = HttpStatusCode.OK,
            string expectedMessageOnBadRequest = null)
        {
            var bodyPayload = new
            {
                dto.ParticipantRowVersion,
                dto.InvitationRowVersion,
                dto.Participants
            };

            var serializePayload = JsonConvert.SerializeObject(bodyPayload);
            var content          = new StringContent(serializePayload, Encoding.UTF8, "application/json");
            var response         = await TestFactory.Instance.GetHttpClient(userType, plant)
                                   .PutAsync($"{Route}/{id}/Accept", content);

            await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest);

            if (expectedStatusCode != HttpStatusCode.OK)
            {
                return(null);
            }

            return(await response.Content.ReadAsStringAsync());
        }