Skip to content

Commit

Permalink
Tar med alle felt i CVen. Modelerer alle datoer med dato. Tar med lit…
Browse files Browse the repository at this point in the history
…t flere felt som var savnet.
  • Loading branch information
haakoaho committed Oct 24, 2023
1 parent b22f05e commit ef8f1a9
Show file tree
Hide file tree
Showing 14 changed files with 780 additions and 108 deletions.
30 changes: 15 additions & 15 deletions src/ApplicationCore/Models/Cv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ public class Cv
public class WorkExperience
{
public required string Id { get; init; }
public required string Title { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
public string? MonthFrom { get; init; }
public string? YearFrom { get; init; }
public string? MonthTo { get; init; }
public string? YearTo { get; init; }

public required string Company {get; init;}
public DateOnly? FromDate { get; init; }
public required DateOnly ToDate { get; init; }
}

public class ProjectExperience
{
public required string Id { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
public string? MonthFrom { get; init; }
public string? YearFrom { get; init; }
public string? MonthTo { get; init; }
public string? YearTo { get; init; }
public DateOnly? FromDate { get; init; }
public required DateOnly ToDate { get; init; }

public required string Customer {get; init;}

public List<ProjectExperienceRole> Roles { get; init; } = new();

Expand All @@ -46,20 +46,20 @@ public class ProjectExperienceRole
public class Presentation
{
public required string Id { get; init; }
public required string Title { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
public string? Month { get; init; }
public string? Year { get; init; }
public DateOnly? Date { get; init; }
}

public class Certification
{
public required string Id { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
public DateTime? ExpiryDate { get; init; }
public string? IssuedMonth { get; init; }
public string? IssuedYear { get; init; }

public required string Issuer {get; init;}
public DateOnly? ExpiryDate { get; init; }
public DateOnly? IssuedDate { get; init; }
}

public class Competency
Expand Down
34 changes: 16 additions & 18 deletions src/Infrastructure/ApiClients/DTOs/CvPartnerDTOs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public class ProjectExperience
public object area_amt { get; set; }
public object area_unit { get; set; }
public DateTime created_at { get; set; }
public Customer customer { get; set; }
public Customer? customer { get; set; }
public CustomerAnonymized customer_anonymized { get; set; }
public CustomerDescription customer_description { get; set; }
public string customer_selected { get; set; }
Expand Down Expand Up @@ -601,8 +601,7 @@ private static List<Presentation> ToPresentations(CVPartnerCvDTO cv)
return cv.presentations.Select(dto => new Presentation
{
Description = dto.long_description.no ?? "",
Year = dto.year,
Month = dto.month,
Date = DateFromNullableStrings(dto.month, dto.year),
Title = dto.description.no ?? "",
Id = dto._id
}).ToList();
Expand All @@ -618,10 +617,9 @@ private static List<Presentation> ToPresentations(CVPartnerCvDTO cv)
return cv.work_experiences.Select(dto => new ApplicationCore.Models.WorkExperience()
{
Description = dto.long_description.no ?? "",
MonthFrom = dto.month_from,
YearFrom = dto.year_from,
MonthTo = dto.month_to,
YearTo = dto.year_to,
FromDate = DateFromNullableStrings(dto.month_from, dto.year_from),
ToDate = DateFromNullableStrings(dto.month_to, dto.year_to)?? DateOnly.FromDateTime(DateTime.Now),
Company = dto.employer.no ?? "",
Title = dto.description.no ?? "",
Id = dto._id
}).ToList();
Expand All @@ -638,10 +636,9 @@ private static List<Presentation> ToPresentations(CVPartnerCvDTO cv)
return cv.project_experiences.Select(dto => new ApplicationCore.Models.ProjectExperience
{
Description = dto.long_description.no ?? "",
MonthFrom = dto.month_from,
YearFrom = dto.year_from,
MonthTo = dto.month_to,
YearTo = dto.year_to,
FromDate = DateFromNullableStrings(dto.month_from, dto.year_from),
ToDate = DateFromNullableStrings(dto.month_to, dto.year_to) ?? DateOnly.FromDateTime(DateTime.Now),
Customer = dto.customer?.no ?? "",
Title = dto.description.no ?? "",
Roles = CreateProjectExperienceRolesFromProject(dto),
Competencies = CreateCompetenciesFromProject(dto),
Expand Down Expand Up @@ -678,7 +675,7 @@ private static List<ProjectExperienceRole> CreateProjectExperienceRolesFromProje
}).ToList();
}

private static List<ApplicationCore.Models.Certification> createCertificationFromCv(CVPartnerCvDTO dto)
private static List<ApplicationCore.Models.Certification> CreateCertificationFromCv(CVPartnerCvDTO dto)
{
if (dto.certifications == null)
{
Expand All @@ -690,13 +687,13 @@ private static List<ProjectExperienceRole> CreateProjectExperienceRolesFromProje
Id = cert._id,
Description = cert.long_description.no ?? "",
Title = cert.name?.no ?? "",
IssuedMonth = cert.month,
IssuedYear = cert.year,
Issuer = cert.organiser.no ?? "",
IssuedDate = DateFromNullableStrings(cert.month, cert.year),
ExpiryDate = DateFromNullableStrings(cert.month_expire, cert.year_expire)
}).ToList();
}

private static DateTime? DateFromNullableStrings(string? month, string? year)
private static DateOnly? DateFromNullableStrings(string? month, string? year)
{
if (string.IsNullOrEmpty(year) || !int.TryParse(year, out int yearValue))
{
Expand All @@ -705,13 +702,14 @@ private static List<ProjectExperienceRole> CreateProjectExperienceRolesFromProje

if (string.IsNullOrEmpty(month) || !int.TryParse(month, out int monthValue))
{
return new DateTime(yearValue, 1, 1);
return new DateOnly(yearValue, 1, 1);
}

return new DateTime(yearValue, monthValue, 1);
return new DateOnly(yearValue, monthValue, 1);
}



public static Cv ToCv(CVPartnerCvDTO cvPartnerCv)
{
return new Cv
Expand All @@ -720,7 +718,7 @@ public static Cv ToCv(CVPartnerCvDTO cvPartnerCv)
Presentations = ToPresentations(cvPartnerCv),
WorkExperiences = ToWorkExperience(cvPartnerCv),
ProjectExperiences = CreateProjectExperienceFromCv(cvPartnerCv),
Certifiactions = createCertificationFromCv(cvPartnerCv)
Certifiactions = CreateCertificationFromCv(cvPartnerCv)
};
}
}
13 changes: 7 additions & 6 deletions src/Infrastructure/Entities/CertificationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ namespace Infrastructure.Entities;

public class CertificationEntity
{
[Key] public string Id { get; set; } = null!;
[Key] public required string Id { get; set; }

public Guid EmployeeId { get; set; }
public EmployeeEntity Employee { get; set; } = null!;
public DateTime? ExpiryDate { get; set; }
public string? IssuedMonth { get; set; }
public string? IssuedYear { get; set; }
public string Title { get; set; } = null!;
public string Description { get; set; } = null!;
public DateOnly? ExpiryDate { get; set; }
public DateOnly? IssuedDate { get; set; }
public required string Title { get; set; }
public required string Description { get; set; }

public required string Issuer {get; set;}
public DateTime LastSynced { get; set; }
}
5 changes: 1 addition & 4 deletions src/Infrastructure/Entities/CompetencyEntity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;

namespace Infrastructure.Entities;

Expand Down
14 changes: 6 additions & 8 deletions src/Infrastructure/Entities/EmployeeEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public static Cv ToCv(this EmployeeEntity employeeEntity)
Description = entity.Description,
Id = entity.Id,
Title = entity.Title,
Month = entity.Month,
Year = entity.Year
Date = entity.Date
}).ToList(),
ProjectExperiences = employeeEntity.ProjectExperiences.Select(
entity => entity.ToProjectExperience()).ToList(),
Expand All @@ -104,18 +103,17 @@ public static Cv ToCv(this EmployeeEntity employeeEntity)
Description = entity.Description,
Id = entity.Id,
Title = entity.Title,
MonthFrom = entity.MonthFrom,
MonthTo = entity.MonthTo,
YearFrom = entity.YearFrom,
YearTo = entity.YearTo
FromDate = entity.FromDate,
ToDate = entity.ToDate,
Company = entity.Company
}).ToList(),
Certifiactions = employeeEntity.Certifications.Select(entity => new Certification
{
Description = entity.Description,
Id = entity.Id,
Title = entity.Title,
IssuedMonth = entity.IssuedMonth,
IssuedYear = entity.IssuedYear,
IssuedDate = entity.IssuedDate,
Issuer = entity.Issuer,
ExpiryDate = entity.ExpiryDate
}).ToList()
};
Expand Down
8 changes: 4 additions & 4 deletions src/Infrastructure/Entities/PresentationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace Infrastructure.Entities;
// [Index(nameof(Email), IsUnique = true)]
public record PresentationEntity
{
[Key] public string Id { get; set; } = null!;
[Key] public required string Id { get; set; }
public Guid EmployeeId { get; set; }
public EmployeeEntity Employee { get; set; } = null!;
public string? Month { get; set; }
public string? Year { get; set; }

public DateOnly? Date {get; set;}
public int Order { get; set; }
public string Title { get; set; } = null!;
public string Description { get; set; } = null!;
public DateTime LastSynced { get; set; }
public required DateTime LastSynced { get; set; }
public Uri? Url { get; set; }
}
27 changes: 12 additions & 15 deletions src/Infrastructure/Entities/ProjectExperienceEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@

