merge
This commit is contained in:
commit
5fed86793c
@ -88,7 +88,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
|
|
||||||
[HttpGet("loginEdition")]
|
[HttpGet("loginEdition")]
|
||||||
[Authorize]
|
[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);
|
var edition = await _context.Editions.FindAsync(editionId);
|
||||||
|
|
||||||
|
@ -17,9 +17,12 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
[HttpPost("fill")]
|
[HttpPost("fill")]
|
||||||
public async Task<IActionResult> Fill() {
|
public async Task<IActionResult> Fill()
|
||||||
|
{
|
||||||
await FillerService.FillCompanies();
|
await FillerService.FillCompanies();
|
||||||
|
await FillerService.FillInternshipTypes();
|
||||||
await FillerService.FillEditions();
|
await FillerService.FillEditions();
|
||||||
|
await FillerService.FillStaticPages();
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,11 +32,26 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
await FillerService.FillCompanies();
|
await FillerService.FillCompanies();
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("fill/internshipTypes")]
|
||||||
|
public async Task<IActionResult> FillInternshipTypesAsync()
|
||||||
|
{
|
||||||
|
await FillerService.FillInternshipTypes();
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost("fill/editions")]
|
[HttpPost("fill/editions")]
|
||||||
public async Task<IActionResult> FillEditionsAsync() {
|
public async Task<IActionResult> FillEditionsAsync()
|
||||||
|
{
|
||||||
await FillerService.FillEditions();
|
await FillerService.FillEditions();
|
||||||
return Ok();
|
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.Status404NotFound)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[Authorize(Policy = Policies.RegisteredOnly)]
|
[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 validator = new DocumentPublishRequest.Validator();
|
||||||
var validationResult = await validator.ValidateAsync(documentRequest, cancellationToken);
|
var validationResult = await validator.ValidateAsync(documentRequest, cancellationToken);
|
||||||
@ -45,9 +46,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
return BadRequest(validationResult.ToString());
|
return BadRequest(validationResult.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value);
|
return await _internshipService.AddDocumentToInternship(documentRequest, user.PersonNumber, cancellationToken);
|
||||||
|
|
||||||
return await _internshipService.AddDocumentToInternship(documentRequest, personNumber, cancellationToken);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -38,15 +38,13 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[Authorize]
|
[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 =
|
var editions =
|
||||||
await Context.Editions
|
await Context.Editions
|
||||||
.Where(edition =>
|
.Where(edition =>
|
||||||
edition.Internships
|
edition.Internships
|
||||||
.Any(internship => internship.Student.Id == personNumber))
|
.Any(internship => internship.Student.Id == user.PersonNumber))
|
||||||
.ProjectTo<EditionResult>(Mapper.ConfigurationProvider)
|
.ProjectTo<EditionResult>(Mapper.ConfigurationProvider)
|
||||||
.ToListAsync(token);
|
.ToListAsync(token);
|
||||||
|
|
||||||
@ -74,7 +72,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
var edition =
|
var edition =
|
||||||
await Context.Editions
|
await Context.Editions
|
||||||
.Include(e => e.AvailableSubjects)
|
.Include(e => e.AvailableSubjects)
|
||||||
.Where(e => e.Id == id)
|
.Where(e => e.Id.Equals(id))
|
||||||
.ProjectTo<EditionConfigurationResult>(Mapper.ConfigurationProvider)
|
.ProjectTo<EditionConfigurationResult>(Mapper.ConfigurationProvider)
|
||||||
.FirstOrDefaultAsync(token);
|
.FirstOrDefaultAsync(token);
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<ActionResult> SubmitRegistrationForm([FromBody] RegistrationFormQuery registrationQuery,
|
public async Task<ActionResult> SubmitRegistrationForm([FromBody] RegistrationFormQuery registrationQuery,
|
||||||
CancellationToken cancellationToken)
|
[FromServices] User user, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var validator = new RegistrationFormQuery.Validator();
|
var validator = new RegistrationFormQuery.Validator();
|
||||||
var validationResult = await validator.ValidateAsync(registrationQuery, cancellationToken);
|
var validationResult = await validator.ValidateAsync(registrationQuery, cancellationToken);
|
||||||
@ -46,10 +46,8 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
{
|
{
|
||||||
return BadRequest(validationResult.ToString());
|
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.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[Authorize]
|
[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);
|
var edition = await _context.Editions.FindAsync(registrationCode, token);
|
||||||
|
|
||||||
@ -41,10 +41,8 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value);
|
var student = await _context.Students.FindAsync(user.PersonNumber, token);
|
||||||
|
|
||||||
var student = await _context.Students.FindAsync(personNumber, token);
|
|
||||||
|
|
||||||
edition.RegisterInternship(student);
|
edition.RegisterInternship(student);
|
||||||
await _context.SaveChangesAsync(token);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,12 +22,19 @@ namespace InternshipSystem.Api.ModelBinders
|
|||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
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
|
var user = new User
|
||||||
{
|
{
|
||||||
Name = principal.FindFirst(ClaimTypes.Name).Value,
|
Name = principal.FindFirst(ClaimTypes.Name).Value,
|
||||||
PersonNumber = long.Parse(principal.FindFirst(InternshipClaims.PersonNumber).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);
|
bindingContext.Result = ModelBindingResult.Success(user);
|
||||||
|
@ -10,7 +10,7 @@ namespace InternshipSystem.Api.Queries
|
|||||||
public BranchOfficeForm BranchOffice { get; set; }
|
public BranchOfficeForm BranchOffice { get; set; }
|
||||||
public DateTime? Start { get; set; }
|
public DateTime? Start { get; set; }
|
||||||
public DateTime? End { get; set; }
|
public DateTime? End { get; set; }
|
||||||
public InternshipType? Type { get; set; }
|
public InternshipType Type { get; set; }
|
||||||
|
|
||||||
public class Validator : AbstractValidator<RegistrationFormQuery>
|
public class Validator : AbstractValidator<RegistrationFormQuery>
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ namespace InternshipSystem.Api.Services
|
|||||||
internshipRegistration.Start = registrationQuery.Start ?? internshipRegistration.Start;
|
internshipRegistration.Start = registrationQuery.Start ?? internshipRegistration.Start;
|
||||||
internshipRegistration.End = registrationQuery.End ?? internshipRegistration.End;
|
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");
|
return new BadRequestObjectResult("Edition doesn't have this type of employment in available employments type");
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using InternshipSystem.Core.Commands;
|
using InternshipSystem.Core.Commands;
|
||||||
|
|
||||||
@ -7,7 +7,7 @@ namespace InternshipSystem.Core
|
|||||||
public class Company
|
public class Company
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public Nip Nip { get; set; }
|
public string Nip { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public List<BranchOffice> Branches { get; set; }
|
public List<BranchOffice> Branches { get; set; }
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ namespace InternshipSystem.Core
|
|||||||
public InternshipType AllowedInternshipTypes { get; set; }
|
public InternshipType AllowedInternshipTypes { get; set; }
|
||||||
|
|
||||||
public List<EditionSubject> AvailableSubjects { 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;
|
public bool IsOpen => EditionFinish < DateTime.Today;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ namespace InternshipSystem.Core
|
|||||||
|
|
||||||
public bool IsInternshipTypeAllowed(InternshipType registrationQueryType)
|
public bool IsInternshipTypeAllowed(InternshipType registrationQueryType)
|
||||||
{
|
{
|
||||||
return AvailableInternshipTypes.Select(it => it.InternshipType).Contains(registrationQueryType);
|
return AvailableInternshipTypes.Contains(registrationQueryType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterInternship(Student student)
|
public void RegisterInternship(Student student)
|
||||||
|
@ -5,5 +5,6 @@
|
|||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
public string DescriptionEng { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,10 @@
|
|||||||
using System;
|
namespace InternshipSystem.Core.Entity.Internship
|
||||||
|
|
||||||
namespace InternshipSystem.Core.Entity.Internship
|
|
||||||
{
|
{
|
||||||
[Flags]
|
public class InternshipType
|
||||||
public enum InternshipType : long
|
{
|
||||||
{
|
public long Id { get; set; }
|
||||||
FreeInternship,
|
public string Type { get; set; }
|
||||||
GraduateInternship,
|
public string Description { get; set; }
|
||||||
FreeApprenticeship,
|
public string DescriptionEng { get; set; }
|
||||||
PaidApprenticeship,
|
|
||||||
ForeignInternship,
|
|
||||||
UOP,
|
|
||||||
UD,
|
|
||||||
UZ,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
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 FirstName { get; set; }
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
public string Email { 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();
|
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()
|
public async Task FillEditions()
|
||||||
{
|
{
|
||||||
var editions = new List<Edition>
|
var editions = new List<Edition>
|
||||||
{
|
{
|
||||||
new Edition
|
new Edition
|
||||||
{
|
{
|
||||||
|
Id = Guid.Parse("138da8a3-855c-4b17-9bd2-5f357679efa9"),
|
||||||
EditionStart = new DateTime(2000, 5, 10),
|
EditionStart = new DateTime(2000, 5, 10),
|
||||||
EditionFinish = new DateTime(2000, 11, 10),
|
EditionFinish = new DateTime(2000, 11, 10),
|
||||||
ReportingStart = new DateTime(2000, 9, 30),
|
ReportingStart = new DateTime(2000, 9, 30),
|
||||||
@ -117,21 +175,24 @@ namespace InternshipSystem.Repository
|
|||||||
{
|
{
|
||||||
Subject = new InternshipSubject
|
Subject = new InternshipSubject
|
||||||
{
|
{
|
||||||
Description = "Modelowanie baz danych"
|
Description = "Modelowanie baz danych",
|
||||||
|
DescriptionEng = "Database modeling",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new EditionSubject
|
new EditionSubject
|
||||||
{
|
{
|
||||||
Subject = new InternshipSubject
|
Subject = new InternshipSubject
|
||||||
{
|
{
|
||||||
Description = "Oprogramowywanie kart graficznych"
|
Description = "Oprogramowywanie kart graficznych",
|
||||||
|
DescriptionEng = "Graphics card software",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new EditionSubject
|
new EditionSubject
|
||||||
{
|
{
|
||||||
Subject = new InternshipSubject
|
Subject = new InternshipSubject
|
||||||
{
|
{
|
||||||
Description = "Projektowanie UI"
|
Description = "Projektowanie UI",
|
||||||
|
DescriptionEng = "UI design",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -139,12 +200,12 @@ namespace InternshipSystem.Repository
|
|||||||
{
|
{
|
||||||
Name = "Informatyka",
|
Name = "Informatyka",
|
||||||
},
|
},
|
||||||
AvailableInternshipTypes = new List<EditionInternshipType>
|
AvailableInternshipTypes = new List<InternshipType>
|
||||||
{
|
{
|
||||||
new EditionInternshipType() { InternshipType = InternshipType.UOP },
|
Context.InternshipTypes.First(t => t.Type.Equals("UOP")),
|
||||||
new EditionInternshipType() { InternshipType = InternshipType.UZ },
|
Context.InternshipTypes.First(t => t.Type.Equals("UZ")),
|
||||||
new EditionInternshipType() { InternshipType = InternshipType.UD },
|
Context.InternshipTypes.First(t => t.Type.Equals("UD")),
|
||||||
new EditionInternshipType() { InternshipType = InternshipType.FreeInternship },
|
Context.InternshipTypes.First(t => t.Type.Equals("FreeInternship")),
|
||||||
},
|
},
|
||||||
Internships = new List<Internship>(),
|
Internships = new List<Internship>(),
|
||||||
}
|
}
|
||||||
@ -165,15 +226,15 @@ namespace InternshipSystem.Repository
|
|||||||
},
|
},
|
||||||
InternshipRegistration = new InternshipRegistration
|
InternshipRegistration = new InternshipRegistration
|
||||||
{
|
{
|
||||||
Company = Context.Companies.First(c => c.Id.Equals(1)), //Intel
|
Company = Context.Companies.First(c => c.Name.Equals("Intel")),
|
||||||
Type = InternshipType.UOP,
|
Type = Context.InternshipTypes.First(t => t.Type.Equals("UOP")),
|
||||||
Start = new DateTime(2000, 7, 1),
|
Start = new DateTime(2000, 7, 1),
|
||||||
End = new DateTime(2000, 8, 30),
|
End = new DateTime(2000, 8, 30),
|
||||||
State = DocumentState.Submitted,
|
State = DocumentState.Submitted,
|
||||||
BranchAddress =
|
BranchAddress =
|
||||||
Context.Companies
|
Context.Companies
|
||||||
.Include(c => c.Branches)
|
.Include(c => c.Branches)
|
||||||
.First(c => c.Id.Equals(1))
|
.First(c => c.Name.Equals("Intel"))
|
||||||
.Branches
|
.Branches
|
||||||
.First(),
|
.First(),
|
||||||
},
|
},
|
||||||
@ -214,15 +275,15 @@ namespace InternshipSystem.Repository
|
|||||||
},
|
},
|
||||||
InternshipRegistration = new InternshipRegistration
|
InternshipRegistration = new InternshipRegistration
|
||||||
{
|
{
|
||||||
Company = Context.Companies.First(c => c.Id.Equals(2)), //Asseco
|
Company = Context.Companies.First(c => c.Name.Equals("Asseco Poland")),
|
||||||
Type = InternshipType.UZ,
|
Type = Context.InternshipTypes.First(t => t.Type.Equals("UZ")),
|
||||||
Start = new DateTime(2000, 7, 1),
|
Start = new DateTime(2000, 7, 1),
|
||||||
End = new DateTime(2000, 8, 30),
|
End = new DateTime(2000, 8, 30),
|
||||||
State = DocumentState.Submitted,
|
State = DocumentState.Submitted,
|
||||||
BranchAddress =
|
BranchAddress =
|
||||||
Context.Companies
|
Context.Companies
|
||||||
.Include(c => c.Branches)
|
.Include(c => c.Branches)
|
||||||
.First(c => c.Id.Equals(2))
|
.First(c => c.Name.Equals("Asseco Poland"))
|
||||||
.Branches
|
.Branches
|
||||||
.First(),
|
.First(),
|
||||||
},
|
},
|
||||||
@ -251,45 +312,39 @@ namespace InternshipSystem.Repository
|
|||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
// new InternshipType
|
public async Task FillStaticPages()
|
||||||
// {
|
{
|
||||||
// Type = "FreeInternship",
|
var staticPages = new List<StaticPage>
|
||||||
// Description = "Praktyka bezpłatna",
|
{
|
||||||
// },
|
new StaticPage
|
||||||
// new InternshipType
|
{
|
||||||
// {
|
AccessName = "regulations",
|
||||||
// Type = "GraduateInternship"
|
Title = "Regulamin Praktyk",
|
||||||
// },
|
TitleEng = "Internship Regulations",
|
||||||
// new InternshipType
|
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>" +
|
||||||
// Type = "FreeApprenticeship"
|
"<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>" +
|
||||||
// new InternshipType
|
"<p>Prosto z bazy danych ;D</p>",
|
||||||
// {
|
ContentEng =
|
||||||
// Type = "PaidApprenticeship",
|
"<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>" +
|
||||||
// Description = "np. przemysłowy"
|
"<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>" +
|
||||||
// new InternshipType
|
"<p>Straight from the database ;D</p>",
|
||||||
// {
|
},
|
||||||
// Type = "ForeignInternship",
|
new StaticPage
|
||||||
// Description = "np. IAESTE, ERASMUS"
|
{
|
||||||
// },
|
AccessName = "info",
|
||||||
// new InternshipType
|
Title = "Informacje",
|
||||||
// {
|
TitleEng = "Information",
|
||||||
// Type = "UOP"
|
Content =
|
||||||
// },
|
"<p>Nowe zmiany: <a href=\"https://pl.wikipedia.org/wiki/Lorem_ipsum\" target=\"_blank\"></p>",
|
||||||
// new InternshipType
|
ContentEng =
|
||||||
// {
|
"<p>New changes: <a href=\"https://pl.wikipedia.org/wiki/Lorem_ipsum\" target=\"_blank\"></p>",
|
||||||
// Type = "UD"
|
}
|
||||||
// },
|
};
|
||||||
// new InternshipType
|
await Context.StaticPages.AddRangeAsync(staticPages);
|
||||||
// {
|
await Context.SaveChangesAsync();
|
||||||
// Type = "UZ"
|
}
|
||||||
// },
|
|
||||||
// new InternshipType
|
|
||||||
// {
|
|
||||||
// Type = "Other",
|
|
||||||
// Description = "Należy wprowadzić samodzielnie"
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,8 @@ namespace InternshipSystem.Repository
|
|||||||
{
|
{
|
||||||
public DbSet<Company> Companies { get; set; }
|
public DbSet<Company> Companies { get; set; }
|
||||||
public DbSet<Edition> Editions { 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 DbSet<Student> Students { get; set; }
|
||||||
|
|
||||||
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
||||||
@ -23,21 +24,11 @@ namespace InternshipSystem.Repository
|
|||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.Entity<Company>()
|
|
||||||
.Property(company => company.Nip)
|
|
||||||
.HasConversion<string>(
|
|
||||||
nip => nip,
|
|
||||||
s => (Nip)s);
|
|
||||||
|
|
||||||
modelBuilder.Entity<BranchOffice>()
|
modelBuilder.Entity<BranchOffice>()
|
||||||
.OwnsOne(bo => bo.Address);
|
.OwnsOne(bo => bo.Address);
|
||||||
|
|
||||||
modelBuilder.Entity<InternshipProgram>()
|
modelBuilder.Entity<InternshipProgram>()
|
||||||
.OwnsOne(ip => ip.Mentor)
|
.OwnsOne(ip => ip.Mentor);
|
||||||
.Property(mentor => mentor.PhoneNumber)
|
|
||||||
.HasConversion<string>(
|
|
||||||
number => number,
|
|
||||||
s => (PhoneNumber)s);
|
|
||||||
|
|
||||||
modelBuilder.Entity<ProgramSubject>(builder =>
|
modelBuilder.Entity<ProgramSubject>(builder =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user