From c89229d1a97efa61c4ddd326c9193adfe944a040 Mon Sep 17 00:00:00 2001 From: mborzyszkowski Date: Sat, 12 Sep 2020 17:18:35 +0200 Subject: [PATCH] Rewrite Nip and PhoneNumber --- .../Controllers/InternshipTypesController.cs | 12 +----------- src/InternshipSystem.Core/Entity/Company.cs | 5 ++--- .../Entity/Internship/InternshipSubject.cs | 1 + .../Entity/Internship/InternshipType.cs | 1 + .../Entity/StaticPage.cs | 2 ++ .../ValueObject/Mentor.cs | 2 +- src/InternshipSystem.Core/ValueObject/Nip.cs | 18 ------------------ .../ValueObject/PhoneNumber.cs | 18 ------------------ .../DatabaseFiller.cs | 19 +++++++++++++++---- .../InternshipDbContext.cs | 12 +----------- 10 files changed, 24 insertions(+), 66 deletions(-) delete mode 100644 src/InternshipSystem.Core/ValueObject/Nip.cs delete mode 100644 src/InternshipSystem.Core/ValueObject/PhoneNumber.cs diff --git a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs index f7a77dd..e7ac0df 100644 --- a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs +++ b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs @@ -24,21 +24,11 @@ namespace InternshipSystem.Api.Controllers } private InternshipDbContext Context { get; } - /// - /// Get all internship types - /// - /// List of internship types - [HttpGet] - [ProducesResponseType(StatusCodes.Status200OK)] - public async Task>> GetAllInternshipTypes(CancellationToken cancellationToken) => - await Context.InternshipTypes - .ToListAsync(cancellationToken); - /// /// Get static page /// /// List of internship types for edition - [HttpGet("forCurrentEdition")] + [HttpGet] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] diff --git a/src/InternshipSystem.Core/Entity/Company.cs b/src/InternshipSystem.Core/Entity/Company.cs index 67b640d..46904c4 100644 --- a/src/InternshipSystem.Core/Entity/Company.cs +++ b/src/InternshipSystem.Core/Entity/Company.cs @@ -1,12 +1,11 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace InternshipSystem.Core { public class Company { public long Id { get; set; } - public Nip Nip { get; set; } + public string Nip { get; set; } public string Name { get; set; } public List Branches { get; set; } diff --git a/src/InternshipSystem.Core/Entity/Internship/InternshipSubject.cs b/src/InternshipSystem.Core/Entity/Internship/InternshipSubject.cs index f94b0c9..f6c312b 100644 --- a/src/InternshipSystem.Core/Entity/Internship/InternshipSubject.cs +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipSubject.cs @@ -5,5 +5,6 @@ public long Id { get; set; } public string Description { get; set; } + public string DescriptionEng { 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 5065f12..0056c4a 100644 --- a/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs @@ -5,5 +5,6 @@ public long Id { get; set; } public string Type { get; set; } public string Description { get; set; } + public string DescriptionEng { get; set; } } } \ No newline at end of file diff --git a/src/InternshipSystem.Core/Entity/StaticPage.cs b/src/InternshipSystem.Core/Entity/StaticPage.cs index b4329bd..56b474c 100644 --- a/src/InternshipSystem.Core/Entity/StaticPage.cs +++ b/src/InternshipSystem.Core/Entity/StaticPage.cs @@ -5,6 +5,8 @@ public long Id { get; set; } public string AccessName { get; set; } public string Title { get; set; } + public string TitleEng { get; set; } public string Content { get; set; } + public string ContentEng { get; set; } } } \ No newline at end of file diff --git a/src/InternshipSystem.Core/ValueObject/Mentor.cs b/src/InternshipSystem.Core/ValueObject/Mentor.cs index 4af5c24..d7be213 100644 --- a/src/InternshipSystem.Core/ValueObject/Mentor.cs +++ b/src/InternshipSystem.Core/ValueObject/Mentor.cs @@ -5,6 +5,6 @@ public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } - public PhoneNumber PhoneNumber { get; set; } + public string PhoneNumber { get; set; } } } \ No newline at end of file diff --git a/src/InternshipSystem.Core/ValueObject/Nip.cs b/src/InternshipSystem.Core/ValueObject/Nip.cs deleted file mode 100644 index 903b59e..0000000 --- a/src/InternshipSystem.Core/ValueObject/Nip.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace InternshipSystem.Core -{ - public struct Nip - { - private readonly string _nip; - - public Nip(string nip) - { - _nip = nip; - } - - public static implicit operator string(Nip nip) => - nip._nip; - - public static implicit operator Nip(string maybeNip) => - new Nip(maybeNip); - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Core/ValueObject/PhoneNumber.cs b/src/InternshipSystem.Core/ValueObject/PhoneNumber.cs deleted file mode 100644 index e72d355..0000000 --- a/src/InternshipSystem.Core/ValueObject/PhoneNumber.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace InternshipSystem.Core -{ - public struct PhoneNumber - { - private readonly string _phoneNumber; - - public PhoneNumber(string phoneNumber) - { - _phoneNumber = phoneNumber; - } - - public static implicit operator string(PhoneNumber number) => - number._phoneNumber; - - public static implicit operator PhoneNumber(string maybeNumber) => - new PhoneNumber(maybeNumber); - } -} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/DatabaseFiller.cs b/src/InternshipSystem.Repository/DatabaseFiller.cs index bbb1693..0d07a43 100644 --- a/src/InternshipSystem.Repository/DatabaseFiller.cs +++ b/src/InternshipSystem.Repository/DatabaseFiller.cs @@ -110,41 +110,49 @@ namespace InternshipSystem.Repository { Type = "FreeInternship", Description = "Praktyka bezpłatna", + DescriptionEng = "Free internship", }, new InternshipType { Type = "GraduateInternship", Description = "Praktyka absolwencka", + DescriptionEng = "Graduate internship", }, new InternshipType { Type = "FreeApprenticeship", Description = "Praktyka bezpłatna", + DescriptionEng = "Free apprenticeship", }, new InternshipType { Type = "PaidApprenticeship", Description = "np. przemysłowy", + DescriptionEng = "Paid apprenticeship", }, new InternshipType { Type = "ForeignInternship", Description = "np. IAESTE, ERASMUS", + DescriptionEng = "Foreign internship", }, new InternshipType { Type = "UOP", Description = "umowa o pracę", + DescriptionEng = "contract of employment", }, new InternshipType { Type = "UD", Description = "umowa o dzieło", + DescriptionEng = "contract work", }, new InternshipType { Type = "UZ", Description = "umowa zlecenie", + DescriptionEng = "contract of mandate" }, }; await Context.InternshipTypes.AddRangeAsync(internshipTypes); @@ -167,21 +175,24 @@ namespace InternshipSystem.Repository { Subject = new InternshipSubject { - Description = "Modelowanie baz danych" + Description = "Modelowanie baz danych", + DescriptionEng = "Database modeling", } }, new EditionSubject { Subject = new InternshipSubject { - Description = "Oprogramowywanie kart graficznych" + Description = "Oprogramowywanie kart graficznych", + DescriptionEng = "Graphics card software", } }, new EditionSubject { Subject = new InternshipSubject { - Description = "Projektowanie UI" + Description = "Projektowanie UI", + DescriptionEng = "UI design", } } }, @@ -315,7 +326,7 @@ namespace InternshipSystem.Repository "

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bestiarum vero nullum iudicium puto. Quare ad ea primum, si videtur; Duo Reges: constructio interrete. Eam tum adesse, cum dolor omnis absit; Sed ad bona praeterita redeamus. Facillimum id quidem est, inquam. Apud ceteros autem philosophos, qui quaesivit aliquid, tacet;

