Static Pages and fixes #38
@ -44,7 +44,7 @@ namespace InternshipSystem.Api.Controllers
|
||||
|
||||
[HttpGet("loginEdition")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> LoginIntoEdition(Guid editionId, User user, CancellationToken token)
|
||||
public async Task<ActionResult> LoginIntoEdition(Guid editionId, [FromServices] User user, CancellationToken token)
|
||||
{
|
||||
var edition = await _context.Editions.FindAsync(editionId);
|
||||
|
||||
|
@ -17,9 +17,12 @@ namespace InternshipSystem.Api.Controllers
|
||||
|
||||
|
||||
[HttpPost("fill")]
|
||||
public async Task<IActionResult> Fill() {
|
||||
public async Task<IActionResult> Fill()
|
||||
{
|
||||
await FillerService.FillCompanies();
|
||||
await FillerService.FillInternshipTypes();
|
||||
await FillerService.FillEditions();
|
||||
await FillerService.FillStaticPages();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@ -30,10 +33,25 @@ namespace InternshipSystem.Api.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost("fill/internshipTypes")]
|
||||
public async Task<IActionResult> FillInternshipTypesAsync()
|
||||
{
|
||||
await FillerService.FillInternshipTypes();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost("fill/editions")]
|
||||
public async Task<IActionResult> FillEditionsAsync() {
|
||||
public async Task<IActionResult> FillEditionsAsync()
|
||||
{
|
||||
await FillerService.FillEditions();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost("fill/staticPages")]
|
||||
public async Task<IActionResult> FillStaticPagesAsync()
|
||||
{
|
||||
await FillerService.FillStaticPages();
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
@ -35,7 +35,8 @@ namespace InternshipSystem.Api.Controllers
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
||||
public async Task<ActionResult> AddDocumentToInternship([FromBody] DocumentPublishRequest documentRequest, CancellationToken cancellationToken)
|
||||
public async Task<ActionResult> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -38,15 +38,13 @@ namespace InternshipSystem.Api.Controllers
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<IList<EditionResult>>> GetAvailableEditions(CancellationToken token)
|
||||
public async Task<ActionResult<IList<EditionResult>>> 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<EditionResult>(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<EditionConfigurationResult>(Mapper.ConfigurationProvider)
|
||||
.FirstOrDefaultAsync(token);
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace InternshipSystem.Api.Controllers
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[Authorize]
|
||||
public async Task<ActionResult> SubmitRegistrationForm([FromBody] RegistrationFormQuery registrationQuery,
|
||||
CancellationToken cancellationToken)
|
||||
[FromServices] User user, CancellationToken cancellationToken)
|
||||
{
|
||||
var validator = new RegistrationFormQuery.Validator();
|
||||
var validationResult = await validator.ValidateAsync(registrationQuery, cancellationToken);
|
||||
@ -42,9 +42,7 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
||||
/// <summary>
|
||||
/// Get static page
|
||||
/// </summary>
|
||||
/// <returns>List of internship types for edition</returns>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
||||
public async Task<ActionResult<IList<InternshipType>>> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ namespace InternshipSystem.Api.Controllers
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
[Authorize]
|
||||
public async Task<IActionResult> RegisterStudentForEdition([FromBody] Guid registrationCode, CancellationToken token)
|
||||
public async Task<IActionResult> RegisterStudentForEdition([FromBody] Guid registrationCode, [FromServices] User user, CancellationToken token)
|
||||
{
|
||||
var edition = await _context.Editions.FindAsync(registrationCode, token);
|
||||
|
||||
@ -42,9 +42,7 @@ 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);
|
||||
|
@ -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; }
|
||||
|
||||
/// <summary>
|
||||
/// Get all static pages
|
||||
/// </summary>
|
||||
/// <returns>List of static pages with titles and content</returns>
|
||||
[HttpGet]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<IList<StaticPage>>> GetStaticPages(CancellationToken cancellationToken) =>
|
||||
await Context.StaticPages
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Get static page
|
||||
/// </summary>
|
||||
/// <param name="accessName">Name of page</param>
|
||||
/// <returns>Static page title and content</returns>
|
||||
[HttpGet("{accessName}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult<StaticPage>> 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -23,11 +23,18 @@ 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);
|
||||
|
@ -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<RegistrationFormQuery>
|
||||
{
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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; }
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace InternshipSystem.Core
|
||||
public Course Course { get; set; }
|
||||
public List<Internship> Internships { get; set; }
|
||||
public List<EditionSubject> AvailableSubjects { get; set; }
|
||||
public List<EditionInternshipType> AvailableInternshipTypes { get; set; }
|
||||
public List<InternshipType> 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)
|
||||
|
@ -5,5 +5,6 @@
|
||||
public long Id { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
public string DescriptionEng { get; set; }
|
||||
}
|
||||
}
|
@ -1,14 +1,10 @@
|
||||
namespace InternshipSystem.Core.Entity.Internship
|
||||
{
|
||||
public enum InternshipType
|
||||
public class InternshipType
|
||||
{
|
||||
FreeInternship = 0,
|
||||
GraduateInternship = 1,
|
||||
FreeApprenticeship = 2,
|
||||
PaidApprenticeship = 3,
|
||||
ForeignInternship = 4,
|
||||
UOP = 5,
|
||||
UD = 6,
|
||||
UZ = 7,
|
||||
public long Id { get; set; }
|
||||
public string Type { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string DescriptionEng { get; set; }
|
||||
}
|
||||
}
|
12
src/InternshipSystem.Core/Entity/StaticPage.cs
Normal file
12
src/InternshipSystem.Core/Entity/StaticPage.cs
Normal file
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -102,12 +102,70 @@ namespace InternshipSystem.Repository
|
||||
await Context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task FillInternshipTypes()
|
||||
{
|
||||
var internshipTypes = new List<InternshipType>
|
||||
{
|
||||
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<Edition>
|
||||
{
|
||||
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<EditionInternshipType>
|
||||
AvailableInternshipTypes = new List<InternshipType>
|
||||
{
|
||||
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<Internship>(),
|
||||
}
|
||||
@ -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<StaticPage>
|
||||
{
|
||||
new StaticPage
|
||||
{
|
||||
AccessName = "regulations",
|
||||
Title = "Regulamin Praktyk",
|
||||
TitleEng = "Internship Regulations",
|
||||
Content =
|
||||
"<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>" +
|
||||
"<p>Prosto z bazy danych ;D</p>",
|
||||
ContentEng =
|
||||
"<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>" +
|
||||
"<p>Straight from the database ;D</p>",
|
||||
},
|
||||
new StaticPage
|
||||
{
|
||||
AccessName = "info",
|
||||
Title = "Informacje",
|
||||
TitleEng = "Information",
|
||||
Content =
|
||||
"<p>Nowe zmiany: <a href=\"https://pl.wikipedia.org/wiki/Lorem_ipsum\" target=\"_blank\"></p>",
|
||||
ContentEng =
|
||||
"<p>New changes: <a href=\"https://pl.wikipedia.org/wiki/Lorem_ipsum\" target=\"_blank\"></p>",
|
||||
}
|
||||
};
|
||||
await Context.StaticPages.AddRangeAsync(staticPages);
|
||||
await Context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,8 @@ namespace InternshipSystem.Repository
|
||||
{
|
||||
public DbSet<Company> Companies { get; set; }
|
||||
public DbSet<Edition> Editions { get; set; }
|
||||
|
||||
public DbSet<StaticPage> StaticPages { get; set; }
|
||||
public DbSet<InternshipType> InternshipTypes { get; set; }
|
||||
public DbSet<Student> Students { get; set; }
|
||||
|
||||
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
||||
@ -23,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 =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user