whatever
This commit is contained in:
parent
7258c456ff
commit
4549d31b6e
@ -6,6 +6,9 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
CONNECTIONSTRINGS__INTERNSHIPDATABASE: "Host=db.postgres;Port=5432;Database=postgres;Username=postgres;Password=szwoniu"
|
CONNECTIONSTRINGS__INTERNSHIPDATABASE: "Host=db.postgres;Port=5432;Database=postgres;Username=postgres;Password=szwoniu"
|
||||||
ASPNETCORE_ENVIRONMENT: Development
|
ASPNETCORE_ENVIRONMENT: Development
|
||||||
|
ASPNETCORE_URLS: http://+:80
|
||||||
|
SECURITYOPTIONS__SECRET: PDv7DrqznYL6nv7DrqzjnQYO9JxIsWdcjnQYL6nu0f
|
||||||
|
SECURITYOPTIONS__EXPIRATION: 20
|
||||||
depends_on:
|
depends_on:
|
||||||
- db.postgres
|
- db.postgres
|
||||||
ports:
|
ports:
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.OAuth" Version="2.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public static class AuthenticationBuilderExtension
|
||||||
|
{
|
||||||
|
public static AuthenticationBuilder AddMyGut(this AuthenticationBuilder builder) =>
|
||||||
|
builder.AddMyGut(MyGutAuthenticationDefaults.AuthenticationScheme, MyGutAuthenticationDefaults.DisplayName, options => { });
|
||||||
|
|
||||||
|
public static AuthenticationBuilder AddMyGut(
|
||||||
|
this AuthenticationBuilder builder,
|
||||||
|
string scheme,
|
||||||
|
string caption,
|
||||||
|
Action<MyGutAuthenticationOptions> configuration
|
||||||
|
) =>
|
||||||
|
builder.AddOAuth<MyGutAuthenticationOptions, MyGutAuthenticationHandler>(scheme, caption, configuration);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public static class MyGutAuthenticationConstants
|
||||||
|
{
|
||||||
|
public static class Urls
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Claims
|
||||||
|
{
|
||||||
|
public const string AlbumNumber = "urn:mygut:albumnumber";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UrlQueryParameterValues
|
||||||
|
{
|
||||||
|
public const string Consent = "consent";
|
||||||
|
public const string None = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public static class MyGutAuthenticationDefaults
|
||||||
|
{
|
||||||
|
public const string AuthenticationScheme = "MyGut";
|
||||||
|
|
||||||
|
public const string DisplayName = "MyGut";
|
||||||
|
|
||||||
|
public const string Issuer = "MyGut";
|
||||||
|
|
||||||
|
public const string CallbackPath = "/signin-mygut";
|
||||||
|
|
||||||
|
public const string AuthorizationEndpoint = "https://logowanie.pg.edu.pl/login";
|
||||||
|
|
||||||
|
public const string TokenEndpoint = "https://logowanie.pg.edu.pl/login";
|
||||||
|
|
||||||
|
public const string UserInformationEndpoint = "https://logowanie.pg.edu.pl/login";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using Microsoft.AspNetCore.Authentication;
|
||||||
|
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public class MyGutAuthenticationHandler : OAuthHandler<MyGutAuthenticationOptions>
|
||||||
|
{
|
||||||
|
public MyGutAuthenticationHandler(
|
||||||
|
IOptionsMonitor<MyGutAuthenticationOptions> options,
|
||||||
|
ILoggerFactory logger,
|
||||||
|
UrlEncoder encoder,
|
||||||
|
ISystemClock clock) : base(options, logger, encoder, clock)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.OAuth;
|
||||||
|
|
||||||
|
namespace AspNet.Security.OAuth.MyGut
|
||||||
|
{
|
||||||
|
public class MyGutAuthenticationOptions : OAuthOptions
|
||||||
|
{
|
||||||
|
public MyGutAuthenticationOptions()
|
||||||
|
{
|
||||||
|
ClaimsIssuer = MyGutAuthenticationDefaults.Issuer;
|
||||||
|
CallbackPath = MyGutAuthenticationDefaults.CallbackPath;
|
||||||
|
AuthorizationEndpoint = MyGutAuthenticationDefaults.AuthorizationEndpoint;
|
||||||
|
TokenEndpoint = MyGutAuthenticationDefaults.TokenEndpoint;
|
||||||
|
UserInformationEndpoint = MyGutAuthenticationDefaults.UserInformationEndpoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,9 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using InternshipSystem.Api.Queries;
|
using InternshipSystem.Api.Queries;
|
||||||
|
using InternshipSystem.Api.Result;
|
||||||
using InternshipSystem.Core;
|
using InternshipSystem.Core;
|
||||||
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
||||||
|
|
||||||
namespace InternshipSystem.Api
|
namespace InternshipSystem.Api
|
||||||
{
|
{
|
||||||
@ -9,6 +12,15 @@ namespace InternshipSystem.Api
|
|||||||
public ApiProfile()
|
public ApiProfile()
|
||||||
{
|
{
|
||||||
CreateMap<DocumentPublishRequest, Document>();
|
CreateMap<DocumentPublishRequest, Document>();
|
||||||
|
|
||||||
|
CreateMap<Edition, EditionResult>()
|
||||||
|
.ForMember(
|
||||||
|
result => result.Status,
|
||||||
|
opt => opt.MapFrom(edition => edition.IsOpen ? "Open" : "Archival"));
|
||||||
|
|
||||||
|
CreateMap<Edition, EditionConfigurationResult>();
|
||||||
|
|
||||||
|
CreateMap<EditionSubject, InternshipSubject>().IncludeMembers(es => es.Subject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
68
src/InternshipSystem.Api/Controllers/AccessController.cs
Normal file
68
src/InternshipSystem.Api/Controllers/AccessController.cs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using InternshipSystem.Api.Options;
|
||||||
|
using InternshipSystem.Api.Security;
|
||||||
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Controllers
|
||||||
|
{
|
||||||
|
[Route("access")]
|
||||||
|
[ApiController]
|
||||||
|
public class AccessController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly InternshipDbContext _context;
|
||||||
|
private readonly JwtTokenService _tokenService;
|
||||||
|
private readonly SecurityOptions _securityOptions;
|
||||||
|
|
||||||
|
public AccessController(IOptions<SecurityOptions> options, InternshipDbContext context, JwtTokenService tokenService)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_tokenService = tokenService;
|
||||||
|
_securityOptions = options.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet("login")]
|
||||||
|
public async Task<ActionResult> Authenticate(string code, CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
var identity = new ClaimsIdentity(new[]
|
||||||
|
{
|
||||||
|
new Claim(ClaimTypes.Name, "Jan"),
|
||||||
|
new Claim(ClaimTypes.Surname, "Kowalski"),
|
||||||
|
new Claim(InternshipClaims.PersonNumber, "1")
|
||||||
|
});
|
||||||
|
|
||||||
|
return Ok(_tokenService.generateToken(identity));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("loginEdition")]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<ActionResult> LoginIntoEdition(Guid editionId, User user, CancellationToken token)
|
||||||
|
{
|
||||||
|
var edition = await _context.Editions.FindAsync(editionId);
|
||||||
|
|
||||||
|
var hasInternship = await _context.Entry(edition)
|
||||||
|
.Collection(e => e.Internships)
|
||||||
|
.Query()
|
||||||
|
.AnyAsync(i => i.Student.Id == user.PersonNumber, token);
|
||||||
|
|
||||||
|
if (!hasInternship)
|
||||||
|
{
|
||||||
|
return Unauthorized("Student isn't registered for this edition");
|
||||||
|
}
|
||||||
|
|
||||||
|
var newIdentity = User.Identities.First();
|
||||||
|
|
||||||
|
newIdentity.AddClaim(new Claim(InternshipClaims.Edition, editionId.ToString()));
|
||||||
|
|
||||||
|
return Ok(_tokenService.generateToken(newIdentity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using InternshipSystem.Repository;
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
namespace InternshipSystem.Api.Controllers
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using InternshipSystem.Api.Queries;
|
using InternshipSystem.Api.Queries;
|
||||||
|
using InternshipSystem.Api.Security;
|
||||||
using InternshipSystem.Core;
|
using InternshipSystem.Core;
|
||||||
using InternshipSystem.Repository;
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@ -37,7 +41,8 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
public async Task<ActionResult> AddDocumentToInternship([FromBody] DocumentPublishRequest documentRequest)
|
[Authorize(Policy = Policies.RegisteredOnly)]
|
||||||
|
public async Task<ActionResult> AddDocumentToInternship([FromBody] DocumentPublishRequest documentRequest, User user)
|
||||||
{
|
{
|
||||||
var validator = new DocumentPublishRequest.Validator();
|
var validator = new DocumentPublishRequest.Validator();
|
||||||
var validationResult = await validator.ValidateAsync(documentRequest);
|
var validationResult = await validator.ValidateAsync(documentRequest);
|
||||||
@ -47,7 +52,14 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
return BadRequest(validationResult.ToString());
|
return BadRequest(validationResult.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
var studentInternship = await GetCurrentStudentInternship();
|
var edition =
|
||||||
|
await Context.Editions
|
||||||
|
.FindAsync(user.EditionId.Value);
|
||||||
|
|
||||||
|
var internship = await Context.Entry(edition)
|
||||||
|
.Collection(e => e.Internships)
|
||||||
|
.Query()
|
||||||
|
.SingleAsync(i => i.Student.Id == user.PersonNumber);
|
||||||
|
|
||||||
var document = Mapper.Map<Document>(documentRequest);
|
var document = Mapper.Map<Document>(documentRequest);
|
||||||
|
|
||||||
@ -55,7 +67,7 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
studentInternship.UpdateDocument(document);
|
internship.UpdateDocument(document);
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException)
|
catch (InvalidOperationException)
|
||||||
{
|
{
|
||||||
@ -64,24 +76,11 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
studentInternship.AddNewDocument(document);
|
internship.AddNewDocument(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
await Context.SaveChangesAsync();
|
await Context.SaveChangesAsync();
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Internship> GetCurrentStudentInternship()
|
|
||||||
{
|
|
||||||
// TODO: rewrite when authentication will be implemented
|
|
||||||
var edition = await Context
|
|
||||||
.Editions
|
|
||||||
.FirstAsync();
|
|
||||||
|
|
||||||
return await Context.Entry(edition)
|
|
||||||
.Collection(e => e.Internships)
|
|
||||||
.Query()
|
|
||||||
.FirstAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,32 +1,93 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AutoMapper;
|
||||||
|
using AutoMapper.QueryableExtensions;
|
||||||
|
using IdentityServer4.Extensions;
|
||||||
using InternshipSystem.Api.Result;
|
using InternshipSystem.Api.Result;
|
||||||
using InternshipSystem.Core;
|
using InternshipSystem.Api.Security;
|
||||||
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
using InternshipSystem.Repository;
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Controllers
|
namespace InternshipSystem.Api.Controllers
|
||||||
{
|
{
|
||||||
[Route("edition")]
|
[Route("editions")]
|
||||||
public class EditionController : ControllerBase
|
public class EditionController : ControllerBase
|
||||||
{
|
{
|
||||||
private InternshipDbContext Context { get; }
|
private InternshipDbContext Context { get; }
|
||||||
|
private IMapper Mapper { get; }
|
||||||
|
|
||||||
public EditionController(InternshipDbContext context)
|
public EditionController(InternshipDbContext context, IMapper mapper)
|
||||||
{
|
{
|
||||||
Context = context;
|
Context = context;
|
||||||
|
Mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get current edition parameters
|
/// Get accessible editions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <response code="200">Parameters of edition registered for by student</response>
|
/// <response code="200">Editions accessible by the current user</response>
|
||||||
/// <response code="401">This action is only available for authorized student registered for current edition</response>
|
/// <response code="401">This action is only available for authorized student</response>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<EditionResult>> GetCurrentEdition() =>
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
throw new NotImplementedException();
|
[Authorize]
|
||||||
|
public async Task<ActionResult<IList<EditionResult>>> GetAvailableEditions(CancellationToken token)
|
||||||
|
{
|
||||||
|
var personNumber = long.Parse(User.FindFirst("PersonNumber").Value);
|
||||||
|
|
||||||
|
var editions =
|
||||||
|
await Context.Editions
|
||||||
|
.Where(edition =>
|
||||||
|
edition.Internships
|
||||||
|
.Any(internship => internship.Student.Id == personNumber))
|
||||||
|
.ProjectTo<EditionResult>(Mapper.ConfigurationProvider)
|
||||||
|
.ToListAsync(token);
|
||||||
|
|
||||||
|
if (editions.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(editions);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get edition's configuration
|
||||||
|
/// </summary>
|
||||||
|
/// <response code="200">Parameters of edition registered for by student</response>
|
||||||
|
/// <response code="401">This action is only available for authorized student registered for this edition edition</response>
|
||||||
|
/// <response code="404">Specified edition doesn't exist</response>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
|
[Authorize(Policy = "RegisteredForEditionOnly")]
|
||||||
|
public async Task<ActionResult<EditionConfigurationResult>> GetEditionsConfiguration(Guid id, CancellationToken token)
|
||||||
|
{
|
||||||
|
var personNumber = long.Parse(User.FindFirst(InternshipClaims.PersonNumber).Value);
|
||||||
|
|
||||||
|
var edition =
|
||||||
|
await Context.Editions
|
||||||
|
.Include(e => e.AvailableSubjects)
|
||||||
|
.Where(e => e.Id == id)
|
||||||
|
.ProjectTo<EditionConfigurationResult>(Mapper.ConfigurationProvider)
|
||||||
|
.FirstOrDefaultAsync(token);
|
||||||
|
|
||||||
|
if (edition == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(edition);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using InternshipSystem.Api.Result;
|
using InternshipSystem.Api.Result;
|
||||||
|
using InternshipSystem.Api.Security;
|
||||||
|
using InternshipSystem.Core;
|
||||||
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@ -10,6 +15,13 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[Route("register")]
|
[Route("register")]
|
||||||
public class RegistrationController : ControllerBase
|
public class RegistrationController : ControllerBase
|
||||||
{
|
{
|
||||||
|
private readonly InternshipDbContext _context;
|
||||||
|
|
||||||
|
public RegistrationController(InternshipDbContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Register student for edition using provided registration code
|
/// Register student for edition using provided registration code
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -22,9 +34,23 @@ namespace InternshipSystem.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<IActionResult> RegisterStudentForEdition([FromBody] Guid registrationCode) =>
|
[Authorize]
|
||||||
throw new NotImplementedException();
|
public async Task<IActionResult> RegisterStudentForEdition([FromBody] Guid registrationCode, User user, CancellationToken token)
|
||||||
|
{
|
||||||
|
var edition = await _context.Editions.FindAsync(registrationCode);
|
||||||
|
|
||||||
|
if (edition == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
var student = await _context.Students.FindAsync(user.PersonNumber);
|
||||||
|
|
||||||
|
edition.RegisterInternship(student);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,7 +13,8 @@ COPY . ./
|
|||||||
RUN dotnet publish ./InternshipSystem.Api -c Release -o out
|
RUN dotnet publish ./InternshipSystem.Api -c Release -o out
|
||||||
|
|
||||||
# Build runtime image
|
# Build runtime image
|
||||||
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
|
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
|
||||||
|
RUN curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l /vsdbg
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build-env /app/out .
|
COPY --from=build-env /app/out .
|
||||||
ENTRYPOINT ["dotnet", "./InternshipSystem.Api.dll"]
|
ENTRYPOINT ["dotnet", "./InternshipSystem.Api.dll"]
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
using System.Text;
|
||||||
|
using InternshipSystem.Api.Options;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Extensions
|
||||||
|
{
|
||||||
|
public static class ServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddStudentAuthentication(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
var options = services.BuildServiceProvider().GetService<IOptions<SecurityOptions>>().Value;
|
||||||
|
|
||||||
|
services
|
||||||
|
.AddAuthentication(options =>
|
||||||
|
{
|
||||||
|
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
})
|
||||||
|
.AddJwtBearer(o =>
|
||||||
|
{
|
||||||
|
o.TokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(options.Secret)),
|
||||||
|
ValidateAudience = false,
|
||||||
|
ValidateIssuer = false
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../InternshipSystem.Core/InternshipSystem.Core.csproj" />
|
<ProjectReference Include="../InternshipSystem.Core/InternshipSystem.Core.csproj" />
|
||||||
<ProjectReference Include="../InternshipSystem.Repository/InternshipSystem.Repository.csproj" />
|
<ProjectReference Include="../InternshipSystem.Repository/InternshipSystem.Repository.csproj" />
|
||||||
|
<ProjectReference Include="..\AspNet.Security.OAuth.MyGut\AspNet.Security.OAuth.MyGut.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
37
src/InternshipSystem.Api/ModelBinders/UserBinder.cs
Normal file
37
src/InternshipSystem.Api/ModelBinders/UserBinder.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using InternshipSystem.Api.Security;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.ModelBinders
|
||||||
|
{
|
||||||
|
public class UserBinder : IModelBinder
|
||||||
|
{
|
||||||
|
public Task BindModelAsync(ModelBindingContext bindingContext)
|
||||||
|
{
|
||||||
|
if (bindingContext == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(bindingContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
var principal = bindingContext.HttpContext.User;
|
||||||
|
|
||||||
|
if (principal == null)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
bindingContext.Result = ModelBindingResult.Success(user);
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
src/InternshipSystem.Api/ModelBinders/UserBinderProvider.cs
Normal file
25
src/InternshipSystem.Api/ModelBinders/UserBinderProvider.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using InternshipSystem.Api.Security;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.ModelBinders
|
||||||
|
{
|
||||||
|
public class UserBinderProvider : IModelBinderProvider
|
||||||
|
{
|
||||||
|
public IModelBinder GetBinder(ModelBinderProviderContext context)
|
||||||
|
{
|
||||||
|
if (context == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.Metadata.ModelType == typeof(User))
|
||||||
|
{
|
||||||
|
return new BinderTypeModelBinder(typeof(UserBinder));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
src/InternshipSystem.Api/Options/SecurityOptions.cs
Normal file
8
src/InternshipSystem.Api/Options/SecurityOptions.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace InternshipSystem.Api.Options
|
||||||
|
{
|
||||||
|
public class SecurityOptions
|
||||||
|
{
|
||||||
|
public string Secret { get; set; }
|
||||||
|
public double Expiration { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using InternshipSystem.Core.Entity.Internship;
|
||||||
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Result
|
||||||
|
{
|
||||||
|
public class EditionConfigurationResult
|
||||||
|
{
|
||||||
|
public List<InternshipSubject> AvailableSubjects { get; set; }
|
||||||
|
public DateTime EditionStart { get; set; }
|
||||||
|
public DateTime EditionFinish { get; set; }
|
||||||
|
public DateTime ReportingStart { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
using InternshipSystem.Core;
|
|
||||||
using InternshipSystem.Core.Entity.Internship;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Api.Result
|
namespace InternshipSystem.Api.Result
|
||||||
{
|
{
|
||||||
public struct EditionResult
|
public struct EditionResult
|
||||||
{
|
{
|
||||||
public List<InternshipType> Types { get; set; }
|
public Guid Id { get; set; }
|
||||||
public List<InternshipSubject> Subjects { get; set; }
|
public DateTime EditionStart { get; set; }
|
||||||
public Student Student { get; set; }
|
public DateTime EditionFinish { get; set; }
|
||||||
|
public string CourseName { get; set; }
|
||||||
|
public string Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
9
src/InternshipSystem.Api/Security/InternshipClaims.cs
Normal file
9
src/InternshipSystem.Api/Security/InternshipClaims.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace InternshipSystem.Api.Security
|
||||||
|
{
|
||||||
|
public static class InternshipClaims
|
||||||
|
{
|
||||||
|
public static string Edition = "Edition";
|
||||||
|
|
||||||
|
public static string PersonNumber = "PersonNumber";
|
||||||
|
}
|
||||||
|
}
|
37
src/InternshipSystem.Api/Security/JwtTokenService.cs
Normal file
37
src/InternshipSystem.Api/Security/JwtTokenService.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
|
using System.Security.Claims;
|
||||||
|
using System.Text;
|
||||||
|
using InternshipSystem.Api.Options;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Security
|
||||||
|
{
|
||||||
|
public class JwtTokenService
|
||||||
|
{
|
||||||
|
private SecurityOptions _securityOptions;
|
||||||
|
|
||||||
|
public JwtTokenService(IOptions<SecurityOptions> securityOptions)
|
||||||
|
{
|
||||||
|
_securityOptions = securityOptions.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string generateToken(ClaimsIdentity identity)
|
||||||
|
{
|
||||||
|
var handler = new JwtSecurityTokenHandler();
|
||||||
|
var key = Encoding.ASCII.GetBytes(_securityOptions.Secret);
|
||||||
|
|
||||||
|
var descriptor = new SecurityTokenDescriptor
|
||||||
|
{
|
||||||
|
Subject = identity,
|
||||||
|
Expires = DateTime.UtcNow.AddMinutes(_securityOptions.Expiration),
|
||||||
|
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
|
||||||
|
};
|
||||||
|
|
||||||
|
var jwtToken = handler.CreateJwtSecurityToken(descriptor);
|
||||||
|
|
||||||
|
return handler.WriteToken(jwtToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
src/InternshipSystem.Api/Security/Policies.cs
Normal file
7
src/InternshipSystem.Api/Security/Policies.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace InternshipSystem.Api.Security
|
||||||
|
{
|
||||||
|
public static class Policies
|
||||||
|
{
|
||||||
|
public const string RegisteredOnly = "RegisteredForEditionOnly";
|
||||||
|
}
|
||||||
|
}
|
12
src/InternshipSystem.Api/Security/User.cs
Normal file
12
src/InternshipSystem.Api/Security/User.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Api.Security
|
||||||
|
{
|
||||||
|
public class User
|
||||||
|
{
|
||||||
|
public long PersonNumber { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public Guid? EditionId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
7
src/InternshipSystem.Api/Services/UserService.cs
Normal file
7
src/InternshipSystem.Api/Services/UserService.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace InternshipSystem.Api.Services
|
||||||
|
{
|
||||||
|
public class UserService
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,10 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using InternshipSystem.Api.Extensions;
|
||||||
|
using InternshipSystem.Api.ModelBinders;
|
||||||
|
using InternshipSystem.Api.Options;
|
||||||
|
using InternshipSystem.Api.Security;
|
||||||
using InternshipSystem.Repository;
|
using InternshipSystem.Repository;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
@ -22,6 +26,7 @@ namespace InternshipSystem.Api
|
|||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services) =>
|
public void ConfigureServices(IServiceCollection services) =>
|
||||||
services
|
services
|
||||||
|
.Configure<SecurityOptions>(Configuration.GetSection("SecurityOptions"))
|
||||||
.AddDbContext<InternshipDbContext>(o => o.UseNpgsql(Configuration.GetConnectionString("InternshipDatabase")))
|
.AddDbContext<InternshipDbContext>(o => o.UseNpgsql(Configuration.GetConnectionString("InternshipDatabase")))
|
||||||
.AddSwaggerGen(options =>
|
.AddSwaggerGen(options =>
|
||||||
{
|
{
|
||||||
@ -31,8 +36,17 @@ namespace InternshipSystem.Api
|
|||||||
options.IncludeXmlComments(xmlPath);
|
options.IncludeXmlComments(xmlPath);
|
||||||
})
|
})
|
||||||
.AddScoped<DatabaseFiller>()
|
.AddScoped<DatabaseFiller>()
|
||||||
|
.AddScoped<JwtTokenService>()
|
||||||
.AddAutoMapper(cfg => cfg.AddProfile<ApiProfile>())
|
.AddAutoMapper(cfg => cfg.AddProfile<ApiProfile>())
|
||||||
.AddControllers()
|
.AddStudentAuthentication()
|
||||||
|
.AddAuthorization(o =>
|
||||||
|
{
|
||||||
|
o.AddPolicy(Policies.RegisteredOnly, policy => policy.RequireClaim("Edition"));
|
||||||
|
})
|
||||||
|
.AddControllers(o =>
|
||||||
|
{
|
||||||
|
o.ModelBinderProviders.Insert(0, new UserBinderProvider());
|
||||||
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
@ -43,16 +57,17 @@ namespace InternshipSystem.Api
|
|||||||
}
|
}
|
||||||
|
|
||||||
app
|
app
|
||||||
.UseSwagger()
|
|
||||||
.UseSwaggerUI(options => options.SwaggerEndpoint(Path.Join(Configuration.GetValue<string>("ApiPrefix"), "/swagger/v1/swagger.json"), "InternshipSystem Api"))
|
|
||||||
.UseHttpsRedirection()
|
.UseHttpsRedirection()
|
||||||
.UseRouting()
|
.UseRouting()
|
||||||
|
.UseAuthentication()
|
||||||
.UseAuthorization()
|
.UseAuthorization()
|
||||||
.UseCors()
|
.UseCors()
|
||||||
.UseEndpoints(endpoints =>
|
.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapControllers();
|
endpoints.MapControllers();
|
||||||
});
|
})
|
||||||
|
.UseSwagger()
|
||||||
|
.UseSwaggerUI(options => options.SwaggerEndpoint(Path.Join(Configuration.GetValue<string>("ApiPrefix"), "/swagger/v1/swagger.json"), "InternshipSystem Api"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ namespace InternshipSystem.Core
|
|||||||
public List<Internship> Internships { get; set; }
|
public List<Internship> Internships { get; set; }
|
||||||
public List<EditionSubject> AvailableSubjects { get; set; }
|
public List<EditionSubject> AvailableSubjects { get; set; }
|
||||||
|
|
||||||
|
public bool IsOpen => EditionFinish < DateTime.Today;
|
||||||
|
|
||||||
public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart)
|
public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart)
|
||||||
{
|
{
|
||||||
return new Edition
|
return new Edition
|
||||||
@ -24,5 +26,12 @@ namespace InternshipSystem.Core
|
|||||||
ReportingStart = reportingStart
|
ReportingStart = reportingStart
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RegisterInternship(Student student)
|
||||||
|
{
|
||||||
|
var internship = Internship.CreateStudentsInternship(student);
|
||||||
|
|
||||||
|
Internships.Add(internship);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,6 +13,7 @@ namespace InternshipSystem.Core
|
|||||||
public Report Report { get; set; }
|
public Report Report { get; set; }
|
||||||
public List<Document> Approvals { get; set; }
|
public List<Document> Approvals { get; set; }
|
||||||
public List<Document> Documentation { get; set; }
|
public List<Document> Documentation { get; set; }
|
||||||
|
public float? Grade { get; set; }
|
||||||
|
|
||||||
public void UpdateDocument(Document document)
|
public void UpdateDocument(Document document)
|
||||||
{
|
{
|
||||||
@ -30,5 +31,20 @@ namespace InternshipSystem.Core
|
|||||||
|
|
||||||
Documentation.Add(document);
|
Documentation.Add(document);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Internship CreateStudentsInternship(Student student)
|
||||||
|
{
|
||||||
|
var internship = new Internship();
|
||||||
|
|
||||||
|
internship.Student = student;
|
||||||
|
|
||||||
|
internship.InternshipRegistration = InternshipRegistration.Create();
|
||||||
|
internship.InternshipProgram = InternshipProgram.Create();
|
||||||
|
internship.Report = Report.Create();
|
||||||
|
internship.Approvals = new List<Document>();
|
||||||
|
internship.Documentation = new List<Document>();
|
||||||
|
|
||||||
|
return internship;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,5 +10,10 @@ namespace InternshipSystem.Core
|
|||||||
public Mentor Mentor { get; set; }
|
public Mentor Mentor { get; set; }
|
||||||
public DocumentState State { get; set; }
|
public DocumentState State { get; set; }
|
||||||
public List<ProgramSubject> ChosenSubjects { get; set; }
|
public List<ProgramSubject> ChosenSubjects { get; set; }
|
||||||
|
|
||||||
|
public static InternshipProgram Create()
|
||||||
|
{
|
||||||
|
return new InternshipProgram();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,5 +12,10 @@ namespace InternshipSystem.Core
|
|||||||
public DateTime End { get; set; }
|
public DateTime End { get; set; }
|
||||||
public InternshipType Type { get; set; }
|
public InternshipType Type { get; set; }
|
||||||
public DocumentState State { get; set; }
|
public DocumentState State { get; set; }
|
||||||
|
|
||||||
|
public static InternshipRegistration Create()
|
||||||
|
{
|
||||||
|
return new InternshipRegistration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,5 +4,10 @@
|
|||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public DocumentState State { get; set; }
|
public DocumentState State { get; set; }
|
||||||
|
|
||||||
|
public static Report Create()
|
||||||
|
{
|
||||||
|
return new Report();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +0,0 @@
|
|||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core.Interface.Repository
|
|
||||||
{
|
|
||||||
public interface IInternshipRepository
|
|
||||||
{
|
|
||||||
Task SaveInternship(Internship internship, CancellationToken token);
|
|
||||||
Task<Internship> GetStudentsInternship(Student student, CancellationToken token);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace InternshipSystem.Core.Interface.Repository
|
|
||||||
{
|
|
||||||
public interface IStudentRepository
|
|
||||||
{
|
|
||||||
Task<Student> GetAlbumNumber(int album, CancellationToken token);
|
|
||||||
Task SaveStudent(Student student, CancellationToken token);
|
|
||||||
}
|
|
||||||
}
|
|
10
src/InternshipSystem.Core/ValueObject/InternshipStatus.cs
Normal file
10
src/InternshipSystem.Core/ValueObject/InternshipStatus.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace InternshipSystem.Core.ValueObject
|
||||||
|
{
|
||||||
|
public enum InternshipStatus
|
||||||
|
{
|
||||||
|
Incomplete,
|
||||||
|
InProcess,
|
||||||
|
Graded,
|
||||||
|
Archival
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,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<Student> Students { get; set; }
|
||||||
|
|
||||||
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
|
||||||
: base(options)
|
: base(options)
|
||||||
{
|
{
|
||||||
|
609
src/InternshipSystem.Repository/Migrations/20200828182238_Init.Designer.cs
generated
Normal file
609
src/InternshipSystem.Repository/Migrations/20200828182238_Init.Designer.cs
generated
Normal file
@ -0,0 +1,609 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Repository.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(InternshipDbContext))]
|
||||||
|
[Migration("20200828182238_Init")]
|
||||||
|
partial class Init
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
|
||||||
|
.HasAnnotation("ProductVersion", "3.1.4")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<long?>("CompanyId")
|
||||||
|
.HasColumnName("company_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_branch_office");
|
||||||
|
|
||||||
|
b.HasIndex("CompanyId")
|
||||||
|
.HasName("ix_branch_office_company_id");
|
||||||
|
|
||||||
|
b.ToTable("branch_office");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Company", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnName("name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Nip")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnName("nip")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Range")
|
||||||
|
.HasColumnName("range")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("SiteAddress")
|
||||||
|
.HasColumnName("site_address")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_companies");
|
||||||
|
|
||||||
|
b.ToTable("companies");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Course", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnName("name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_course");
|
||||||
|
|
||||||
|
b.ToTable("course");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnName("description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long?>("InternshipId")
|
||||||
|
.HasColumnName("internship_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("InternshipId1")
|
||||||
|
.HasColumnName("internship_id1")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("RejectionReason")
|
||||||
|
.HasColumnName("rejection_reason")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Scan")
|
||||||
|
.HasColumnName("scan")
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnName("state")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnName("type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_document");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipId")
|
||||||
|
.HasName("ix_document_internship_id");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipId1")
|
||||||
|
.HasName("ix_document_internship_id1");
|
||||||
|
|
||||||
|
b.ToTable("document");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<long?>("CourseId")
|
||||||
|
.HasColumnName("course_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EditionFinish")
|
||||||
|
.HasColumnName("edition_finish")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EditionStart")
|
||||||
|
.HasColumnName("edition_start")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ReportingStart")
|
||||||
|
.HasColumnName("reporting_start")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_editions");
|
||||||
|
|
||||||
|
b.HasIndex("CourseId")
|
||||||
|
.HasName("ix_editions_course_id");
|
||||||
|
|
||||||
|
b.ToTable("editions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipSubject", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnName("description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship_subject");
|
||||||
|
|
||||||
|
b.ToTable("internship_subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnName("description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.HasColumnName("type")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship_type");
|
||||||
|
|
||||||
|
b.ToTable("internship_type");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<Guid?>("EditionId")
|
||||||
|
.HasColumnName("edition_id")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<float>("Grade")
|
||||||
|
.HasColumnName("grade")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<long?>("InternshipProgramId")
|
||||||
|
.HasColumnName("internship_program_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("InternshipRegistrationId")
|
||||||
|
.HasColumnName("internship_registration_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("ReportId")
|
||||||
|
.HasColumnName("report_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("StudentId")
|
||||||
|
.HasColumnName("student_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship");
|
||||||
|
|
||||||
|
b.HasIndex("EditionId")
|
||||||
|
.HasName("ix_internship_edition_id");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipProgramId")
|
||||||
|
.HasName("ix_internship_internship_program_id");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipRegistrationId")
|
||||||
|
.HasName("ix_internship_internship_registration_id");
|
||||||
|
|
||||||
|
b.HasIndex("ReportId")
|
||||||
|
.HasName("ix_internship_report_id");
|
||||||
|
|
||||||
|
b.HasIndex("StudentId")
|
||||||
|
.HasName("ix_internship_student_id");
|
||||||
|
|
||||||
|
b.ToTable("internship");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnName("state")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship_program");
|
||||||
|
|
||||||
|
b.ToTable("internship_program");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<long?>("BranchAddressId")
|
||||||
|
.HasColumnName("branch_address_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("CompanyId")
|
||||||
|
.HasColumnName("company_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("End")
|
||||||
|
.HasColumnName("end")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Start")
|
||||||
|
.HasColumnName("start")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnName("state")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<long?>("TypeId")
|
||||||
|
.HasColumnName("type_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship_registration");
|
||||||
|
|
||||||
|
b.HasIndex("BranchAddressId")
|
||||||
|
.HasName("ix_internship_registration_branch_address_id");
|
||||||
|
|
||||||
|
b.HasIndex("CompanyId")
|
||||||
|
.HasName("ix_internship_registration_company_id");
|
||||||
|
|
||||||
|
b.HasIndex("TypeId")
|
||||||
|
.HasName("ix_internship_registration_type_id");
|
||||||
|
|
||||||
|
b.ToTable("internship_registration");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnName("state")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_report");
|
||||||
|
|
||||||
|
b.ToTable("report");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Student", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<int>("AlbumNumber")
|
||||||
|
.HasColumnName("album_number")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnName("email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.HasColumnName("first_name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.HasColumnName("last_name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Semester")
|
||||||
|
.HasColumnName("semester")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_student");
|
||||||
|
|
||||||
|
b.ToTable("student");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("EditionId")
|
||||||
|
.HasColumnName("edition_id")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<long>("InternshipSubjectId")
|
||||||
|
.HasColumnName("internship_subject_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("EditionId", "InternshipSubjectId")
|
||||||
|
.HasName("pk_edition_subject");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipSubjectId")
|
||||||
|
.HasName("ix_edition_subject_internship_subject_id");
|
||||||
|
|
||||||
|
b.ToTable("edition_subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("InternshipProgramId")
|
||||||
|
.HasColumnName("internship_program_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("InternshipSubjectId")
|
||||||
|
.HasColumnName("internship_subject_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("InternshipProgramId", "InternshipSubjectId")
|
||||||
|
.HasName("pk_program_subject");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipSubjectId")
|
||||||
|
.HasName("ix_program_subject_internship_subject_id");
|
||||||
|
|
||||||
|
b.ToTable("program_subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Company", null)
|
||||||
|
.WithMany("Branches")
|
||||||
|
.HasForeignKey("CompanyId")
|
||||||
|
.HasConstraintName("fk_branch_office_companies_company_id");
|
||||||
|
|
||||||
|
b.OwnsOne("InternshipSystem.Core.BranchAddress", "Address", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("BranchOfficeId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b1.Property<string>("Building")
|
||||||
|
.HasColumnName("building")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("City")
|
||||||
|
.HasColumnName("city")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("Country")
|
||||||
|
.HasColumnName("country")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("PostalCode")
|
||||||
|
.HasColumnName("postal_code")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("Street")
|
||||||
|
.HasColumnName("street")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.HasKey("BranchOfficeId")
|
||||||
|
.HasName("pk_branch_office");
|
||||||
|
|
||||||
|
b1.ToTable("branch_office");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("BranchOfficeId")
|
||||||
|
.HasConstraintName("fk_branch_address_branch_office_branch_office_id");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Internship", null)
|
||||||
|
.WithMany("Approvals")
|
||||||
|
.HasForeignKey("InternshipId")
|
||||||
|
.HasConstraintName("fk_document_internship_internship_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Internship", null)
|
||||||
|
.WithMany("Documentation")
|
||||||
|
.HasForeignKey("InternshipId1")
|
||||||
|
.HasConstraintName("fk_document_internship_internship_id1");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Course", "Course")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CourseId")
|
||||||
|
.HasConstraintName("fk_editions_course_course_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Edition", null)
|
||||||
|
.WithMany("Internships")
|
||||||
|
.HasForeignKey("EditionId")
|
||||||
|
.HasConstraintName("fk_internship_editions_edition_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.InternshipProgram", "InternshipProgram")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InternshipProgramId")
|
||||||
|
.HasConstraintName("fk_internship_internship_program_internship_program_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.InternshipRegistration", "InternshipRegistration")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InternshipRegistrationId")
|
||||||
|
.HasConstraintName("fk_internship_internship_registration_internship_registration_");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Report", "Report")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ReportId")
|
||||||
|
.HasConstraintName("fk_internship_report_report_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Student", "Student")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("StudentId")
|
||||||
|
.HasConstraintName("fk_internship_student_student_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", b =>
|
||||||
|
{
|
||||||
|
b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("InternshipProgramId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b1.Property<string>("Email")
|
||||||
|
.HasColumnName("email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("FirstName")
|
||||||
|
.HasColumnName("first_name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("LastName")
|
||||||
|
.HasColumnName("last_name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("PhoneNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnName("mentor_phone_number")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.HasKey("InternshipProgramId")
|
||||||
|
.HasName("pk_internship_program");
|
||||||
|
|
||||||
|
b1.ToTable("internship_program");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("InternshipProgramId")
|
||||||
|
.HasConstraintName("fk_mentor_internship_program_internship_program_id");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.BranchOffice", "BranchAddress")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("BranchAddressId")
|
||||||
|
.HasConstraintName("fk_internship_registration_branch_office_branch_address_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Company", "Company")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CompanyId")
|
||||||
|
.HasConstraintName("fk_internship_registration_companies_company_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "Type")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("TypeId")
|
||||||
|
.HasConstraintName("fk_internship_registration_internship_type_type_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
||||||
|
.WithMany("AvailableSubjects")
|
||||||
|
.HasForeignKey("EditionId")
|
||||||
|
.HasConstraintName("fk_edition_subject_editions_edition_id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InternshipSubjectId")
|
||||||
|
.HasConstraintName("fk_edition_subject_internship_subject_internship_subject_id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.InternshipProgram", "Program")
|
||||||
|
.WithMany("ChosenSubjects")
|
||||||
|
.HasForeignKey("InternshipProgramId")
|
||||||
|
.HasConstraintName("fk_program_subject_internship_program_internship_program_id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InternshipSubjectId")
|
||||||
|
.HasConstraintName("fk_program_subject_internship_subject_internship_subject_id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,438 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Repository.Migrations
|
||||||
|
{
|
||||||
|
public partial class Init : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "companies",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
nip = table.Column<string>(nullable: false),
|
||||||
|
name = table.Column<string>(nullable: true),
|
||||||
|
range = table.Column<int>(nullable: false),
|
||||||
|
site_address = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_companies", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "course",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
name = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_course", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "internship_program",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
first_name = table.Column<string>(nullable: true),
|
||||||
|
last_name = table.Column<string>(nullable: true),
|
||||||
|
email = table.Column<string>(nullable: true),
|
||||||
|
mentor_phone_number = table.Column<string>(nullable: true),
|
||||||
|
state = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_internship_program", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "internship_subject",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
description = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_internship_subject", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "internship_type",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
type = table.Column<string>(nullable: true),
|
||||||
|
description = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_internship_type", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "report",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
state = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_report", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "student",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
album_number = table.Column<int>(nullable: false),
|
||||||
|
first_name = table.Column<string>(nullable: true),
|
||||||
|
last_name = table.Column<string>(nullable: true),
|
||||||
|
email = table.Column<string>(nullable: true),
|
||||||
|
semester = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_student", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "branch_office",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
street = table.Column<string>(nullable: true),
|
||||||
|
building = table.Column<string>(nullable: true),
|
||||||
|
city = table.Column<string>(nullable: true),
|
||||||
|
postal_code = table.Column<string>(nullable: true),
|
||||||
|
country = table.Column<string>(nullable: true),
|
||||||
|
company_id = table.Column<long>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_branch_office", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_branch_office_companies_company_id",
|
||||||
|
column: x => x.company_id,
|
||||||
|
principalTable: "companies",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "editions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<Guid>(nullable: false),
|
||||||
|
edition_start = table.Column<DateTime>(nullable: false),
|
||||||
|
edition_finish = table.Column<DateTime>(nullable: false),
|
||||||
|
reporting_start = table.Column<DateTime>(nullable: false),
|
||||||
|
course_id = table.Column<long>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_editions", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_editions_course_course_id",
|
||||||
|
column: x => x.course_id,
|
||||||
|
principalTable: "course",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "program_subject",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
internship_program_id = table.Column<long>(nullable: false),
|
||||||
|
internship_subject_id = table.Column<long>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_program_subject", x => new { x.internship_program_id, x.internship_subject_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_program_subject_internship_program_internship_program_id",
|
||||||
|
column: x => x.internship_program_id,
|
||||||
|
principalTable: "internship_program",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_program_subject_internship_subject_internship_subject_id",
|
||||||
|
column: x => x.internship_subject_id,
|
||||||
|
principalTable: "internship_subject",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "internship_registration",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
company_id = table.Column<long>(nullable: true),
|
||||||
|
branch_address_id = table.Column<long>(nullable: true),
|
||||||
|
start = table.Column<DateTime>(nullable: false),
|
||||||
|
end = table.Column<DateTime>(nullable: false),
|
||||||
|
type_id = table.Column<long>(nullable: true),
|
||||||
|
state = table.Column<int>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_internship_registration", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_internship_registration_branch_office_branch_address_id",
|
||||||
|
column: x => x.branch_address_id,
|
||||||
|
principalTable: "branch_office",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_internship_registration_companies_company_id",
|
||||||
|
column: x => x.company_id,
|
||||||
|
principalTable: "companies",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_internship_registration_internship_type_type_id",
|
||||||
|
column: x => x.type_id,
|
||||||
|
principalTable: "internship_type",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "edition_subject",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
edition_id = table.Column<Guid>(nullable: false),
|
||||||
|
internship_subject_id = table.Column<long>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_edition_subject", x => new { x.edition_id, x.internship_subject_id });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_edition_subject_editions_edition_id",
|
||||||
|
column: x => x.edition_id,
|
||||||
|
principalTable: "editions",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_edition_subject_internship_subject_internship_subject_id",
|
||||||
|
column: x => x.internship_subject_id,
|
||||||
|
principalTable: "internship_subject",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "internship",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
student_id = table.Column<long>(nullable: true),
|
||||||
|
internship_registration_id = table.Column<long>(nullable: true),
|
||||||
|
internship_program_id = table.Column<long>(nullable: true),
|
||||||
|
report_id = table.Column<long>(nullable: true),
|
||||||
|
grade = table.Column<float>(nullable: false),
|
||||||
|
edition_id = table.Column<Guid>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_internship", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_internship_editions_edition_id",
|
||||||
|
column: x => x.edition_id,
|
||||||
|
principalTable: "editions",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_internship_internship_program_internship_program_id",
|
||||||
|
column: x => x.internship_program_id,
|
||||||
|
principalTable: "internship_program",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_internship_internship_registration_internship_registration_",
|
||||||
|
column: x => x.internship_registration_id,
|
||||||
|
principalTable: "internship_registration",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_internship_report_report_id",
|
||||||
|
column: x => x.report_id,
|
||||||
|
principalTable: "report",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_internship_student_student_id",
|
||||||
|
column: x => x.student_id,
|
||||||
|
principalTable: "student",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "document",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
description = table.Column<string>(nullable: true),
|
||||||
|
scan = table.Column<byte[]>(nullable: true),
|
||||||
|
type = table.Column<int>(nullable: false),
|
||||||
|
state = table.Column<int>(nullable: false),
|
||||||
|
rejection_reason = table.Column<string>(nullable: true),
|
||||||
|
internship_id = table.Column<long>(nullable: true),
|
||||||
|
internship_id1 = table.Column<long>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("pk_document", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_document_internship_internship_id",
|
||||||
|
column: x => x.internship_id,
|
||||||
|
principalTable: "internship",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "fk_document_internship_internship_id1",
|
||||||
|
column: x => x.internship_id1,
|
||||||
|
principalTable: "internship",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_branch_office_company_id",
|
||||||
|
table: "branch_office",
|
||||||
|
column: "company_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_document_internship_id",
|
||||||
|
table: "document",
|
||||||
|
column: "internship_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_document_internship_id1",
|
||||||
|
table: "document",
|
||||||
|
column: "internship_id1");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_edition_subject_internship_subject_id",
|
||||||
|
table: "edition_subject",
|
||||||
|
column: "internship_subject_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_editions_course_id",
|
||||||
|
table: "editions",
|
||||||
|
column: "course_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internship_edition_id",
|
||||||
|
table: "internship",
|
||||||
|
column: "edition_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internship_internship_program_id",
|
||||||
|
table: "internship",
|
||||||
|
column: "internship_program_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internship_internship_registration_id",
|
||||||
|
table: "internship",
|
||||||
|
column: "internship_registration_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internship_report_id",
|
||||||
|
table: "internship",
|
||||||
|
column: "report_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internship_student_id",
|
||||||
|
table: "internship",
|
||||||
|
column: "student_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internship_registration_branch_address_id",
|
||||||
|
table: "internship_registration",
|
||||||
|
column: "branch_address_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internship_registration_company_id",
|
||||||
|
table: "internship_registration",
|
||||||
|
column: "company_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_internship_registration_type_id",
|
||||||
|
table: "internship_registration",
|
||||||
|
column: "type_id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "ix_program_subject_internship_subject_id",
|
||||||
|
table: "program_subject",
|
||||||
|
column: "internship_subject_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "document");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "edition_subject");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "program_subject");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "internship");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "internship_subject");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "editions");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "internship_program");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "internship_registration");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "report");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "student");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "course");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "branch_office");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "internship_type");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "companies");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,607 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using InternshipSystem.Repository;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
namespace InternshipSystem.Repository.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(InternshipDbContext))]
|
||||||
|
partial class InternshipDbContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
|
||||||
|
.HasAnnotation("ProductVersion", "3.1.4")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<long?>("CompanyId")
|
||||||
|
.HasColumnName("company_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_branch_office");
|
||||||
|
|
||||||
|
b.HasIndex("CompanyId")
|
||||||
|
.HasName("ix_branch_office_company_id");
|
||||||
|
|
||||||
|
b.ToTable("branch_office");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Company", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnName("name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Nip")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnName("nip")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Range")
|
||||||
|
.HasColumnName("range")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("SiteAddress")
|
||||||
|
.HasColumnName("site_address")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_companies");
|
||||||
|
|
||||||
|
b.ToTable("companies");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Course", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnName("name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_course");
|
||||||
|
|
||||||
|
b.ToTable("course");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnName("description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<long?>("InternshipId")
|
||||||
|
.HasColumnName("internship_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("InternshipId1")
|
||||||
|
.HasColumnName("internship_id1")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("RejectionReason")
|
||||||
|
.HasColumnName("rejection_reason")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Scan")
|
||||||
|
.HasColumnName("scan")
|
||||||
|
.HasColumnType("bytea");
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnName("state")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnName("type")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_document");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipId")
|
||||||
|
.HasName("ix_document_internship_id");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipId1")
|
||||||
|
.HasName("ix_document_internship_id1");
|
||||||
|
|
||||||
|
b.ToTable("document");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<long?>("CourseId")
|
||||||
|
.HasColumnName("course_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EditionFinish")
|
||||||
|
.HasColumnName("edition_finish")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("EditionStart")
|
||||||
|
.HasColumnName("edition_start")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ReportingStart")
|
||||||
|
.HasColumnName("reporting_start")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_editions");
|
||||||
|
|
||||||
|
b.HasIndex("CourseId")
|
||||||
|
.HasName("ix_editions_course_id");
|
||||||
|
|
||||||
|
b.ToTable("editions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipSubject", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnName("description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship_subject");
|
||||||
|
|
||||||
|
b.ToTable("internship_subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.InternshipType", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasColumnName("description")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.HasColumnName("type")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship_type");
|
||||||
|
|
||||||
|
b.ToTable("internship_type");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<Guid?>("EditionId")
|
||||||
|
.HasColumnName("edition_id")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<float>("Grade")
|
||||||
|
.HasColumnName("grade")
|
||||||
|
.HasColumnType("real");
|
||||||
|
|
||||||
|
b.Property<long?>("InternshipProgramId")
|
||||||
|
.HasColumnName("internship_program_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("InternshipRegistrationId")
|
||||||
|
.HasColumnName("internship_registration_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("ReportId")
|
||||||
|
.HasColumnName("report_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("StudentId")
|
||||||
|
.HasColumnName("student_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship");
|
||||||
|
|
||||||
|
b.HasIndex("EditionId")
|
||||||
|
.HasName("ix_internship_edition_id");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipProgramId")
|
||||||
|
.HasName("ix_internship_internship_program_id");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipRegistrationId")
|
||||||
|
.HasName("ix_internship_internship_registration_id");
|
||||||
|
|
||||||
|
b.HasIndex("ReportId")
|
||||||
|
.HasName("ix_internship_report_id");
|
||||||
|
|
||||||
|
b.HasIndex("StudentId")
|
||||||
|
.HasName("ix_internship_student_id");
|
||||||
|
|
||||||
|
b.ToTable("internship");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnName("state")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship_program");
|
||||||
|
|
||||||
|
b.ToTable("internship_program");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<long?>("BranchAddressId")
|
||||||
|
.HasColumnName("branch_address_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long?>("CompanyId")
|
||||||
|
.HasColumnName("company_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<DateTime>("End")
|
||||||
|
.HasColumnName("end")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Start")
|
||||||
|
.HasColumnName("start")
|
||||||
|
.HasColumnType("timestamp without time zone");
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnName("state")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<long?>("TypeId")
|
||||||
|
.HasColumnName("type_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_internship_registration");
|
||||||
|
|
||||||
|
b.HasIndex("BranchAddressId")
|
||||||
|
.HasName("ix_internship_registration_branch_address_id");
|
||||||
|
|
||||||
|
b.HasIndex("CompanyId")
|
||||||
|
.HasName("ix_internship_registration_company_id");
|
||||||
|
|
||||||
|
b.HasIndex("TypeId")
|
||||||
|
.HasName("ix_internship_registration_type_id");
|
||||||
|
|
||||||
|
b.ToTable("internship_registration");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<int>("State")
|
||||||
|
.HasColumnName("state")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_report");
|
||||||
|
|
||||||
|
b.ToTable("report");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Student", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b.Property<int>("AlbumNumber")
|
||||||
|
.HasColumnName("album_number")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasColumnName("email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.HasColumnName("first_name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.HasColumnName("last_name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Semester")
|
||||||
|
.HasColumnName("semester")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id")
|
||||||
|
.HasName("pk_student");
|
||||||
|
|
||||||
|
b.ToTable("student");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("EditionId")
|
||||||
|
.HasColumnName("edition_id")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<long>("InternshipSubjectId")
|
||||||
|
.HasColumnName("internship_subject_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("EditionId", "InternshipSubjectId")
|
||||||
|
.HasName("pk_edition_subject");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipSubjectId")
|
||||||
|
.HasName("ix_edition_subject_internship_subject_id");
|
||||||
|
|
||||||
|
b.ToTable("edition_subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("InternshipProgramId")
|
||||||
|
.HasColumnName("internship_program_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<long>("InternshipSubjectId")
|
||||||
|
.HasColumnName("internship_subject_id")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.HasKey("InternshipProgramId", "InternshipSubjectId")
|
||||||
|
.HasName("pk_program_subject");
|
||||||
|
|
||||||
|
b.HasIndex("InternshipSubjectId")
|
||||||
|
.HasName("ix_program_subject_internship_subject_id");
|
||||||
|
|
||||||
|
b.ToTable("program_subject");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Company", null)
|
||||||
|
.WithMany("Branches")
|
||||||
|
.HasForeignKey("CompanyId")
|
||||||
|
.HasConstraintName("fk_branch_office_companies_company_id");
|
||||||
|
|
||||||
|
b.OwnsOne("InternshipSystem.Core.BranchAddress", "Address", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("BranchOfficeId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b1.Property<string>("Building")
|
||||||
|
.HasColumnName("building")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("City")
|
||||||
|
.HasColumnName("city")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("Country")
|
||||||
|
.HasColumnName("country")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("PostalCode")
|
||||||
|
.HasColumnName("postal_code")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("Street")
|
||||||
|
.HasColumnName("street")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.HasKey("BranchOfficeId")
|
||||||
|
.HasName("pk_branch_office");
|
||||||
|
|
||||||
|
b1.ToTable("branch_office");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("BranchOfficeId")
|
||||||
|
.HasConstraintName("fk_branch_address_branch_office_branch_office_id");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Internship", null)
|
||||||
|
.WithMany("Approvals")
|
||||||
|
.HasForeignKey("InternshipId")
|
||||||
|
.HasConstraintName("fk_document_internship_internship_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Internship", null)
|
||||||
|
.WithMany("Documentation")
|
||||||
|
.HasForeignKey("InternshipId1")
|
||||||
|
.HasConstraintName("fk_document_internship_internship_id1");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Course", "Course")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CourseId")
|
||||||
|
.HasConstraintName("fk_editions_course_course_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.Internship", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Edition", null)
|
||||||
|
.WithMany("Internships")
|
||||||
|
.HasForeignKey("EditionId")
|
||||||
|
.HasConstraintName("fk_internship_editions_edition_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.InternshipProgram", "InternshipProgram")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InternshipProgramId")
|
||||||
|
.HasConstraintName("fk_internship_internship_program_internship_program_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.InternshipRegistration", "InternshipRegistration")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InternshipRegistrationId")
|
||||||
|
.HasConstraintName("fk_internship_internship_registration_internship_registration_");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Report", "Report")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ReportId")
|
||||||
|
.HasConstraintName("fk_internship_report_report_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Student", "Student")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("StudentId")
|
||||||
|
.HasConstraintName("fk_internship_student_student_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.InternshipProgram", b =>
|
||||||
|
{
|
||||||
|
b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<long>("InternshipProgramId")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnName("id")
|
||||||
|
.HasColumnType("bigint")
|
||||||
|
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
b1.Property<string>("Email")
|
||||||
|
.HasColumnName("email")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("FirstName")
|
||||||
|
.HasColumnName("first_name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("LastName")
|
||||||
|
.HasColumnName("last_name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.Property<string>("PhoneNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnName("mentor_phone_number")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b1.HasKey("InternshipProgramId")
|
||||||
|
.HasName("pk_internship_program");
|
||||||
|
|
||||||
|
b1.ToTable("internship_program");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("InternshipProgramId")
|
||||||
|
.HasConstraintName("fk_mentor_internship_program_internship_program_id");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.InternshipRegistration", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.BranchOffice", "BranchAddress")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("BranchAddressId")
|
||||||
|
.HasConstraintName("fk_internship_registration_branch_office_branch_address_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Company", "Company")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("CompanyId")
|
||||||
|
.HasConstraintName("fk_internship_registration_companies_company_id");
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "Type")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("TypeId")
|
||||||
|
.HasConstraintName("fk_internship_registration_internship_type_type_id");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionSubject", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.Edition", "Edition")
|
||||||
|
.WithMany("AvailableSubjects")
|
||||||
|
.HasForeignKey("EditionId")
|
||||||
|
.HasConstraintName("fk_edition_subject_editions_edition_id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InternshipSubjectId")
|
||||||
|
.HasConstraintName("fk_edition_subject_internship_subject_internship_subject_id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ProgramSubject", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("InternshipSystem.Core.InternshipProgram", "Program")
|
||||||
|
.WithMany("ChosenSubjects")
|
||||||
|
.HasForeignKey("InternshipProgramId")
|
||||||
|
.HasConstraintName("fk_program_subject_internship_program_internship_program_id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipSubject", "Subject")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("InternshipSubjectId")
|
||||||
|
.HasConstraintName("fk_program_subject_internship_subject_internship_subject_id")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user