feature steps class Given set job offer to the sent status public void

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
feature steps class:
[Given(@"I set job offer to the sent status")]
public void GivenISetJobOfferToTheSentStatus()
{
string listName = "Job Offers";
string jsonText = @"{'__metadata': { 'type': 'SP.Data.JobOffersItem' },'Status':'Sent'}";
List<JToken> jobOffersDocumentlist = WebServiceSupport.GetJsonItemsFromList(listName).ToList();
string itemId = jobOffersDocumentlist.Where(x => x["ApplicantFullName"].ToString().Equals(CandidateQA1Name) && x["JobRole"].ToString().Equals(JobOpeningName)).FirstOrDefault()["Id"].ToString();
WebServiceSupport.UpdateItemInList(listName, itemId, jsonText);
}
WebServiceSupprortClass:
internal static void UpdateItemInList(string listName, string itemId, string jsonText)
{
string listEndPoint = $"_api/lists/getbytitle('{listName}')/items({itemId})";
RestClient client = CreateRestClient();
RestRequest request = new RestRequest(listEndPoint, Method.POST);
request.SetMergeMethod(jsonText);
IRestResponse response = client.Execute(request);
}
WebServiceExtentionsClass:
public static void SetMergeMethod(this RestRequest restRequest, string jsonText)
{
restRequest.AddJsonBody(jsonText);
restRequest.SetFormDigestValue();
restRequest.AddHeader("IF-MATCH", "*");
restRequest.AddHeader("X-HTTP-Method", "MERGE");
restRequest.SetJsonFormatForResponce();
restRequest.AddHeader("content-type", "application/json;odata=verbose");
restRequest.AddHeader("content-length", jsonText.Length.ToString());
}