diff --git a/src/InternshipSystem.Api/Controllers/AccessController.cs b/src/InternshipSystem.Api/Controllers/AccessController.cs index 44d1b95..ea15e8f 100644 --- a/src/InternshipSystem.Api/Controllers/AccessController.cs +++ b/src/InternshipSystem.Api/Controllers/AccessController.cs @@ -44,7 +44,7 @@ namespace InternshipSystem.Api.Controllers [HttpGet("loginEdition")] [Authorize] - public async Task LoginIntoEdition(Guid editionId, User user, CancellationToken token) + public async Task LoginIntoEdition(Guid editionId, [FromServices] User user, CancellationToken token) { var edition = await _context.Editions.FindAsync(editionId); diff --git a/src/InternshipSystem.Api/Controllers/AdminController.cs b/src/InternshipSystem.Api/Controllers/AdminController.cs index 6a153f8..0c943a5 100644 --- a/src/InternshipSystem.Api/Controllers/AdminController.cs +++ b/src/InternshipSystem.Api/Controllers/AdminController.cs @@ -17,9 +17,12 @@ namespace InternshipSystem.Api.Controllers [HttpPost("fill")] - public async Task Fill() { + public async Task Fill() + { await FillerService.FillCompanies(); + await FillerService.FillInternshipTypes(); await FillerService.FillEditions(); + await FillerService.FillStaticPages(); return Ok(); } @@ -29,11 +32,26 @@ namespace InternshipSystem.Api.Controllers await FillerService.FillCompanies(); return Ok(); } + + [HttpPost("fill/internshipTypes")] + public async Task FillInternshipTypesAsync() + { + await FillerService.FillInternshipTypes(); + return Ok(); + } [HttpPost("fill/editions")] - public async Task FillEditionsAsync() { + public async Task FillEditionsAsync() + { await FillerService.FillEditions(); return Ok(); } + + [HttpPost("fill/staticPages")] + public async Task FillStaticPagesAsync() + { + await FillerService.FillStaticPages(); + return Ok(); + } } } \ No newline at end of file diff --git a/src/InternshipSystem.Api/Controllers/DocumentsController.cs b/src/InternshipSystem.Api/Controllers/DocumentsController.cs index 3406f9b..033b2aa 100644 --- a/src/InternshipSystem.Api/Controllers/DocumentsController.cs +++ b/src/InternshipSystem.Api/Controllers/DocumentsController.cs @@ -35,7 +35,8 @@ namespace InternshipSystem.Api.Controllers [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [Authorize(Policy = Policies.RegisteredOnly)] - public async Task AddDocumentToInternship([FromBody] DocumentPublishRequest documentRequest, CancellationToken cancellationToken) + public async Task AddDocumentToInternship([FromBody] DocumentPublishRequest documentRequest, + [FromServices] User user, CancellationToken cancellationToken) { var validator = new DocumentPublishRequest.Validator(); var validationResult = await validator.ValidateAsync(documentRequest, cancellationToken); @@ -45,9 +46,7 @@ namespace InternshipSystem.Api.Controllers return BadRequest(validationResult.ToString()); } - var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value); - - return await _internshipService.AddDocumentToInternship(documentRequest, personNumber, cancellationToken); + return await _internshipService.AddDocumentToInternship(documentRequest, user.PersonNumber, cancellationToken); } } } \ No newline at end of file diff --git a/src/InternshipSystem.Api/Controllers/EditionController.cs b/src/InternshipSystem.Api/Controllers/EditionController.cs index f9e6774..777524c 100644 --- a/src/InternshipSystem.Api/Controllers/EditionController.cs +++ b/src/InternshipSystem.Api/Controllers/EditionController.cs @@ -38,15 +38,13 @@ namespace InternshipSystem.Api.Controllers [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] - public async Task>> GetAvailableEditions(CancellationToken token) + public async Task>> GetAvailableEditions([FromServices] User user, CancellationToken token) { - var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value); - var editions = await Context.Editions .Where(edition => edition.Internships - .Any(internship => internship.Student.Id == personNumber)) + .Any(internship => internship.Student.Id == user.PersonNumber)) .ProjectTo(Mapper.ConfigurationProvider) .ToListAsync(token); @@ -74,7 +72,7 @@ namespace InternshipSystem.Api.Controllers var edition = await Context.Editions .Include(e => e.AvailableSubjects) - .Where(e => e.Id == id) + .Where(e => e.Id.Equals(id)) .ProjectTo(Mapper.ConfigurationProvider) .FirstOrDefaultAsync(token); diff --git a/src/InternshipSystem.Api/Controllers/InternshipRegistrationController.cs b/src/InternshipSystem.Api/Controllers/InternshipRegistrationController.cs index 44c8eb6..6bc7ab8 100644 --- a/src/InternshipSystem.Api/Controllers/InternshipRegistrationController.cs +++ b/src/InternshipSystem.Api/Controllers/InternshipRegistrationController.cs @@ -31,8 +31,8 @@ namespace InternshipSystem.Api.Controllers [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [Authorize] - public async Task SubmitRegistrationForm([FromBody] RegistrationFormQuery registrationQuery, - CancellationToken cancellationToken) + public async Task SubmitRegistrationForm([FromBody] RegistrationFormQuery registrationQuery, + [FromServices] User user, CancellationToken cancellationToken) { var validator = new RegistrationFormQuery.Validator(); var validationResult = await validator.ValidateAsync(registrationQuery, cancellationToken); @@ -41,10 +41,8 @@ namespace InternshipSystem.Api.Controllers { return BadRequest(validationResult.ToString()); } - - var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value); - return await _internshipService.SubmitRegistration(registrationQuery, personNumber, cancellationToken); + return await _internshipService.SubmitRegistration(registrationQuery, user.PersonNumber, cancellationToken); } } } \ No newline at end of file diff --git a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs new file mode 100644 index 0000000..e7ac0df --- /dev/null +++ b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using InternshipSystem.Api.Security; +using InternshipSystem.Core.Entity.Internship; +using InternshipSystem.Repository; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace InternshipSystem.Api.Controllers +{ + [ApiController] + [Route("internshipType")] + public class InternshipTypesController : ControllerBase + { + + public InternshipTypesController(InternshipDbContext context) + { + Context = context; + } + private InternshipDbContext Context { get; } + + /// + /// Get static page + /// + /// List of internship types for edition + [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + [Authorize(Policy = Policies.RegisteredOnly)] + public async Task>> GetInternshipTypesForEdition([FromServices] User user, CancellationToken cancellationToken) + { + var edition = + await Context.Editions + .Include(e => e.AvailableInternshipTypes) + .Where(e => e.Id.Equals(user.EditionId)) + .FirstOrDefaultAsync(cancellationToken: cancellationToken); + + if (edition == null) + { + return NotFound(); + } + + return Ok(edition.AvailableInternshipTypes); + } + } +} \ No newline at end of file diff --git a/src/InternshipSystem.Api/Controllers/RegistrationController.cs b/src/InternshipSystem.Api/Controllers/RegistrationController.cs index 89d2cb2..f5de0b1 100644 --- a/src/InternshipSystem.Api/Controllers/RegistrationController.cs +++ b/src/InternshipSystem.Api/Controllers/RegistrationController.cs @@ -33,7 +33,7 @@ namespace InternshipSystem.Api.Controllers [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] - public async Task RegisterStudentForEdition([FromBody] Guid registrationCode, CancellationToken token) + public async Task RegisterStudentForEdition([FromBody] Guid registrationCode, [FromServices] User user, CancellationToken token) { var edition = await _context.Editions.FindAsync(registrationCode, token); @@ -41,10 +41,8 @@ namespace InternshipSystem.Api.Controllers { return NotFound(); } - - var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value); - - var student = await _context.Students.FindAsync(personNumber, token); + + var student = await _context.Students.FindAsync(user.PersonNumber, token); edition.RegisterInternship(student); await _context.SaveChangesAsync(token); diff --git a/src/InternshipSystem.Api/Controllers/StaticPagesController.cs b/src/InternshipSystem.Api/Controllers/StaticPagesController.cs new file mode 100644 index 0000000..e819202 --- /dev/null +++ b/src/InternshipSystem.Api/Controllers/StaticPagesController.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using InternshipSystem.Core; +using InternshipSystem.Repository; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +namespace InternshipSystem.Api.Controllers +{ + [ApiController] + [Route("staticPage")] + public class StaticPagesController : ControllerBase + { + public StaticPagesController(InternshipDbContext context) + { + Context = context; + } + private InternshipDbContext Context { get; } + + /// + /// Get all static pages + /// + /// List of static pages with titles and content + [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + public async Task>> GetStaticPages(CancellationToken cancellationToken) => + await Context.StaticPages + .ToListAsync(cancellationToken); + + /// + /// Get static page + /// + /// Name of page + /// Static page title and content + [HttpGet("{accessName}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task> GetStaticPage(string accessName, CancellationToken cancellationToken) + { + var page = + await Context.StaticPages + .Where(p => p.AccessName.Trim().ToLower().Equals(accessName.Trim().ToLower())) + .FirstOrDefaultAsync(cancellationToken); + + if (page == null) + { + return NotFound(); + } + + return Ok(page); + } + } +} \ No newline at end of file diff --git a/src/InternshipSystem.Api/ModelBinders/UserBinder.cs b/src/InternshipSystem.Api/ModelBinders/UserBinder.cs index 8a5fe2a..62096e2 100644 --- a/src/InternshipSystem.Api/ModelBinders/UserBinder.cs +++ b/src/InternshipSystem.Api/ModelBinders/UserBinder.cs @@ -22,12 +22,19 @@ namespace InternshipSystem.Api.ModelBinders { return Task.CompletedTask; } + + Guid? editionGuid = null; + if (principal.FindFirst(InternshipClaims.Edition) != null + && Guid.TryParse(principal.FindFirst(InternshipClaims.Edition).Value, out var edition)) + { + editionGuid = edition; + } var user = new User { Name = principal.FindFirst(ClaimTypes.Name).Value, PersonNumber = long.Parse(principal.FindFirst(InternshipClaims.PersonNumber).Value), - EditionId = Guid.TryParse(principal.FindFirst(InternshipClaims.Edition).Value, out var edition) ? edition : (Guid?) null + EditionId = editionGuid }; bindingContext.Result = ModelBindingResult.Success(user); diff --git a/src/InternshipSystem.Api/Queries/RegistrationFormQuery.cs b/src/InternshipSystem.Api/Queries/RegistrationFormQuery.cs index 77122c9..c1aad76 100644 --- a/src/InternshipSystem.Api/Queries/RegistrationFormQuery.cs +++ b/src/InternshipSystem.Api/Queries/RegistrationFormQuery.cs @@ -10,7 +10,7 @@ namespace InternshipSystem.Api.Queries public BranchOfficeForm BranchOffice { get; set; } public DateTime? Start { get; set; } public DateTime? End { get; set; } - public InternshipType? Type { get; set; } + public InternshipType Type { get; set; } public class Validator : AbstractValidator { diff --git a/src/InternshipSystem.Api/Services/InternshipService.cs b/src/InternshipSystem.Api/Services/InternshipService.cs index 4bcaa03..51eafc5 100644 --- a/src/InternshipSystem.Api/Services/InternshipService.cs +++ b/src/InternshipSystem.Api/Services/InternshipService.cs @@ -68,7 +68,7 @@ namespace InternshipSystem.Api.Services internshipRegistration.Start = registrationQuery.Start ?? internshipRegistration.Start; internshipRegistration.End = registrationQuery.End ?? internshipRegistration.End; - if (registrationQuery.Type.HasValue && edition.IsInternshipTypeAllowed(registrationQuery.Type.Value)) + if (registrationQuery.Type != null && edition.IsInternshipTypeAllowed(registrationQuery.Type)) { return new BadRequestObjectResult("Edition doesn't have this type of employment in available employments type"); } 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/Edition.cs b/src/InternshipSystem.Core/Entity/Edition.cs index d6ee476..16fd29c 100644 --- a/src/InternshipSystem.Core/Entity/Edition.cs +++ b/src/InternshipSystem.Core/Entity/Edition.cs @@ -15,7 +15,7 @@ namespace InternshipSystem.Core public Course Course { get; set; } public List Internships { get; set; } public List AvailableSubjects { get; set; } - public List AvailableInternshipTypes { get; set; } + public List AvailableInternshipTypes { get; set; } public bool IsOpen => EditionFinish < DateTime.Today; @@ -31,7 +31,7 @@ namespace InternshipSystem.Core public bool IsInternshipTypeAllowed(InternshipType registrationQueryType) { - return AvailableInternshipTypes.Select(it => it.InternshipType).Contains(registrationQueryType); + return AvailableInternshipTypes.Contains(registrationQueryType); } public void RegisterInternship(Student student) 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 e810e05..0056c4a 100644 --- a/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs @@ -1,14 +1,10 @@ namespace InternshipSystem.Core.Entity.Internship { - public enum InternshipType - { - FreeInternship = 0, - GraduateInternship = 1, - FreeApprenticeship = 2, - PaidApprenticeship = 3, - ForeignInternship = 4, - UOP = 5, - UD = 6, - UZ = 7, + public class InternshipType + { + 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 new file mode 100644 index 0000000..56b474c --- /dev/null +++ b/src/InternshipSystem.Core/Entity/StaticPage.cs @@ -0,0 +1,12 @@ +namespace InternshipSystem.Core +{ + public class StaticPage + { + 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/UglyOrmArtifacts/EditionInternshipType.cs b/src/InternshipSystem.Core/UglyOrmArtifacts/EditionInternshipType.cs deleted file mode 100644 index f8c03c2..0000000 --- a/src/InternshipSystem.Core/UglyOrmArtifacts/EditionInternshipType.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using InternshipSystem.Core.Entity.Internship; - -namespace InternshipSystem.Core.UglyOrmArtifacts -{ - public class EditionInternshipType - { - public long Id { get; set; } - public InternshipType InternshipType { 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 c3f135a..f6038a8 100644 --- a/src/InternshipSystem.Repository/DatabaseFiller.cs +++ b/src/InternshipSystem.Repository/DatabaseFiller.cs @@ -102,12 +102,70 @@ namespace InternshipSystem.Repository await Context.SaveChangesAsync(); } + public async Task FillInternshipTypes() + { + var internshipTypes = new List + { + new InternshipType + { + 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); + await Context.SaveChangesAsync(); + } + public async Task FillEditions() { var editions = new List { new Edition { + Id = Guid.Parse("138da8a3-855c-4b17-9bd2-5f357679efa9"), EditionStart = new DateTime(2000, 5, 10), EditionFinish = new DateTime(2000, 11, 10), ReportingStart = new DateTime(2000, 9, 30), @@ -117,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", } } }, @@ -139,12 +200,12 @@ namespace InternshipSystem.Repository { Name = "Informatyka", }, - AvailableInternshipTypes = new List + AvailableInternshipTypes = new List { - new EditionInternshipType() { InternshipType = InternshipType.UOP }, - new EditionInternshipType() { InternshipType = InternshipType.UZ }, - new EditionInternshipType() { InternshipType = InternshipType.UD }, - new EditionInternshipType() { InternshipType = InternshipType.FreeInternship }, + Context.InternshipTypes.First(t => t.Type.Equals("UOP")), + Context.InternshipTypes.First(t => t.Type.Equals("UZ")), + Context.InternshipTypes.First(t => t.Type.Equals("UD")), + Context.InternshipTypes.First(t => t.Type.Equals("FreeInternship")), }, Internships = new List(), } @@ -166,15 +227,15 @@ namespace InternshipSystem.Repository }, InternshipRegistration = new InternshipRegistration { - Company = Context.Companies.First(c => c.Id.Equals(1)), //Intel - Type = InternshipType.UOP, + Company = Context.Companies.First(c => c.Name.Equals("Intel")), + Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")), Start = new DateTime(2000, 7, 1), End = new DateTime(2000, 8, 30), State = DocumentState.Submitted, BranchAddress = Context.Companies .Include(c => c.Branches) - .First(c => c.Id.Equals(1)) + .First(c => c.Name.Equals("Intel")) .Branches .First(), }, @@ -216,15 +277,15 @@ namespace InternshipSystem.Repository }, InternshipRegistration = new InternshipRegistration { - Company = Context.Companies.First(c => c.Id.Equals(2)), //Asseco - Type = InternshipType.UZ, + Company = Context.Companies.First(c => c.Name.Equals("Asseco Poland")), + Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")), Start = new DateTime(2000, 7, 1), End = new DateTime(2000, 8, 30), State = DocumentState.Submitted, BranchAddress = Context.Companies .Include(c => c.Branches) - .First(c => c.Id.Equals(2)) + .First(c => c.Name.Equals("Asseco Poland")) .Branches .First(), }, @@ -253,45 +314,39 @@ namespace InternshipSystem.Repository await Context.SaveChangesAsync(); } - // new InternshipType - // { - // Type = "FreeInternship", - // Description = "Praktyka bezpłatna", - // }, - // new InternshipType - // { - // Type = "GraduateInternship" - // }, - // new InternshipType - // { - // Type = "FreeApprenticeship" - // }, - // new InternshipType - // { - // Type = "PaidApprenticeship", - // Description = "np. przemysłowy" - // }, - // new InternshipType - // { - // Type = "ForeignInternship", - // Description = "np. IAESTE, ERASMUS" - // }, - // new InternshipType - // { - // Type = "UOP" - // }, - // new InternshipType - // { - // Type = "UD" - // }, - // new InternshipType - // { - // Type = "UZ" - // }, - // new InternshipType - // { - // Type = "Other", - // Description = "Należy wprowadzić samodzielnie" - // } + public async Task FillStaticPages() + { + var staticPages = new List + { + new StaticPage + { + AccessName = "regulations", + Title = "Regulamin Praktyk", + TitleEng = "Internship Regulations", + Content = + "

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 z bazy danych ;D

", + ContentEng = + "

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.

" + + "

Straight from the database ;D

", + }, + new StaticPage + { + AccessName = "info", + Title = "Informacje", + TitleEng = "Information", + Content = + "

Nowe zmiany:

", + ContentEng = + "

New changes:

", + } + }; + await Context.StaticPages.AddRangeAsync(staticPages); + await Context.SaveChangesAsync(); + } } } \ No newline at end of file diff --git a/src/InternshipSystem.Repository/InternshipDbContext.cs b/src/InternshipSystem.Repository/InternshipDbContext.cs index cd73ffb..0e729fb 100644 --- a/src/InternshipSystem.Repository/InternshipDbContext.cs +++ b/src/InternshipSystem.Repository/InternshipDbContext.cs @@ -9,7 +9,8 @@ namespace InternshipSystem.Repository { public DbSet Companies { get; set; } public DbSet Editions { get; set; } - + public DbSet StaticPages { get; set; } + public DbSet InternshipTypes { get; set; } public DbSet Students { get; set; } public InternshipDbContext(DbContextOptions options) @@ -23,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 => {