Merge pull request 'InternshipTypeNextFixes' (#57) from InternshipTypeNextFixes into master
This commit is contained in:
commit
1b80f058dc
@ -79,8 +79,9 @@ namespace InternshipSystem.Api.Controllers
|
||||
public async Task<ActionResult<IEnumerable<InternshipType>>> 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,
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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; } = "";
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
|
@ -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<Internship>(),
|
||||
@ -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,
|
||||
|
@ -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<string>("Type")
|
||||
.HasColumnName("type")
|
||||
b.Property<string>("Label")
|
||||
.HasColumnName("label")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LabelEng")
|
||||
.HasColumnName("label_eng")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id")
|
@ -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<long>(nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
type = table.Column<string>(nullable: true),
|
||||
label = table.Column<string>(nullable: true),
|
||||
label_eng = table.Column<string>(nullable: true),
|
||||
description = table.Column<string>(nullable: true),
|
||||
description_eng = table.Column<string>(nullable: true)
|
||||
},
|
@ -299,8 +299,12 @@ namespace InternshipSystem.Repository.Migrations
|
||||
.HasColumnName("description_eng")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Type")
|
||||
.HasColumnName("type")
|
||||
b.Property<string>("Label")
|
||||
.HasColumnName("label")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("LabelEng")
|
||||
.HasColumnName("label_eng")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id")
|
||||
|
Loading…
Reference in New Issue
Block a user