Skip to content

Commit 2ae5605

Browse files
committed
Merge branch 'v2.1.0'
2 parents 36f521d + be88a85 commit 2ae5605

File tree

3 files changed

+111
-1
lines changed

3 files changed

+111
-1
lines changed

ResumeSharpLib/Models/JsonJob.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Newtonsoft.Json;
5+
using Newtonsoft.Json.Converters;
6+
using NodaTime;
7+
using NodaTime.Serialization.JsonNet;
8+
9+
namespace ResumeSharpLib
10+
{
11+
12+
/// <summary>
13+
/// The JsonJob object based on https://jsonresume.org/job-description-schema/
14+
/// </summary>
15+
public partial class JsonJob
16+
{
17+
[JsonProperty("title")]
18+
public string Title { get; set; }
19+
20+
[JsonProperty("company")]
21+
public string Company { get; set; }
22+
23+
[JsonProperty("type")]
24+
public string Type { get; set; }
25+
26+
[JsonProperty("date")]
27+
public OffsetDateTime Date { get; set; }
28+
29+
[JsonProperty("description")]
30+
public string Description { get; set; }
31+
32+
[JsonProperty("location")]
33+
public string Location { get; set; }
34+
35+
[JsonProperty("remote")]
36+
public string Remote { get; set; }
37+
38+
[JsonProperty("salary")]
39+
public string Salary { get; set; }
40+
41+
[JsonProperty("experience")]
42+
public string Experience { get; set; }
43+
44+
[JsonProperty("responsibilities")]
45+
public List<string> Responsibilities { get; set; }
46+
47+
[JsonProperty("qualification")]
48+
public List<string> Qualifications { get; set; }
49+
50+
[JsonProperty("skills")]
51+
public List<Skill> Skills { get; set; }
52+
53+
}
54+
55+
56+
public partial class JsonJob
57+
{
58+
/// <summary>
59+
/// Create a JsonResume object from json string
60+
/// </summary>
61+
/// <param name="json">the json string</param>
62+
/// <returns></returns>
63+
public static JsonJob FromJson(string json) => JsonConvert.DeserializeObject<JsonJob>(json, Converter.Settings);
64+
}
65+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using ResumeSharpLib.Utils;
5+
6+
namespace ResumeSharpLib.Utils.Extensions
7+
{
8+
public static class JsonJobExtensions
9+
{
10+
/// <summary>
11+
/// Adds a skill item to the job object
12+
/// </summary>
13+
/// <param name="jsonJob">the job object</param>
14+
/// <param name="skill">the skill item</param>
15+
/// <returns></returns>
16+
public static JsonJob AddSkill(this JsonJob jsonJob, Skill skill)
17+
{
18+
Utilities.AddItemToList(jsonJob.Skills, skill);
19+
return jsonJob;
20+
}
21+
22+
public static JsonJob AddQualification(this JsonJob jsonJob, string qualification)
23+
{
24+
Utilities.AddItemToList(jsonJob.Qualifications, qualification);
25+
return jsonJob;
26+
}
27+
28+
public static JsonJob AddResponsibility(this JsonJob jsonJob, string responsibility)
29+
{
30+
Utilities.AddItemToList(jsonJob.Responsibilities, responsibility);
31+
return jsonJob;
32+
}
33+
}
34+
}

ResumeSharpTests/UnitTest1.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ public void AddJsonResumeTest()
3636
Assert.AreEqual(jsonResume.Projects.Count, 1);
3737
}
3838

39-
39+
[TestMethod]
40+
public void AddJsonJobTest()
41+
{
42+
JsonJob jsonJob = new JsonJob();
43+
jsonJob.AddSkill(new Skill())
44+
.AddQualification("")
45+
.AddResponsibility("");
46+
47+
Assert.AreEqual(jsonJob.Skills.Count, 1);
48+
Assert.AreEqual(jsonJob.Qualifications.Count, 1);
49+
Assert.AreEqual(jsonJob.Responsibilities.Count, 1);
50+
}
4051
}
4152
}

0 commit comments

Comments
 (0)