diff --git a/src/ApplicationCore/Models/Cv.cs b/src/ApplicationCore/Models/Cv.cs index ebdb21a..ded2d5c 100644 --- a/src/ApplicationCore/Models/Cv.cs +++ b/src/ApplicationCore/Models/Cv.cs @@ -13,12 +13,12 @@ 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 @@ -26,10 +26,10 @@ 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 Roles { get; init; } = new(); @@ -46,10 +46,9 @@ 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 @@ -57,9 +56,10 @@ 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 diff --git a/src/Infrastructure/ApiClients/DTOs/CvPartnerDTOs.cs b/src/Infrastructure/ApiClients/DTOs/CvPartnerDTOs.cs index 37729f7..99f62ae 100644 --- a/src/Infrastructure/ApiClients/DTOs/CvPartnerDTOs.cs +++ b/src/Infrastructure/ApiClients/DTOs/CvPartnerDTOs.cs @@ -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; } @@ -601,8 +601,7 @@ private static List 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(); @@ -618,10 +617,9 @@ private static List 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(); @@ -638,10 +636,9 @@ private static List 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), @@ -678,7 +675,7 @@ private static List CreateProjectExperienceRolesFromProje }).ToList(); } - private static List createCertificationFromCv(CVPartnerCvDTO dto) + private static List CreateCertificationFromCv(CVPartnerCvDTO dto) { if (dto.certifications == null) { @@ -690,13 +687,13 @@ private static List 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)) { @@ -705,13 +702,14 @@ private static List 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 @@ -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) }; } } \ No newline at end of file diff --git a/src/Infrastructure/Entities/CertificationEntity.cs b/src/Infrastructure/Entities/CertificationEntity.cs index 8f431d4..6be4d8d 100644 --- a/src/Infrastructure/Entities/CertificationEntity.cs +++ b/src/Infrastructure/Entities/CertificationEntity.cs @@ -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; } } \ No newline at end of file diff --git a/src/Infrastructure/Entities/CompetencyEntity.cs b/src/Infrastructure/Entities/CompetencyEntity.cs index 47a3d70..4951547 100644 --- a/src/Infrastructure/Entities/CompetencyEntity.cs +++ b/src/Infrastructure/Entities/CompetencyEntity.cs @@ -1,7 +1,4 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; - -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; namespace Infrastructure.Entities; diff --git a/src/Infrastructure/Entities/EmployeeEntity.cs b/src/Infrastructure/Entities/EmployeeEntity.cs index 3b78cf1..38bdf5b 100644 --- a/src/Infrastructure/Entities/EmployeeEntity.cs +++ b/src/Infrastructure/Entities/EmployeeEntity.cs @@ -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(), @@ -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() }; diff --git a/src/Infrastructure/Entities/PresentationEntity.cs b/src/Infrastructure/Entities/PresentationEntity.cs index bb88c23..34e367b 100644 --- a/src/Infrastructure/Entities/PresentationEntity.cs +++ b/src/Infrastructure/Entities/PresentationEntity.cs @@ -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; } } \ No newline at end of file diff --git a/src/Infrastructure/Entities/ProjectExperienceEntity.cs b/src/Infrastructure/Entities/ProjectExperienceEntity.cs index 4682f09..766d985 100644 --- a/src/Infrastructure/Entities/ProjectExperienceEntity.cs +++ b/src/Infrastructure/Entities/ProjectExperienceEntity.cs @@ -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 ProjectExperienceRoles { get; set; } = new(); public List Competencies { get; set; } = new(); @@ -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 diff --git a/src/Infrastructure/Entities/ProjectExperienceRoleEntity.cs b/src/Infrastructure/Entities/ProjectExperienceRoleEntity.cs index 53fce69..dff04da 100644 --- a/src/Infrastructure/Entities/ProjectExperienceRoleEntity.cs +++ b/src/Infrastructure/Entities/ProjectExperienceRoleEntity.cs @@ -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 diff --git a/src/Infrastructure/Entities/WorkExperienceEntity.cs b/src/Infrastructure/Entities/WorkExperienceEntity.cs index e67af75..8ccee03 100644 --- a/src/Infrastructure/Entities/WorkExperienceEntity.cs +++ b/src/Infrastructure/Entities/WorkExperienceEntity.cs @@ -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; } } \ No newline at end of file diff --git a/src/Infrastructure/Migrations/20231024103415_AlterCvCustomerNameAndDates.Designer.cs b/src/Infrastructure/Migrations/20231024103415_AlterCvCustomerNameAndDates.Designer.cs new file mode 100644 index 0000000..2fc474b --- /dev/null +++ b/src/Infrastructure/Migrations/20231024103415_AlterCvCustomerNameAndDates.Designer.cs @@ -0,0 +1,456 @@ +// +using System; +using Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Employees.Migrations +{ + [DbContext(typeof(EmployeeContext))] + [Migration("20231024103415_AlterCvCustomerNameAndDates")] + partial class AlterCvCustomerNameAndDates + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Infrastructure.Entities.CertificationEntity", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("ExpiryDate") + .HasColumnType("date"); + + b.Property("IssueDate") + .HasColumnType("date"); + + b.Property("Issuer") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastSynced") + .HasColumnType("datetime2"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.ToTable("Certifications"); + }); + + modelBuilder.Entity("Infrastructure.Entities.CompetencyEntity", b => + { + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("ProjectExperienceId") + .HasColumnType("nvarchar(450)"); + + b.Property("LastSynced") + .HasColumnType("datetime2"); + + b.HasKey("Name", "ProjectExperienceId"); + + b.HasIndex("ProjectExperienceId"); + + b.ToTable("Competencies"); + }); + + modelBuilder.Entity("Infrastructure.Entities.EmergencyContactEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Phone") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Relation") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId") + .IsUnique(); + + b.ToTable("EmergencyContacts"); + }); + + modelBuilder.Entity("Infrastructure.Entities.EmployeeAllergiesAndDietaryPreferencesEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Comment") + .HasColumnType("nvarchar(max)"); + + b.Property("DefaultAllergies") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DietaryPreferences") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("OtherAllergies") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId") + .IsUnique(); + + b.ToTable("EmployeeAllergiesAndDietaryPreferences"); + }); + + modelBuilder.Entity("Infrastructure.Entities.EmployeeEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AccountNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Address") + .HasColumnType("nvarchar(max)"); + + b.Property("City") + .HasColumnType("nvarchar(max)"); + + b.Property("CountryCode") + .IsRequired() + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("ImageUrl") + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OfficeName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("Telephone") + .HasColumnType("nvarchar(max)"); + + b.Property("ZipCode") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Email") + .IsUnique(); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("Infrastructure.Entities.PresentationEntity", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("LastSynced") + .HasColumnType("datetime2"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.ToTable("Presentations"); + }); + + modelBuilder.Entity("Infrastructure.Entities.ProjectExperienceEntity", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("Customer") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("FromDate") + .HasColumnType("date"); + + b.Property("LastSynced") + .HasColumnType("datetime2"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ToDate") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.ToTable("ProjectExperiences"); + }); + + modelBuilder.Entity("Infrastructure.Entities.ProjectExperienceRoleEntity", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastSynced") + .HasColumnType("datetime2"); + + b.Property("ProjectExperienceId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ProjectExperienceId"); + + b.ToTable("ProjectExperienceRoles"); + }); + + modelBuilder.Entity("Infrastructure.Entities.WorkExperienceEntity", b => + { + b.Property("Id") + .HasColumnType("nvarchar(450)"); + + b.Property("Company") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("FromDate") + .HasColumnType("date"); + + b.Property("LastSynced") + .HasColumnType("datetime2"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ToDate") + .HasColumnType("date"); + + b.Property("Url") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.ToTable("WorkExperiences"); + }); + + modelBuilder.Entity("Infrastructure.Entities.CertificationEntity", b => + { + b.HasOne("Infrastructure.Entities.EmployeeEntity", "Employee") + .WithMany("Certifications") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("Infrastructure.Entities.CompetencyEntity", b => + { + b.HasOne("Infrastructure.Entities.ProjectExperienceEntity", "ProjectExperience") + .WithMany("Competencies") + .HasForeignKey("ProjectExperienceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ProjectExperience"); + }); + + modelBuilder.Entity("Infrastructure.Entities.EmergencyContactEntity", b => + { + b.HasOne("Infrastructure.Entities.EmployeeEntity", "Employee") + .WithOne("EmergencyContact") + .HasForeignKey("Infrastructure.Entities.EmergencyContactEntity", "EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("Infrastructure.Entities.EmployeeAllergiesAndDietaryPreferencesEntity", b => + { + b.HasOne("Infrastructure.Entities.EmployeeEntity", "Employee") + .WithOne("AllergiesAndDietaryPreferences") + .HasForeignKey("Infrastructure.Entities.EmployeeAllergiesAndDietaryPreferencesEntity", "EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("Infrastructure.Entities.PresentationEntity", b => + { + b.HasOne("Infrastructure.Entities.EmployeeEntity", "Employee") + .WithMany("Presentations") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("Infrastructure.Entities.ProjectExperienceEntity", b => + { + b.HasOne("Infrastructure.Entities.EmployeeEntity", "Employee") + .WithMany("ProjectExperiences") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("Infrastructure.Entities.ProjectExperienceRoleEntity", b => + { + b.HasOne("Infrastructure.Entities.ProjectExperienceEntity", "ProjectExperience") + .WithMany("ProjectExperienceRoles") + .HasForeignKey("ProjectExperienceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ProjectExperience"); + }); + + modelBuilder.Entity("Infrastructure.Entities.WorkExperienceEntity", b => + { + b.HasOne("Infrastructure.Entities.EmployeeEntity", "Employee") + .WithMany("WorkExperiences") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("Infrastructure.Entities.EmployeeEntity", b => + { + b.Navigation("AllergiesAndDietaryPreferences"); + + b.Navigation("Certifications"); + + b.Navigation("EmergencyContact"); + + b.Navigation("Presentations"); + + b.Navigation("ProjectExperiences"); + + b.Navigation("WorkExperiences"); + }); + + modelBuilder.Entity("Infrastructure.Entities.ProjectExperienceEntity", b => + { + b.Navigation("Competencies"); + + b.Navigation("ProjectExperienceRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Infrastructure/Migrations/20231024103415_AlterCvCustomerNameAndDates.cs b/src/Infrastructure/Migrations/20231024103415_AlterCvCustomerNameAndDates.cs new file mode 100644 index 0000000..1fead31 --- /dev/null +++ b/src/Infrastructure/Migrations/20231024103415_AlterCvCustomerNameAndDates.cs @@ -0,0 +1,227 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Employees.Migrations +{ + /// + public partial class AlterCvCustomerNameAndDates : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "MonthFrom", + table: "ProjectExperiences"); + + migrationBuilder.DropColumn( + name: "YearFrom", + table: "ProjectExperiences"); + + migrationBuilder.DropColumn( + name: "MonthTo", + table: "ProjectExperiences"); + + migrationBuilder.DropColumn( + name: "YearTo", + table: "ProjectExperiences"); + + migrationBuilder.AddColumn( + name: "Customer", + table: "ProjectExperiences", + type: "varchar(255)", + nullable: true); + + migrationBuilder.AddColumn( + name: "FromDate", + table: "ProjectExperiences", + type: "date", + nullable: true); + + migrationBuilder.AddColumn( + name: "ToDate", + table: "ProjectExperiences", + type: "date", + nullable: true); + migrationBuilder.DropColumn( + name: "YearFrom", + table: "WorkExperiences"); + + migrationBuilder.DropColumn( + name: "MonthTo", + table: "WorkExperiences"); + + migrationBuilder.DropColumn( + name: "YearTo", + table: "WorkExperiences"); + + migrationBuilder.AddColumn( + name: "Company", + table: "WorkExperiences", + type: "varchar(255)", + nullable: true); + + migrationBuilder.AddColumn( + name: "FromDate", + table: "WorkExperiences", + type: "date", + nullable: true); + + migrationBuilder.AddColumn( + name: "ToDate", + table: "WorkExperiences", + type: "date", + nullable: true); + migrationBuilder.DropColumn( +name: "Month", +table: "Presentations"); + + migrationBuilder.DropColumn( + name: "Year", + table: "Presentations"); + + migrationBuilder.AddColumn( + name: "Date", + table: "Presentations", + type: "date", + nullable: true); + migrationBuilder.DropColumn( + name: "IssuedYear", + table: "Certifications"); + + migrationBuilder.AddColumn( + name: "IssuedDate", + table: "Certifications", + type: "date", + nullable: true); + + migrationBuilder.AddColumn( + name: "Issuer", + table: "Certifications", + type: "varchar(255)", + nullable: true); + + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Customer", + table: "ProjectExperiences"); + + migrationBuilder.DropColumn( + name: "FromDate", + table: "ProjectExperiences"); + + migrationBuilder.DropColumn( + name: "ToDate", + table: "ProjectExperiences"); + + migrationBuilder.AddColumn( + name: "MonthFrom", + table: "ProjectExperiences", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "YearFrom", + table: "ProjectExperiences", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MonthTo", + table: "ProjectExperiences", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "YearTo", + table: "ProjectExperiences", + type: "int", + nullable: false, + defaultValue: 0); + migrationBuilder.DropColumn( + name: "Company", + table: "WorkExperiences"); + + migrationBuilder.DropColumn( + name: "FromDate", + table: "WorkExperiences"); + + migrationBuilder.DropColumn( + name: "ToDate", + table: "WorkExperiences"); + + migrationBuilder.AddColumn( + name: "MonthFrom", + table: "WorkExperiences", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "YearFrom", + table: "WorkExperiences", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "MonthTo", + table: "WorkExperiences", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "YearTo", + table: "WorkExperiences", + type: "int", + nullable: false); + + migrationBuilder.DropColumn( +name: "Date", +table: "Presentations"); + + migrationBuilder.AddColumn( + name: "Month", + table: "Presentations", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "Year", + table: "Presentations", + type: "int", + nullable: false, + defaultValue: 0); + migrationBuilder.DropColumn( +name: "IssuedDate", +table: "Certifications"); + + migrationBuilder.DropColumn( + name: "Issuer", + table: "Certifications"); + + migrationBuilder.AddColumn( + name: "IssuedMonth", + table: "Certifications", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "IssuedYear", + table: "Certifications", + type: "int", + nullable: false, + defaultValue: 0); + } + + } +} diff --git a/src/Infrastructure/Repositories/EmployeeRepository.cs b/src/Infrastructure/Repositories/EmployeeRepository.cs index e856955..a2ff581 100644 --- a/src/Infrastructure/Repositories/EmployeeRepository.cs +++ b/src/Infrastructure/Repositories/EmployeeRepository.cs @@ -5,9 +5,7 @@ using Infrastructure.Entities; -using Microsoft.AspNetCore.Authentication.OAuth.Claims; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Internal; using Microsoft.Extensions.Logging; namespace Infrastructure.Repositories; @@ -206,9 +204,9 @@ private async Task AddCertifications(List certifications, Employe Id = certification.Id, Description = certification.Description, Title = certification.Title, - IssuedMonth = certification.IssuedMonth, - IssuedYear = certification.IssuedYear, + IssuedDate = certification.IssuedDate, ExpiryDate = certification.ExpiryDate, + Issuer = certification.Issuer, LastSynced = DateTime.Now, Employee = entity }; @@ -219,8 +217,7 @@ private async Task AddCertifications(List certifications, Employe certificationEntity.Title = certification.Title; certificationEntity.Description = certification.Description; certificationEntity.ExpiryDate = certification.ExpiryDate; - certificationEntity.IssuedMonth = certification.IssuedMonth; - certificationEntity.IssuedYear = certification.IssuedYear; + certificationEntity.IssuedDate = certification.IssuedDate; certificationEntity.LastSynced = DateTime.Now; } await _db.SaveChangesAsync(); @@ -240,9 +237,9 @@ private async Task AddPresentations(List presentations, EmployeeEn Employee = entity, Description = presentation.Description ?? "", LastSynced = DateTime.Now, - Month = presentation.Month, + Date = presentation.Date, Title = presentation.Title, - Year = presentation.Year + }; await _db.AddAsync(presentationEntity); @@ -251,8 +248,7 @@ private async Task AddPresentations(List presentations, EmployeeEn { presentationEntity.Description = presentation.Description; - presentationEntity.Month = presentation.Month; - presentationEntity.Year = presentation.Year; + presentationEntity.Date = presentation.Date; presentationEntity.Title = presentation.Title; presentationEntity.LastSynced = DateTime.Now; } @@ -271,11 +267,10 @@ private async Task AddWorkExperience(List workExperiences, Emplo Id = workExperience.Id, EmployeeId = entity.Id, Description = workExperience.Description, - MonthFrom = workExperience.MonthFrom, - MonthTo = workExperience.MonthTo, - YearFrom = workExperience.YearFrom, - YearTo = workExperience.YearTo, + FromDate = workExperience.FromDate, + ToDate = workExperience.ToDate, Title = workExperience.Title, + Company = workExperience.Company, LastSynced = DateTime.Now }; await _db.AddAsync(workExperienceEntity); @@ -284,10 +279,9 @@ private async Task AddWorkExperience(List workExperiences, Emplo { workExperienceEntity.Description = workExperience.Description; workExperienceEntity.Title = workExperience.Title; - workExperienceEntity.MonthFrom = workExperience.MonthFrom; - workExperienceEntity.MonthTo = workExperience.MonthTo; - workExperienceEntity.YearFrom = workExperience.YearFrom; - workExperienceEntity.YearTo = workExperience.YearTo; + workExperienceEntity.FromDate = workExperience.FromDate; + workExperienceEntity.ToDate = workExperience.ToDate; + workExperienceEntity.Company = workExperience.Company; workExperienceEntity.LastSynced = DateTime.Now; } } @@ -310,10 +304,9 @@ private async Task AddProjectExperience(List projectExperienc Employee = entity, Description = projectExperience.Description, Title = projectExperience.Title, - MonthFrom = projectExperience.MonthFrom, - MonthTo = projectExperience.MonthTo, - YearFrom = projectExperience.YearFrom, - YearTo = projectExperience.YearTo, + FromDate = projectExperience.FromDate, + ToDate = projectExperience.ToDate, + Customer = projectExperience.Customer, LastSynced = DateTime.Now, }; await _db.AddAsync(projectExperienceEntity); @@ -322,10 +315,9 @@ private async Task AddProjectExperience(List projectExperienc { projectExperienceEntity.Description = projectExperience.Description; projectExperienceEntity.Title = projectExperience.Title; - projectExperienceEntity.MonthFrom = projectExperience.MonthFrom; - projectExperienceEntity.MonthTo = projectExperience.MonthTo; - projectExperienceEntity.YearFrom = projectExperience.YearFrom; - projectExperienceEntity.YearTo = projectExperience.YearTo; + projectExperienceEntity.FromDate = projectExperience.FromDate; + projectExperienceEntity.ToDate = projectExperience.ToDate; + projectExperienceEntity.Customer = projectExperience.Customer; projectExperienceEntity.LastSynced = DateTime.Now; } await AddProjectExperienceRole(projectExperience.Roles, projectExperienceEntity); diff --git a/src/Web/Program.cs b/src/Web/Program.cs index bf07338..a4b7701 100644 --- a/src/Web/Program.cs +++ b/src/Web/Program.cs @@ -139,8 +139,10 @@ builder.Services.AddDbContextPool(options => { - options.UseSqlServer(builder.Configuration.GetConnectionString("EmployeeDatabase"), sqlOptions => sqlOptions.CommandTimeout(45)); - // https://devblogs.microsoft.com/azure-sdk/azure-identity-with-sql-graph-ef/ + options.UseSqlServer(builder.Configuration.GetConnectionString("EmployeeDatabase"), sqlOptions =>{ + sqlOptions.CommandTimeout(45); + sqlOptions.UseDateOnlyTimeOnly(); + }); options.AddInterceptors(new AzureAdAuthenticationDbConnectionInterceptor()); }); diff --git a/src/Web/Web.csproj b/src/Web/Web.csproj index 4148c37..27ea4c5 100644 --- a/src/Web/Web.csproj +++ b/src/Web/Web.csproj @@ -15,6 +15,8 @@ + +