diff --git a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs index f6f01ae..d427da7 100644 --- a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs +++ b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs @@ -79,8 +79,9 @@ namespace InternshipSystem.Api.Controllers public async Task>> SearchInternshipTypes([FromQuery] InternshipTypeSearchQuery searchQuery, CancellationToken cancellationToken) { return await Context.InternshipTypes - .Where(t => string.IsNullOrEmpty(searchQuery.Type) || t.Type.Contains(searchQuery.Type)) - .OrderBy(t => t.Type) + .Where(t => string.IsNullOrEmpty(searchQuery.Label) || t.Label.Contains(searchQuery.Label)) + .Where(t => string.IsNullOrEmpty(searchQuery.LabelEng) || t.Label.Contains(searchQuery.LabelEng)) + .OrderBy(t => t.Label) .Skip(searchQuery.Page * searchQuery.PerPage) .Take(searchQuery.PerPage) .ToListAsync(cancellationToken); @@ -118,7 +119,8 @@ namespace InternshipSystem.Api.Controllers return NotFound($"Internship type with id {internshipTypeFrom.Id} not found"); } - internshipType.Type = string.IsNullOrEmpty(internshipTypeFrom.Type) ? internshipType.Type : internshipTypeFrom.Type; + internshipType.Label = string.IsNullOrEmpty(internshipTypeFrom.Label) ? internshipType.Label : internshipTypeFrom.Label; + internshipType.LabelEng = string.IsNullOrEmpty(internshipTypeFrom.LabelEng) ? internshipType.LabelEng : internshipTypeFrom.LabelEng; internshipType.Description = string.IsNullOrEmpty(internshipTypeFrom.Description) ? internshipType.Description : internshipTypeFrom.Description; internshipType.DescriptionEng = string.IsNullOrEmpty(internshipTypeFrom.DescriptionEng) ? internshipType.DescriptionEng : internshipTypeFrom.DescriptionEng; } @@ -126,7 +128,8 @@ namespace InternshipSystem.Api.Controllers { var newInternshipType = new InternshipType { - Type = internshipTypeFrom.Type, + Label = internshipTypeFrom.Label, + LabelEng = internshipTypeFrom.LabelEng, Description = internshipTypeFrom.Description, DescriptionEng = internshipTypeFrom.DescriptionEng, }; diff --git a/src/InternshipSystem.Api/Queries/InternshipTypeFrom.cs b/src/InternshipSystem.Api/Queries/InternshipTypeFrom.cs index 14abd25..5e746ff 100644 --- a/src/InternshipSystem.Api/Queries/InternshipTypeFrom.cs +++ b/src/InternshipSystem.Api/Queries/InternshipTypeFrom.cs @@ -5,7 +5,8 @@ namespace InternshipSystem.Api.Queries public class InternshipTypeFrom { public long? Id { get; set; } - public string Type { get; set; } + public string Label { get; set; } + public string LabelEng { get; set; } public string Description { get; set; } public string DescriptionEng { get; set; } @@ -15,12 +16,10 @@ namespace InternshipSystem.Api.Queries { RuleFor(t => t.Id).NotNull() .When(t => - string.IsNullOrEmpty(t.Description) || string.IsNullOrEmpty(t.Type) || string.IsNullOrEmpty(t.DescriptionEng)); - RuleFor(t => t.Type).NotEmpty() + string.IsNullOrEmpty(t.Label) || string.IsNullOrEmpty(t.LabelEng)); + RuleFor(t => t.Label).NotEmpty() .When(t => !t.Id.HasValue); - RuleFor(t => t.Description).NotEmpty() - .When(t => !t.Id.HasValue); - RuleFor(t => t.DescriptionEng).NotEmpty() + RuleFor(t => t.LabelEng).NotEmpty() .When(t => !t.Id.HasValue); } } diff --git a/src/InternshipSystem.Api/Queries/SearchQuery/InternshipTypeSearchQuery.cs b/src/InternshipSystem.Api/Queries/SearchQuery/InternshipTypeSearchQuery.cs index b8034b7..16bb4c1 100644 --- a/src/InternshipSystem.Api/Queries/SearchQuery/InternshipTypeSearchQuery.cs +++ b/src/InternshipSystem.Api/Queries/SearchQuery/InternshipTypeSearchQuery.cs @@ -4,6 +4,7 @@ namespace InternshipSystem.Api.Controllers { public class InternshipTypeSearchQuery : SearchQuery { - public string Type { get; set; } = ""; + public string Label { get; set; } = ""; + public string LabelEng { get; set; } = ""; } } \ No newline at end of file diff --git a/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs b/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs index 0056c4a..f6a5627 100644 --- a/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs @@ -3,7 +3,8 @@ public class InternshipType { public long Id { get; set; } - public string Type { get; set; } + public string Label { get; set; } + public string LabelEng { get; set; } public string Description { get; set; } public string DescriptionEng { get; set; } } diff --git a/src/InternshipSystem.Repository/DatabaseFiller.cs b/src/InternshipSystem.Repository/DatabaseFiller.cs index 5745a8f..6ce607c 100644 --- a/src/InternshipSystem.Repository/DatabaseFiller.cs +++ b/src/InternshipSystem.Repository/DatabaseFiller.cs @@ -114,51 +114,40 @@ namespace InternshipSystem.Repository { new InternshipType { - Type = "FreeInternship", - Description = "Praktyka bezpłatna", - DescriptionEng = "Free internship", + Label = "Praktyka bezpłatna", + LabelEng = "Free internship", }, new InternshipType { - Type = "GraduateInternship", - Description = "Praktyka absolwencka", - DescriptionEng = "Graduate internship", + Label = "Praktyka absolwencka", + LabelEng = "Graduate internship", }, new InternshipType { - Type = "FreeApprenticeship", - Description = "Praktyka bezpłatna", - DescriptionEng = "Free apprenticeship", + Label = "Praktyka bezpłatna", + LabelEng = "Free apprenticeship", }, new InternshipType { - Type = "PaidApprenticeship", - Description = "np. przemysłowy", - DescriptionEng = "Paid apprenticeship", + Label = "Praktyka Zagraniczna", + LabelEng = "Foreign Internship", + Description = "IAESTE, ERASMUS", + DescriptionEng = "IAESTE, ERASMUS", }, new InternshipType { - Type = "ForeignInternship", - Description = "np. IAESTE, ERASMUS", - DescriptionEng = "Foreign internship", + Label = "Umowa o pracę", + LabelEng = "contract of employment", }, new InternshipType { - Type = "UOP", - Description = "umowa o pracę", - DescriptionEng = "contract of employment", + Label = "Umowa o dzieło", + LabelEng = "contract work", }, new InternshipType { - Type = "UD", - Description = "umowa o dzieło", - DescriptionEng = "contract work", - }, - new InternshipType - { - Type = "UZ", - Description = "umowa zlecenie", - DescriptionEng = "contract of mandate" + Label = "Umowa zlecenie", + LabelEng = "contract of mandate" }, }; await Context.InternshipTypes.AddRangeAsync(internshipTypes); @@ -210,19 +199,19 @@ namespace InternshipSystem.Repository { new EditionInternshipType { - InternshipType = Context.InternshipTypes.First(t => t.Type.Equals("UOP")) + InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")) }, new EditionInternshipType { - InternshipType = Context.InternshipTypes.First(t => t.Type.Equals("UZ")) + InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenie")) }, new EditionInternshipType { - InternshipType = Context.InternshipTypes.First(t => t.Type.Equals("UD")) + InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o dzieło")) }, new EditionInternshipType { - InternshipType = Context.InternshipTypes.First(t => t.Type.Equals("FreeInternship")) + InternshipType = Context.InternshipTypes.First(t => t.Label.Equals("Praktyka bezpłatna")) } }, Internships = new List(), @@ -245,7 +234,7 @@ namespace InternshipSystem.Repository InternshipRegistration = new InternshipRegistration { Company = Context.Companies.First(c => c.Name.Equals("Intel")), - Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")), + Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa o pracę")), Start = new DateTime(2000, 7, 1), End = new DateTime(2000, 8, 30), State = DocumentState.Submitted, @@ -291,7 +280,7 @@ namespace InternshipSystem.Repository InternshipRegistration = new InternshipRegistration { Company = Context.Companies.First(c => c.Name.Equals("Asseco Poland")), - Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")), + Type = Context.InternshipTypes.First(t => t.Label.Equals("Umowa zlecenie")), Start = new DateTime(2000, 7, 1), End = new DateTime(2000, 8, 30), State = DocumentState.Submitted, diff --git a/src/InternshipSystem.Repository/Migrations/20201002222652_Initial.Designer.cs b/src/InternshipSystem.Repository/Migrations/20201003202928_init.Designer.cs similarity index 98% rename from src/InternshipSystem.Repository/Migrations/20201002222652_Initial.Designer.cs rename to src/InternshipSystem.Repository/Migrations/20201003202928_init.Designer.cs index 75a0794..47844d7 100644 --- a/src/InternshipSystem.Repository/Migrations/20201002222652_Initial.Designer.cs +++ b/src/InternshipSystem.Repository/Migrations/20201003202928_init.Designer.cs @@ -10,8 +10,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace InternshipSystem.Repository.Migrations { [DbContext(typeof(InternshipDbContext))] - [Migration("20201002222652_Initial")] - partial class Initial + [Migration("20201003202928_init")] + partial class init { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -301,8 +301,12 @@ namespace InternshipSystem.Repository.Migrations .HasColumnName("description_eng") .HasColumnType("text"); - b.Property("Type") - .HasColumnName("type") + b.Property("Label") + .HasColumnName("label") + .HasColumnType("text"); + + b.Property("LabelEng") + .HasColumnName("label_eng") .HasColumnType("text"); b.HasKey("Id") diff --git a/src/InternshipSystem.Repository/Migrations/20201002222652_Initial.cs b/src/InternshipSystem.Repository/Migrations/20201003202928_init.cs similarity index 99% rename from src/InternshipSystem.Repository/Migrations/20201002222652_Initial.cs rename to src/InternshipSystem.Repository/Migrations/20201003202928_init.cs index 74d742d..b950b85 100644 --- a/src/InternshipSystem.Repository/Migrations/20201002222652_Initial.cs +++ b/src/InternshipSystem.Repository/Migrations/20201003202928_init.cs @@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace InternshipSystem.Repository.Migrations { - public partial class Initial : Migration + public partial class init : Migration { protected override void Up(MigrationBuilder migrationBuilder) { @@ -56,7 +56,8 @@ namespace InternshipSystem.Repository.Migrations { id = table.Column(nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - type = table.Column(nullable: true), + label = table.Column(nullable: true), + label_eng = table.Column(nullable: true), description = table.Column(nullable: true), description_eng = table.Column(nullable: true) }, diff --git a/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs b/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs index e78d3af..b43220e 100644 --- a/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs +++ b/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs @@ -299,8 +299,12 @@ namespace InternshipSystem.Repository.Migrations .HasColumnName("description_eng") .HasColumnType("text"); - b.Property("Type") - .HasColumnName("type") + b.Property("Label") + .HasColumnName("label") + .HasColumnType("text"); + + b.Property("LabelEng") + .HasColumnName("label_eng") .HasColumnType("text"); b.HasKey("Id")