diff --git a/ResumeSharpLib/Models/JsonJob.cs b/ResumeSharpLib/Models/JsonJob.cs new file mode 100644 index 0000000..0031dc5 --- /dev/null +++ b/ResumeSharpLib/Models/JsonJob.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using NodaTime; +using NodaTime.Serialization.JsonNet; + +namespace ResumeSharpLib +{ + + /// + /// The JsonJob object based on https://jsonresume.org/job-description-schema/ + /// + public partial class JsonJob + { + [JsonProperty("title")] + public string Title { get; set; } + + [JsonProperty("company")] + public string Company { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("date")] + public OffsetDateTime Date { get; set; } + + [JsonProperty("description")] + public string Description { get; set; } + + [JsonProperty("location")] + public string Location { get; set; } + + [JsonProperty("remote")] + public string Remote { get; set; } + + [JsonProperty("salary")] + public string Salary { get; set; } + + [JsonProperty("experience")] + public string Experience { get; set; } + + [JsonProperty("responsibilities")] + public List Responsibilities { get; set; } + + [JsonProperty("qualification")] + public List Qualifications { get; set; } + + [JsonProperty("skills")] + public List Skills { get; set; } + + } + + + public partial class JsonJob + { + /// + /// Create a JsonResume object from json string + /// + /// the json string + /// + public static JsonJob FromJson(string json) => JsonConvert.DeserializeObject(json, Converter.Settings); + } +} diff --git a/ResumeSharpLib/Utils/Extensions/JsonJobExtensions.cs b/ResumeSharpLib/Utils/Extensions/JsonJobExtensions.cs new file mode 100644 index 0000000..34d30e8 --- /dev/null +++ b/ResumeSharpLib/Utils/Extensions/JsonJobExtensions.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Text; +using ResumeSharpLib.Utils; + +namespace ResumeSharpLib.Utils.Extensions +{ + public static class JsonJobExtensions + { + /// + /// Adds a skill item to the job object + /// + /// the job object + /// the skill item + /// + public static JsonJob AddSkill(this JsonJob jsonJob, Skill skill) + { + Utilities.AddItemToList(jsonJob.Skills, skill); + return jsonJob; + } + + public static JsonJob AddQualification(this JsonJob jsonJob, string qualification) + { + Utilities.AddItemToList(jsonJob.Qualifications, qualification); + return jsonJob; + } + + public static JsonJob AddResponsibility(this JsonJob jsonJob, string responsibility) + { + Utilities.AddItemToList(jsonJob.Responsibilities, responsibility); + return jsonJob; + } + } +} diff --git a/ResumeSharpTests/UnitTest1.cs b/ResumeSharpTests/UnitTest1.cs index d006666..0a3e5a6 100644 --- a/ResumeSharpTests/UnitTest1.cs +++ b/ResumeSharpTests/UnitTest1.cs @@ -36,6 +36,17 @@ public void AddJsonResumeTest() Assert.AreEqual(jsonResume.Projects.Count, 1); } - + [TestMethod] + public void AddJsonJobTest() + { + JsonJob jsonJob = new JsonJob(); + jsonJob.AddSkill(new Skill()) + .AddQualification("") + .AddResponsibility(""); + + Assert.AreEqual(jsonJob.Skills.Count, 1); + Assert.AreEqual(jsonJob.Qualifications.Count, 1); + Assert.AreEqual(jsonJob.Responsibilities.Count, 1); + } } }