" + "

Quorum altera prosunt, nocent altera. Eam stabilem appellas. Sed nimis multa. Quo plebiscito decreta a senatu est consuli quaestio Cn. Sin laboramus, quis est, qui alienae modum statuat industriae? Quod quidem nobis non saepe contingit. Si autem id non concedatur, non continuo vita beata tollitur. " + "Illum mallem levares, quo optimum atque humanissimum virum, Cn. Id est enim, de quo quaerimus.

Ille vero, si insipiens-quo certe, quoniam tyrannus -, numquam beatus; Sin dicit obscurari quaedam nec apparere, quia valde parva sint, nos quoque concedimus; Et quod est munus, quod opus sapientiae? Ab hoc autem quaedam non melius quam veteres, quaedam omnino relicta.

" + - "Prosto spod bazy ;D" + "

Prosto spod bazy ;D

" }, new StaticPage { diff --git a/src/InternshipSystem.Repository/InternshipDbContext.cs b/src/InternshipSystem.Repository/InternshipDbContext.cs index 9ff73e3..0e729fb 100644 --- a/src/InternshipSystem.Repository/InternshipDbContext.cs +++ b/src/InternshipSystem.Repository/InternshipDbContext.cs @@ -24,21 +24,11 @@ namespace InternshipSystem.Repository protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.Entity() - .Property(company => company.Nip) - .HasConversion( - nip => nip, - s => (Nip)s); - modelBuilder.Entity() .OwnsOne(bo => bo.Address); modelBuilder.Entity() - .OwnsOne(ip => ip.Mentor) - .Property(mentor => mentor.PhoneNumber) - .HasConversion( - number => number, - s => (PhoneNumber)s); + .OwnsOne(ip => ip.Mentor); modelBuilder.Entity(builder => {