public static async Task <string> UpdateSavedFilterAsync( UserType userType, string plant, int savedFilterId, string newTitle, string newCriteria, bool defaultFilter, string rowVersion, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new UpdateSavedFilterDto() { Title = newTitle, Criteria = newCriteria, DefaultFilter = defaultFilter, RowVersion = rowVersion }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PutAsync($"{Route}/SavedFilters/{savedFilterId}", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(""); } return(await response.Content.ReadAsStringAsync()); }
public static async Task <string> UpdateTagStepAndRequirementsAsync( UserType userType, string plant, int tagId, string description, int stepId, string rowVersion, List <TagRequirementDto> newRequirements = null, List <UpdatedTagRequirementDto> updatedRequirements = null, List <DeletedTagRequirementDto> deletedRequirements = null, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { description, stepId, rowVersion, newRequirements, updatedRequirements, deletedRequirements }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PutAsync($"{_route}/{tagId}/UpdateTagStepAndRequirements", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(null); } return(await response.Content.ReadAsStringAsync()); }
public static async Task RecordCbValueAsync( UserType userType, string plant, int tagId, int requirementId, int fieldId, string comment, bool isChecked, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { comment, checkBoxValues = new [] { new { fieldId, isChecked } } }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync($"{_route}/{tagId}/Requirements/{requirementId}/RecordValues", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); }
public static async Task <XLFile> ExportInvitationsAsync( UserType userType, string plant, string projectName, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var parameters = new ParameterCollection { { "ProjectName", projectName } }; var url = $"{Route}/ExportInvitationsToExcel{parameters}"; var response = await TestFactory.Instance.GetHttpClient(userType, plant).GetAsync(url); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var stream = await response.Content.ReadAsStreamAsync(); var result = new XLFile { Workbook = new XLWorkbook(stream), ContentType = response.Content.Headers.ContentType?.MediaType }; return(result); }
public static async Task <string> UpdateModeAsync( UserType userType, string plant, int id, string title, string rowVersion, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { title, forSupplier = false, rowVersion }; 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}", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(null); } return(await response.Content.ReadAsStringAsync()); }
public static async Task <List <StepIdAndRowVersion> > SwapStepsAsync( UserType userType, string plant, int journeyId, StepIdAndRowVersion stepA, StepIdAndRowVersion stepB, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { stepA, stepB }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PutAsync($"{_route}/{journeyId}/Steps/SwapSteps", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(null); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <StepIdAndRowVersion> >(jsonString)); }
public static async Task <List <InvitationForMainDto> > GetInvitationsByCommPkgNoAsync( UserType userType, string plant, string commPkgNo, string projectName, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var parameters = new ParameterCollection { { "projectName", projectName } }; var url = $"{Route}/ByCommPkgNo/{commPkgNo}{parameters}"; var response = await TestFactory.Instance.GetHttpClient(userType, plant).GetAsync(url); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var content = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <InvitationForMainDto> >(content)); }
public static async Task <int> CreateRequirementDefinitionAsync( UserType userType, string plant, int reqTypeId, string title, List <FieldDto> fields = null, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { title, sortKey = 10, defaultIntervalWeeks = 4, fields }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync($"{_route}/{reqTypeId}/RequirementDefinitions", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(-1); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <int>(jsonString)); }
public static async Task <TagResultDto> GetAllTagsAsync( UserType userType, string plant, string projectName, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var parameters = new ParameterCollection { { "ProjectName", projectName } }; var url = $"{_route}{parameters}"; var response = await TestFactory.Instance.GetHttpClient(userType, plant).GetAsync(url); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <TagResultDto>(jsonString)); }
public static async Task <string> UnAcceptPunchOutAsync( UserType userType, string plant, int id, UnAcceptPunchOutDto dto, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { dto.InvitationRowVersion, dto.ParticipantRowVersion }; 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}/UnAccept", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } return(await response.Content.ReadAsStringAsync()); }
private static async Task <string> VoidUnvoidRequirementDefinitionAsync( HttpClient client, int reqTypeId, int reqDefId, string rowVersion, string action, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { rowVersion }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await client.PutAsync($"{_route}/{reqTypeId}/RequirementDefinitions/{reqDefId}/{action}", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(null); } return(await response.Content.ReadAsStringAsync()); }
public static async Task <List <CommPkgWithMdpIposDto> > GetLatestMdpIpoOnCommPkgsAsync( UserType userType, string plant, IList <string> commPkgNos, string projectName, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var parameters = new ParameterCollection { { "projectName", projectName } }; foreach (var commPkgNo in commPkgNos) { parameters.Add("commPkgNos", commPkgNo); } var url = $"{Route}/ByCommPkgNos{parameters}"; var response = await TestFactory.Instance.GetHttpClient(userType, plant).GetAsync(url); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var content = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <CommPkgWithMdpIposDto> >(content)); }
public static async Task <int> CreateSavedFilterAsync( UserType userType, string plant, string title, string criteria, bool defaultFilter, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { projectName = KnownTestData.ProjectName, title, criteria, defaultFilter }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync($"{Route}/SavedFilter", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(-1); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <int>(jsonString)); }
public static async Task <ProCoSysCommPkgSearchDto> GetCommPkgsInProjectV2Async( UserType userType, string plant, string projectName, string startsWithCommPkgNo, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var parameters = new ParameterCollection { { "projectName", projectName }, { "startsWithCommPkgNo", startsWithCommPkgNo } }; var url = $"{Route}/CommPkgsV2{parameters}"; var response = await TestFactory.Instance.GetHttpClient(userType, plant).GetAsync(url); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var content = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ProCoSysCommPkgSearchDto>(content)); }
public static async Task <IList <IdAndRowVersion> > RescheduleAsync( UserType userType, string plant, IEnumerable <IdAndRowVersion> tagDtos, int weeks, RescheduledDirection direction, string comment, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { Tags = tagDtos, weeks, direction, comment }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PutAsync($"{_route}/Reschedule", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(null); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <IdAndRowVersion> >(jsonString)); }
public static async Task <int> CreateModeAsync( UserType userType, string plant, string title, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { title, forSupplier = false }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync(_route, content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(-1); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <int>(jsonString)); }
public static async Task <string> UpdateRequirementDefinitionAsync( UserType userType, string plant, int requirementTypeId, int requirementDefinitionId, string title, int defaultIntervalWeeks, string rowVersion, List <FieldDetailsDto> updatedFields = null, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { title, defaultIntervalWeeks, sortKey = 10, rowVersion, updatedFields }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PutAsync($"{_route}/{requirementTypeId}/RequirementDefinitions/{requirementDefinitionId}", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(null); } return(await response.Content.ReadAsStringAsync()); }
public static async Task PreserveRequirementAsync( UserType userType, string plant, int tagId, int requirementId, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync($"{_route}/{tagId}/Requirements/{requirementId}/Preserve", null !); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); }
public static async Task UploadAttachmentAsync( UserType userType, string plant, int id, TestFile file, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var httpContent = file.CreateHttpContent(); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync($"{Route}/{id}/Attachments", httpContent); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); }
public static async Task UploadFieldValueAttachmentAsync( UserType userType, string plant, int tagId, int requirementId, int fieldId, TestFile file, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var httpContent = file.CreateHttpContent(); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync($"{_route}/{tagId}/Requirements/{requirementId}/Attachment/{fieldId}", httpContent); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); }
public static async Task StartPreservationAsync( UserType userType, string plant, IEnumerable <int> tagIds, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = tagIds; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PutAsync($"{_route}/StartPreservation", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); }
public static async Task ChangeAttendedStatusAndNotesOnParticipantsAsync( UserType userType, string plant, int id, ParticipantToChangeDto[] dtos, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var serializePayload = JsonConvert.SerializeObject(dtos); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant) .PutAsync($"{Route}/{id}/AttendedStatusAndNotes", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); }
public static async Task <int> CreateAreaTagAsync( UserType userType, string plant, string projectName, AreaTagType areaTagType, string disciplineCode, string areaCode, string tagNoSuffix, List <TagRequirementDto> requirements, int stepId, string description, string remark, string storageArea, string purchaseOrderCalloffCode, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { projectName, areaTagType, disciplineCode, areaCode, tagNoSuffix, requirements, stepId, description, remark, storageArea, purchaseOrderCalloffCode }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync($"{_route}/Area", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(-1); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <int>(jsonString)); }
public static async Task <List <TagDto> > GetTagsAsync( UserType userType, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var response = await TestFactory.Instance.GetHttpClient(userType, null).GetAsync($"{_route}/Tags"); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <TagDto> >(jsonString)); }
public static async Task <int> CreateInvitationAsync( UserType userType, string plant, string title, string description, string location, DisciplineType type, System.DateTime startTime, System.DateTime endTime, IList <CreateParticipantsDto> participants, IEnumerable <string> mcPkgScope, IEnumerable <string> commPkgScope, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var bodyPayload = new { projectName = KnownTestData.ProjectName, title, description, location, type, startTime, endTime, participants, mcPkgScope, commPkgScope }; var serializePayload = JsonConvert.SerializeObject(bodyPayload); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant).PostAsync(Route, content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(-1); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <int>(jsonString)); }
public static async Task <List <ModeDto> > GetAllModesAsync( UserType userType, string plant, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var response = await TestFactory.Instance.GetHttpClient(userType, plant).GetAsync(_route); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var content = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <ModeDto> >(content)); }
public static async Task <ActionDetailsDto> GetActionAsync( UserType userType, string plant, int tagId, int actionId, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var response = await TestFactory.Instance.GetHttpClient(userType, plant).GetAsync($"{_route}/{tagId}/Actions/{actionId}"); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ActionDetailsDto>(jsonString)); }
public static async Task <List <ProCoSysFunctionalRoleDto> > GetFunctionalRolesForIpoAsync( UserType userType, string plant, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var response = await TestFactory.Instance.GetHttpClient(userType, plant) .GetAsync($"{Route}/FunctionalRoles/ByClassification/IPO"); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var content = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <ProCoSysFunctionalRoleDto> >(content)); }
public static async Task <List <SavedFilterDto> > GetSavedFiltersInProjectAsync( UserType userType, string plant, string projectName, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var project = projectName ?? KnownTestData.ProjectName; var response = await TestFactory.Instance.GetHttpClient(userType, plant).GetAsync($"{Route}/SavedFilters?projectName={project}"); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (response.StatusCode != HttpStatusCode.OK) { return(new List <SavedFilterDto>()); } var jsonString = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <List <SavedFilterDto> >(jsonString)); }
public static async Task <AttachmentDto> GetAttachmentAsync( UserType userType, string plant, int id, int attachmentId, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var response = await TestFactory.Instance.GetHttpClient(userType, plant).GetAsync($"{Route}/{id}/Attachments/{attachmentId}"); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); if (expectedStatusCode != HttpStatusCode.OK) { return(null); } var content = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <AttachmentDto>(content)); }