using ApplicationCore.Models;

using Microsoft.EntityFrameworkCore;

namespace Infrastructure.Entities;

public record ProjectExperienceEntity
{
[Key] public string Id { get; set; } = null!;
[Key] public required string Id { get; set; }

public Guid EmployeeId { get; set; }
public EmployeeEntity Employee { get; set; } = null!;
public string? MonthFrom { get; set; }
public string? YearFrom { get; set; }
public string? MonthTo { get; set; }
public string? YearTo { get; set; }

public DateOnly? FromDate {get; set;}
public DateOnly ToDate {get; set;}
public int Order { get; set; }
public string Title { get; set; } = null!;
public string Description { get; set; } = null!;
public DateTime LastSynced { get; set; }
public Uri? Url { get; set; }
public required string Title { get; set; }
public required string Description { get; set; }

public required string Customer {get; set;}
public required DateTime LastSynced { get; set; }
public List<ProjectExperienceRoleEntity> ProjectExperienceRoles { get; set; } = new();

public List<CompetencyEntity> Competencies { get; set; } = new();
Expand All @@ -35,10 +33,9 @@ public static ProjectExperience ToProjectExperience(this ProjectExperienceEntity
Id = pe.Id,
Title = pe.Title,
Description = pe.Description,
MonthFrom = pe.MonthFrom,
MonthTo = pe.MonthTo,
YearFrom = pe.YearFrom,
YearTo = pe.YearTo,
ToDate = pe.ToDate,
FromDate = pe.FromDate,
Customer = pe.Customer,
Roles = pe.ProjectExperienceRoles.Select(pEntity => new ProjectExperienceRole
{
Description = pEntity.Description, Id = pEntity.Id, Title = pEntity.Title
Expand Down
8 changes: 4 additions & 4 deletions src/Infrastructure/Entities/ProjectExperienceRoleEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ namespace Infrastructure.Entities;
public record ProjectExperienceRoleEntity
{
[Key] public required string Id { get; set; }
public string Title { get; set; }
public required string Title { get; set; }

public string Description { get; set; }
public required string Description { get; set; }

public string ProjectExperienceId { get; set; }
public string ProjectExperienceId { get; set; } = null!;

public ProjectExperienceEntity ProjectExperience { get; set; } = null!;

public DateTime LastSynced { get; set; }
public required DateTime LastSynced { get; set; }
}

public static class ProjectExperienceRoleEntityExtension
Expand Down
14 changes: 8 additions & 6 deletions src/Infrastructure/Entities/WorkExperienceEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ public record WorkExperienceEntity

public required Guid EmployeeId { get; set; }
public EmployeeEntity Employee { get; set; } = null!;
public string? MonthFrom { get; set; }
public string? YearFrom { get; set; }
public string? MonthTo { get; set; }
public string? YearTo { get; set; }

public DateOnly? FromDate {get; set;}

public DateOnly ToDate {get; set;}
public int Order { get; set; }
public string Title { get; set; } = null!;
public string Description { get; set; } = null!;
public required string Title { get; set; }
public required string Description { get; set; }

public required string Company {get; set;}
public DateTime LastSynced { get; set; }
public Uri? Url { get; set; }
}
Loading

0 comments on commit ef8f1a9

Please sign in to comment.