Rewrite Nip and PhoneNumber

This commit is contained in:
mborzyszkowski 2020-09-12 17:18:35 +02:00
parent 7b7998f408
commit c89229d1a9
10 changed files with 24 additions and 66 deletions

View File

@ -24,21 +24,11 @@ namespace InternshipSystem.Api.Controllers
}
private InternshipDbContext Context { get; }
/// <summary>
/// Get all internship types
/// </summary>
/// <returns>List of internship types</returns>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<IList<InternshipType>>> GetAllInternshipTypes(CancellationToken cancellationToken) =>
await Context.InternshipTypes
.ToListAsync(cancellationToken);
/// <summary>
/// Get static page
/// </summary>
/// <returns>List of internship types for edition</returns>
[HttpGet("forCurrentEdition")]
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]

View File

@ -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<BranchOffice> Branches { get; set; }

View File

@ -5,5 +5,6 @@
public long Id { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
}
}

View File

@ -5,5 +5,6 @@
public long Id { get; set; }
public string Type { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Bestiarum vero nullum iudicium puto. Quare ad ea primum, si videtur; <b>Duo Reges: constructio interrete.</b> <i>Eam tum adesse, cum dolor omnis absit;</i> Sed ad bona praeterita redeamus. <mark>Facillimum id quidem est, inquam.</mark> Apud ceteros autem philosophos, qui quaesivit aliquid, tacet; </p>" +
"<p><a href=\"http://loripsum.net/\" target=\"_blank\">Quorum altera prosunt, nocent altera.</a> Eam stabilem appellas. <i>Sed nimis multa.</i> Quo plebiscito decreta a senatu est consuli quaestio Cn. Sin laboramus, quis est, qui alienae modum statuat industriae? <mark>Quod quidem nobis non saepe contingit.</mark> Si autem id non concedatur, non continuo vita beata tollitur. " +
"<a href=\"http://loripsum.net/\" target=\"_blank\">Illum mallem levares, quo optimum atque humanissimum virum, Cn.</a> <i>Id est enim, de quo quaerimus.</i> </p><p>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. </p>" +
"Prosto spod bazy ;D"
"<p>Prosto spod bazy ;D</p>"
},
new StaticPage
{

View File

@ -24,21 +24,11 @@ namespace InternshipSystem.Repository
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Company>()
.Property(company => company.Nip)
.HasConversion<string>(
nip => nip,
s => (Nip)s);
modelBuilder.Entity<BranchOffice>()
.OwnsOne(bo => bo.Address);
modelBuilder.Entity<InternshipProgram>()
.OwnsOne(ip => ip.Mentor)
.Property(mentor => mentor.PhoneNumber)
.HasConversion<string>(
number => number,
s => (PhoneNumber)s);
.OwnsOne(ip => ip.Mentor);
modelBuilder.Entity<ProgramSubject>(builder =>
{