public static async Task <string> CompletePunchOutAsync(
            UserType userType,
            string plant,
            int id,
            CompletePunchOutDto 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}/Complete", content);

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

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

            return(await response.Content.ReadAsStringAsync());
        }
Beispiel #2
0
        internal async Task <(int, CompletePunchOutDto)> CreateValidCompletePunchOutDtoAsync(List <CreateParticipantsDto> participants)
        {
            var id = await InvitationsControllerTestsHelper.CreateInvitationAsync(
                UserType.Planner,
                TestFactory.PlantWithAccess,
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString(),
                InvitationLocation,
                DisciplineType.DP,
                _invitationStartTime,
                _invitationEndTime,
                participants,
                _mcPkgScope,
                null);

            var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                id);

            var completerParticipant = invitation.Participants
                                       .Single(p => p.Organization == Organization.Contractor);

            var completePunchOutDto = new CompletePunchOutDto
            {
                InvitationRowVersion  = invitation.RowVersion,
                ParticipantRowVersion = completerParticipant.RowVersion,
                Participants          = new List <ParticipantToChangeDto>
                {
                    new ParticipantToChangeDto
                    {
                        Id         = completerParticipant.Id,
                        Note       = $"Some note about the punch round or attendee {Guid.NewGuid():B}",
                        RowVersion = completerParticipant.RowVersion,
                        Attended   = true
                    }
                }
            };

            return(id, completePunchOutDto);
        }