Compare commits

..

1 Commits

Author SHA1 Message Date
38e443b517 Accept/Reject document 2021-01-10 19:17:46 +01:00
33 changed files with 120 additions and 926 deletions

View File

@ -1,49 +0,0 @@
# Uruchomienie
Aby uruchomić środowisko deweloperskie wystarczy
```bash
docker build -f ./InternshipSystem.Api/Dockerfile -t internship.api .
docker-compose -f ./.docker/docker-compose.yaml --build --volumes
```
# Opis struktury
Opis struktury projektu
## src/
zawiera kod podzielony na 3 projekty
- Api - Definicja interfejsu wystawianego dla częsci frontendowej
- Core - Logika biznesowa aplikacji, definicja domeny.
- Repository - Definicja repozytorium EFCore
## test/
Zawiera testy jednostkowe projektu. Przy pisaniu wykorzystano Machine-Specification
## .build/
Folder zawierający pliki definiujące CI/CD projektu
## .docker/
Folder zawiera pliki docker-compose przeznaczone do uruchamiania środowiska deweloperskiego, stanowiące również dokumentacje zmiennych środowiskowych konfigurujących projekt
```yaml
CONNECTIONSTRINGS__INTERNSHIPDATABASE: "Host=db.postgres;Port=5432;Database=postgres;Username=postgres;Password=password"
ASPNETCORE_ENVIRONMENT: Development
ASPNETCORE_URLS: http://+:80
SECURITYOPTIONS__SECRET: secret
SECURITYOPTIONS__EXPIRATION: 1440 # 24h in minutes
SECURITYOPTIONS__BASEURL: https://logowanie.pg.edu.pl
SECURITYOPTIONS__TOKENPATH: /oauth2.0/accessToken
SECURITYOPTIONS__PROFILEPATH: /oauth2.0/profile
SECURITYOPTIONS__CLIENTID: PraktykiClientId
SECURITYOPTIONS__REDIRECTURL: https://system-praktyk.net/user/login/check/pg
```
## props/
Folder ze współdzieloną konfiguracją dla grup projektów, np. wersji bibliotek używanych przy pisaniu testów.

5
global.json Normal file
View File

@ -0,0 +1,5 @@
{
"sdk": {
"version": "3.1.301"
}
}

View File

@ -3,7 +3,6 @@ using AutoMapper;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Result;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
@ -34,11 +33,6 @@ namespace InternshipSystem.Api
CreateMap<EditionInternshipType, InternshipType>()
.IncludeMembers(eit => eit.InternshipType);
CreateMap<ReportFieldEdition, ReportField>()
.IncludeMembers(e => e.Field);
CreateMap<ReportField, ReportField>();
CreateMap<InternshipType, InternshipType>();
}
}

View File

@ -23,27 +23,7 @@ namespace InternshipSystem.Api.Controllers
Context = context;
}
[HttpDelete("{documentId}/delete")]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> DeleteDocument(long documentId, CancellationToken ct)
{
var internship = await Context.Internships
.Include(i => i.Documentation)
.FirstOrDefaultAsync(i => i.Documentation.Any(d => d.Id.Equals(documentId)), ct);
if (internship == null)
{
return NotFound();
}
internship.RemoveDocument(documentId);
await Context.SaveChangesAsync(ct);
return Ok();
}
[HttpPut("{documentId}/accept")]
[HttpPut("accept/{documentId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
@ -75,12 +55,12 @@ namespace InternshipSystem.Api.Controllers
return Ok();
}
[HttpPut("{documentId}/reject")]
[HttpPut("reject/{documentId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> RejectDocument(long documentId, [FromBody] string comment, CancellationToken token)
public async Task<ActionResult> RejectInternship(long documentId, [FromBody] string comment, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.Documentation)

View File

@ -99,8 +99,6 @@ namespace InternshipSystem.Api.Controllers
var edition =
await Context.Editions
.Include(e => e.AvailableSubjects)
.Include(e => e.ReportSchema)
.ThenInclude(e => e.Field)
.Include(e => e.Course)
.Where(e => e.Id == user.EditionId)
.ProjectTo<EditionConfigurationResult>(Mapper.ConfigurationProvider)

View File

@ -44,8 +44,6 @@ namespace InternshipSystem.Api.Controllers
.Take(searchQuery.PerPage)
.ToListAsync(token);
[HttpGet("{editionId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
@ -59,8 +57,6 @@ namespace InternshipSystem.Api.Controllers
.ThenInclude(s => s.Subject)
.Include(e => e.AvailableInternshipTypes)
.ThenInclude(i => i.InternshipType)
.Include(e => e.ReportSchema)
.ThenInclude(er => er.Field)
.Where(e => e.Id == editionId)
.ProjectTo<EditionDetailsResult>(Mapper.ConfigurationProvider)
.FirstOrDefaultAsync(token);
@ -94,7 +90,6 @@ namespace InternshipSystem.Api.Controllers
var editionToUpdate = await Context.Editions
.Include(e => e.AvailableSubjects)
.Include(e => e.AvailableInternshipTypes)
.Include(e => e.ReportSchema)
.FirstOrDefaultAsync(e => e.Id == editionForm.Id.Value, token);
if (editionToUpdate == null)
@ -103,7 +98,7 @@ namespace InternshipSystem.Api.Controllers
}
editionToUpdate.UpdateEdition(editionForm.EditionStart, editionForm.EditionFinish, editionForm.ReportingStart,
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds, editionForm.ReportSchema);
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds);
if (!editionToUpdate.IsValidDates)
{
@ -114,7 +109,7 @@ namespace InternshipSystem.Api.Controllers
{
var newEdition =
Edition.CreateEdition(editionForm.EditionStart.Value, editionForm.EditionFinish.Value, editionForm.ReportingStart.Value,
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds, editionForm.ReportSchema);
editionForm.Course, editionForm.AvailableSubjectsIds, editionForm.AvailableInternshipTypesIds);
if (!newEdition.IsValidDates)
{
@ -140,7 +135,6 @@ namespace InternshipSystem.Api.Controllers
var editionToDelete = await Context.Editions
.Include(e => e.AvailableSubjects)
.Include(e => e.AvailableInternshipTypes)
.Include(e => e.ReportSchema)
.FirstOrDefaultAsync(e => e.Id.Equals(editionId), token);
if (editionToDelete == null)

View File

@ -38,14 +38,11 @@ namespace InternshipSystem.Api.Controllers
.Include(i => i.InternshipRegistration.Type)
.Include(i => i.Student)
.Include(i => i.Documentation)
.Include(i => i.Report)
.Where(i => !searchQuery.EditionId.HasValue || i.Edition.Id == searchQuery.EditionId)
.Where(i => !searchQuery.InternshipState.HasValue || i.InternshipRegistration.State == searchQuery.InternshipState)
.Where(i => !searchQuery.InternshipState.HasValue || i.Report.State == searchQuery.ReportState)
.Where(i => !searchQuery.StudentAlbumNumber.HasValue || i.Student.AlbumNumber == searchQuery.StudentAlbumNumber)
.Where(i => !searchQuery.EditionId.HasValue || i.Edition.Id.Equals(searchQuery.EditionId))
.Where(i => !searchQuery.InternshipState.HasValue || i.InternshipRegistration.State.Equals(searchQuery.InternshipState))
.Where(i => !searchQuery.StudentAlbumNumber.HasValue || i.Student.AlbumNumber.Equals(searchQuery.StudentAlbumNumber))
.Where(i => string.IsNullOrEmpty(searchQuery.StudentFirstName) || i.Student.FirstName.ToLower().Contains(searchQuery.StudentFirstName.ToLower()))
.Where(i => string.IsNullOrEmpty(searchQuery.StudentLastName) || i.Student.LastName.ToLower().Contains(searchQuery.StudentLastName.ToLower()))
.Where(i => !searchQuery.DocumentWithState.HasValue || i.Documentation.Any(d => d.State == searchQuery.DocumentWithState))
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage);
@ -97,54 +94,12 @@ namespace InternshipSystem.Api.Controllers
return Ok(internship);
}
[HttpGet("{internshipId}/status")]
[HttpPut("accept/{internshipId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> GetInternshipStatus(long internshipId, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.InternshipRegistration)
.Include(i => i.Report)
.Include(i => i.Documentation)
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
if (internship == null)
{
return NotFound();
}
return new JsonResult(new { Errors = internship.ValidateStatus() });
}
[HttpPut("{internshipId}/grade")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> GradeInternship(long internshipId, [FromBody] float grade, CancellationToken token)
{
var internship = await Context.Internships
.FirstOrDefaultAsync(i => i.Id.Equals(internshipId), token);
if (internship == null)
{
return NotFound();
}
internship.Grade = grade;
await Context.SaveChangesAsync(token);
return new JsonResult(new { Errors = internship.ValidateStatus() });
}
[HttpPut("{internshipId}/registration/accept")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> AcceptInternshipRegistration(long internshipId, [FromBody] string comment, CancellationToken token)
public async Task<ActionResult> AcceptInternship(long internshipId, [FromBody] string comment, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.InternshipRegistration)
@ -163,12 +118,12 @@ namespace InternshipSystem.Api.Controllers
return Ok();
}
[HttpPut("{internshipId}/registration/reject")]
[HttpPut("reject/{internshipId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> RejectInternshipRegistration(long internshipId, [FromBody] string comment, CancellationToken token)
public async Task<ActionResult> RejectInternship(long internshipId, [FromBody] string comment, CancellationToken token)
{
var internship = await Context.Internships
.Include(i => i.InternshipRegistration)

View File

@ -47,7 +47,7 @@ namespace InternshipSystem.Api.Controllers
.ThenInclude(t => t.Subject)
.FirstAsync(e => e.Id == user.EditionId, cancellationToken);
var internship =
var internshipRegistration =
await _context
.Entry(edition)
.Collection(e => e.Internships)
@ -62,11 +62,12 @@ namespace InternshipSystem.Api.Controllers
.ThenInclude(c => c.Type)
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Subjects)
.Include(i => i.Documentation)
.Where(i => i.Student.Id == user.PersonNumber)
.Select(i => i.InternshipRegistration)
.FirstAsync(cancellationToken);
var useCase = new UpdateInternshipRegistrationUseCase(_context, internship, edition, user);
var useCase = new UpdateInternshipRegistrationUseCase(_context, internshipRegistration, edition, user);
try
{

View File

@ -1,62 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Security;
using InternshipSystem.Core.ValueObject;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace InternshipSystem.Api.Controllers
{
[Route("internship/report")]
public class ReportController : ControllerBase
{
private readonly InternshipDbContext _context;
public ReportController(InternshipDbContext context)
{
_context = context;
}
[HttpPost]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> PostReport([FromBody] JObject reportValue, [FromServices] User user, CancellationToken ct)
{
var edition = await _context.Editions
.FindAsync(user.EditionId);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Report)
.Include(i => i.Documentation)
.SingleAsync(i => i.Student.Id == user.PersonNumber, ct);
internship.Report.UpdateReport(reportValue.ToString(Formatting.None));
internship.AddNewDocument("", DocumentType.InternshipEvaluation);
await _context.SaveChangesAsync(ct);
return Ok();
}
[HttpGet]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult> GetReport([FromServices] User user, CancellationToken ct)
{
var edition = await _context.Editions
.FindAsync(user.EditionId);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Report)
.SingleAsync(i => i.Student.Id == user.PersonNumber, ct);
return Ok(JsonConvert.DeserializeObject(internship.Report.Value));
}
}
}

View File

@ -1,90 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AutoMapper;
using InternshipSystem.Api.Queries.SearchQuery;
using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[Route("management/report")]
public class ReportFieldsController : ControllerBase
{
private readonly InternshipDbContext _context;
private readonly IMapper _mapper;
public ReportFieldsController(InternshipDbContext context, IMapper mapper)
{
_context = context;
_mapper = mapper;
}
[HttpGet("fields")]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<IEnumerable<ReportField>> GetFields(FieldSearchQuery searchQuery, CancellationToken ct) =>
await _context.ReportFields
.Where(c => c.Label.ToLower().Contains(searchQuery.Label.ToLower()))
.OrderBy(o => o.Label)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
.ToListAsync(ct);
[HttpPost("fields")]
[Authorize(Policy = Policies.IsOverseer)]
public async Task<ActionResult> CreateField([FromBody] FieldCreateRequest request, CancellationToken ct)
{
ReportField field;
switch (request.FieldType)
{
case FieldType.LongText:
case FieldType.ShortText:
field = new ReportField(request.Label, request.LabelEng, request.Description, request.DescriptionEng, request.FieldType);
break;
case FieldType.Select:
case FieldType.Radial:
case FieldType.Checkbox:
field = new ReportChoiceField(request.Label, request.LabelEng, request.Description, request.DescriptionEng, request.FieldType, request.Choices);
break;
default:
return BadRequest("Unknown field type");
}
try
{
await _context.ReportFields.AddAsync(field, ct);
await _context.SaveChangesAsync(ct);
}
catch (Exception e)
{
return BadRequest("Failed");
}
return Ok();
}
}
public class FieldSearchQuery : SearchQuery
{
public string Label { get; set; } = "";
}
public class FieldCreateRequest
{
public long? Id { get; set; }
public string Label { get; set; }
public string LabelEng { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
public FieldType FieldType { get; set; }
public string[] Choices { get; set; }
}
}

View File

@ -16,7 +16,6 @@ namespace InternshipSystem.Api.Queries
public Course Course { get; set; }
public List<long> AvailableSubjectsIds { get; set; } = new List<long>();
public List<long> AvailableInternshipTypesIds { get; set; } = new List<long>();
public List<long> ReportSchema { get; set; } = new List<long>();
public class Validator : AbstractValidator<EditionForm>
{

View File

@ -7,7 +7,6 @@ namespace InternshipSystem.Api.Queries.SearchQuery
{
public Guid? EditionId { get; set; } = null;
public DocumentState? InternshipState { get; set; } = null;
public DocumentState? ReportState { get; set; }
public int? StudentAlbumNumber { get; set; } = null;
public string StudentFirstName { get; set; } = "";
public string StudentLastName { get; set; } = "";
@ -16,7 +15,5 @@ namespace InternshipSystem.Api.Queries.SearchQuery
/// </summary>
public string OrderByField { get; set; } = "";
public SortOrder SortOrder { get; set; } = SortOrder.None;
public DocumentState? DocumentWithState { get; set; }
}
}

View File

@ -10,7 +10,6 @@ namespace InternshipSystem.Api.Result
public class EditionConfigurationResult
{
public List<InternshipSubject> AvailableSubjects { get; set; }
public List<ReportField> ReportSchema { get; set; }
public Course Course { get; set; }
public DateTime EditionStart { get; set; }
public DateTime EditionFinish { get; set; }

View File

@ -15,6 +15,5 @@ namespace InternshipSystem.Api.Result
public Course Course { get; set; }
public List<InternshipSubject> AvailableSubjects { get; set; }
public List<InternshipType> AvailableInternshipTypes { get; set; }
public List<ReportField> ReportSchema { get; set; }
}
}

View File

@ -9,7 +9,6 @@ using InternshipSystem.Api.Security;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Core.UglyOrmArtifacts;
using InternshipSystem.Core.ValueObject;
using InternshipSystem.Repository;
using Microsoft.EntityFrameworkCore;
@ -18,27 +17,25 @@ namespace InternshipSystem.Api.UseCases
public class UpdateInternshipRegistrationUseCase
{
private readonly InternshipDbContext _dbContext;
private readonly Internship _internship;
private readonly Edition _edition;
private readonly User _user;
private readonly InternshipRegistration subjectRegistration;
public UpdateInternshipRegistrationUseCase(InternshipDbContext dbContext,
Internship internship, Edition edition, User user)
InternshipRegistration internshipRegistration, Edition edition, User user)
{
_dbContext = dbContext;
_internship = internship;
_edition = edition;
_user = user;
_internship = internship;
subjectRegistration = internship.InternshipRegistration;
subjectRegistration = internshipRegistration;
}
public async Task<(DocumentState State, IEnumerable<ErrorDescription>)> UpdateInternshipRegistration(
UpdateRegistrationForm registrationCommand,
CancellationToken cancellationToken)
{
UpdateTimeFrame(registrationCommand);
subjectRegistration.Start = registrationCommand.Start ?? subjectRegistration.Start;
subjectRegistration.End = registrationCommand.End ?? subjectRegistration.End;
subjectRegistration.DeclaredHours = registrationCommand.Hours ?? subjectRegistration.DeclaredHours;
if (registrationCommand.Type.HasValue)
@ -64,43 +61,9 @@ namespace InternshipSystem.Api.UseCases
return subjectRegistration.ValidateStatus(_edition);
}
private void UpdateTimeFrame(UpdateRegistrationForm registrationCommand)
{
subjectRegistration.Start = registrationCommand.Start ?? subjectRegistration.Start;
subjectRegistration.End = registrationCommand.End ?? subjectRegistration.End;
if (!_edition.IsDateDuringEdition(subjectRegistration.Start, subjectRegistration.End))
{
_internship.AddNewDocument("", DocumentType.OutsideTermApproval);
}
else
{
_internship.RemoveDocument(DocumentType.OutsideTermApproval);
}
}
private void UpdateInternshipType(long typeId)
{
var editionInternshipType = _edition.AvailableInternshipTypes.FirstOrDefault(i => i.InternshipTypeId == typeId);
if (editionInternshipType?.InternshipType.RequireDeansApproval == true)
{
_internship.AddNewDocument("", DocumentType.InternshipTypeApproval);
}
else
{
_internship.RemoveDocument(DocumentType.InternshipTypeApproval);
}
if (editionInternshipType?.InternshipType.RequireInsurance == true)
{
_internship.AddNewDocument("", DocumentType.NnwInsurance);
}
else
{
_internship.RemoveDocument(DocumentType.NnwInsurance);
}
subjectRegistration.Type = editionInternshipType?.InternshipType ?? subjectRegistration.Type;
}

View File

@ -17,12 +17,11 @@ namespace InternshipSystem.Core
public List<Internship> Internships { get; set; }
public List<EditionSubject> AvailableSubjects { get; set; }
public List<EditionInternshipType> AvailableInternshipTypes { get; set; }
public List<ReportFieldEdition> ReportSchema { get; set; }
public bool IsOpen => EditionFinish < DateTime.Today;
public static Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart, Course course,
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds, IEnumerable<long> reportFieldIds)
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds)
{
var newEdition = CreateEdition(start, end, reportingStart, course);
@ -44,15 +43,6 @@ namespace InternshipSystem.Core
})
.ToList();
newEdition.ReportSchema =
reportFieldIds
.Select(i => new ReportFieldEdition
{
Edition = newEdition,
ReportFieldId = i,
})
.ToList();
return newEdition;
}
@ -66,12 +56,11 @@ namespace InternshipSystem.Core
Course = course,
AvailableSubjects = new List<EditionSubject>(),
AvailableInternshipTypes = new List<EditionInternshipType>(),
ReportSchema = new List<ReportFieldEdition>()
};
}
public void UpdateEdition(DateTime? start, DateTime? end, DateTime? reportingStart, Course course,
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds, IEnumerable<long> reportFieldIds)
IEnumerable<long> subjectsIds, IEnumerable<long> internshipTypesIds)
{
EditionStart = start ?? EditionStart;
EditionFinish = end ?? EditionFinish;
@ -99,17 +88,6 @@ namespace InternshipSystem.Core
})
.ToList();
}
if (reportFieldIds != null)
{
ReportSchema =
reportFieldIds
.Select(i => new ReportFieldEdition
{
ReportFieldId = i,
})
.ToList();
}
}
public void RegisterInternship(Student student)

View File

@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
using InternshipSystem.Core.ValueObject;
namespace InternshipSystem.Core.Entity.Internship
@ -27,19 +26,14 @@ namespace InternshipSystem.Core.Entity.Internship
internship.Report = Report.Create();
internship.Documentation = new List<Document>();
if (student.Semester != 6)
{
internship.AddNewDocument("", DocumentType.OutsideSemesterApproval);
}
return internship;
}
public void AddNewDocument(string description, DocumentType type)
{
if (type != DocumentType.Other && Documentation.Any(d => d.Type == type))
if (Documentation.Any(d => d.Type == type))
{
return;
throw new ArgumentException("Internship already has a document of given type");
}
var document = new Document
@ -52,54 +46,12 @@ namespace InternshipSystem.Core.Entity.Internship
Documentation.Add(document);
}
public void RemoveDocument(DocumentType documentType)
public void UpdateDocumentScan(long documentId, byte[] documentScan)
{
if (documentType == DocumentType.Other)
{
return;
}
var document = Documentation.First(d => d.Id == documentId);
var doc = Documentation.FirstOrDefault(d => d.Type == documentType);
if (doc != null)
{
Documentation.Remove(doc);
}
}
public void RemoveDocument(long id)
{
var doc = Documentation.FirstOrDefault(d => d.Id == id);
if (doc != null)
{
Documentation.Remove(doc);
}
}
public IEnumerable<ErrorDescription> ValidateStatus()
{
var validator = new Validator();
var result = validator.Validate(this);
return result.ToErrorDescription();
}
private class Validator : AbstractValidator<Internship>
{
public Validator()
{
RuleFor(i => i.Report)
.Must(r => r.State == DocumentState.Accepted)
.WithMessage("error.report.not_accepted");
RuleFor(i => i.InternshipRegistration)
.Must(r => r.State == DocumentState.Accepted)
.WithMessage("error.registration.not_accepted");
RuleForEach(i => i.Documentation)
.Must(d => d.State == DocumentState.Accepted)
.WithMessage("error.documentation.not_accepted");
}
// document.Scan = documentScan;
// document.State = DocumentState.Submitted;
}
}
}

View File

@ -62,9 +62,13 @@ namespace InternshipSystem.Core.Entity.Internship
.Must(edition.IsTypeAvailable)
.WithMessage("error.type.not_available");
RuleFor(x => x.Start)
.GreaterThanOrEqualTo(edition.EditionStart)
.LessThan(x => x.End)
.NotEmpty()
.WithMessage("error.start_date.empty");
RuleFor(x => x.End)
.LessThanOrEqualTo(edition.EditionFinish)
.GreaterThan(x => x.Start)
.NotEmpty()
.WithMessage("error.end_date.empty");
RuleFor(x => x.DeclaredHours)

View File

@ -7,7 +7,5 @@
public string LabelEng { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
public bool RequireDeansApproval { get; set; }
public bool RequireInsurance { get; set; }
}
}

View File

@ -6,17 +6,12 @@ namespace InternshipSystem.Core
{
public long Id { get; set; }
public DocumentState State { get; set; }
public string Value { get; set; }
public RangeOfActivity Range { get; set; }
public Uri SiteAddress { get; set; }
public static Report Create()
{
return new Report();
}
public void UpdateReport(string reportValue)
{
Value = reportValue;
State = DocumentState.Submitted;
}
}
}

View File

@ -1,49 +0,0 @@
using System;
using System.Collections.Generic;
namespace InternshipSystem.Core.Entity
{
public class ReportField
{
public ReportField()
{
}
public ReportField(string label, string labelEng, string description, string descriptionEng, FieldType fieldType)
{
Label = label;
LabelEng = labelEng;
Description = description;
DescriptionEng = descriptionEng;
FieldType = fieldType;
}
public long Id { get; set; }
public string Label { get; set; }
public string LabelEng { get; set; }
public string Description { get; set; }
public string DescriptionEng { get; set; }
public FieldType FieldType { get; set; }
}
public enum FieldType
{
LongText,
ShortText,
Select,
Radial,
Checkbox
}
public class ReportChoiceField : ReportField
{
public ReportChoiceField(string label, string labelEng, string description, string descriptionEng,
FieldType fieldType, string[] choices) : base(label, labelEng, description, descriptionEng, fieldType)
{
Choices = choices;
}
public string[] Choices { get; set; }
}
}

View File

@ -1,13 +0,0 @@
using System;
using InternshipSystem.Core.Entity;
namespace InternshipSystem.Core.UglyOrmArtifacts
{
public class ReportFieldEdition
{
public Guid EditionId { get; set; }
public Edition Edition { get; set; }
public long ReportFieldId { get; set; }
public ReportField Field { get; set; }
}
}

View File

@ -3,11 +3,7 @@
public enum DocumentType
{
IppScan,
OutsideTermApproval,
InternshipTypeApproval,
OutsideSemesterApproval,
NnwInsurance,
InternshipEvaluation,
Other
DeanConsent,
NnwIsurance
}
}

View File

@ -120,7 +120,6 @@ namespace InternshipSystem.Repository
LabelEng = "Internship agreement",
Description = "Praktyka bezpłatna",
DescriptionEng = "Free internship",
RequireInsurance = true
},
new InternshipType
{
@ -131,7 +130,6 @@ namespace InternshipSystem.Repository
{
Label = "Umowa o staż bezpłatny",
LabelEng = "Free apprenticeship agreement",
RequireInsurance = true
},
new InternshipType
{
@ -161,7 +159,6 @@ namespace InternshipSystem.Repository
{
Label = "Umowa zlecenia (w tym B2B)",
LabelEng = "Contract of mandate (including B2B)",
RequireDeansApproval = true
},
};
await Context.InternshipTypes.AddRangeAsync(internshipTypes);
@ -350,7 +347,6 @@ namespace InternshipSystem.Repository
}
}
},
Report = Report.Create()
},
new Internship
{

View File

@ -1,5 +1,3 @@
using System;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using InternshipSystem.Core;
using InternshipSystem.Core.Entity;
@ -18,8 +16,6 @@ namespace InternshipSystem.Repository
public DbSet<Course> Courses { get; set; }
public DbSet<Internship> Internships { get; set; }
public DbSet<ReportField> ReportFields { get; set; }
public InternshipDbContext(DbContextOptions<InternshipDbContext> options)
: base(options)
{
@ -95,37 +91,6 @@ namespace InternshipSystem.Repository
.WithMany()
.HasForeignKey(subject => subject.InternshipSubjectId);
});
modelBuilder.Entity<ReportFieldEdition>(builder =>
{
builder
.HasKey(e => new {e.EditionId, e.ReportFieldId});
builder
.HasOne(e => e.Edition)
.WithMany(edition => edition.ReportSchema)
.HasForeignKey(r => r.EditionId);
builder
.HasOne(e => e.Field)
.WithMany()
.HasForeignKey(r => r.ReportFieldId);
});
modelBuilder.Entity<ReportField>()
.HasDiscriminator<string>("field_discrimnator")
.HasValue<ReportField>("single")
.HasValue<ReportChoiceField>("choice");
modelBuilder.Entity<ReportChoiceField>()
.Property(r => r.Choices)
.HasConversion(
a => string.Join('#', a),
s => s.Split('#', StringSplitOptions.RemoveEmptyEntries));
modelBuilder.Entity<Report>()
.Property(r => r.Value)
.HasColumnType("jsonb");
}
}
}

View File

@ -20,4 +20,8 @@
<ProjectReference Include="..\InternshipSystem.Core\InternshipSystem.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations" />
</ItemGroup>
</Project>

View File

@ -10,8 +10,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
[DbContext(typeof(InternshipDbContext))]
[Migration("20210111195519_Insurance")]
partial class Insurance
[Migration("20210110082601_init")]
partial class init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -80,10 +80,6 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("ChangeStateComment")
.HasColumnName("change_state_comment")
.HasColumnType("text");
b.Property<string>("Description")
.HasColumnName("description")
.HasColumnType("text");
@ -92,6 +88,10 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("internship_id")
.HasColumnType("bigint");
b.Property<string>("RejectionReason")
.HasColumnName("rejection_reason")
.HasColumnType("text");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
@ -342,61 +342,12 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<bool>("RequireDeansApproval")
.HasColumnName("require_deans_approval")
.HasColumnType("boolean");
b.Property<bool>("RequireInsurance")
.HasColumnName("require_insurance")
.HasColumnType("boolean");
b.HasKey("Id")
.HasName("pk_internship_types");
b.ToTable("internship_types");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", 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>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<int>("FieldType")
.HasColumnName("field_type")
.HasColumnType("integer");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<string>("field_discrimnator")
.IsRequired()
.HasColumnName("field_discrimnator")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_report_fields");
b.ToTable("report_fields");
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
{
b.Property<long>("Id")
@ -405,14 +356,18 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("Range")
.HasColumnName("range")
.HasColumnType("integer");
b.Property<string>("SiteAddress")
.HasColumnName("site_address")
.HasColumnType("text");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<string>("Value")
.HasColumnName("value")
.HasColumnType("jsonb");
b.HasKey("Id")
.HasName("pk_report");
@ -548,36 +503,6 @@ namespace InternshipSystem.Repository.Migrations
b.ToTable("program_subject");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("ReportFieldId")
.HasColumnName("report_field_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "ReportFieldId")
.HasName("pk_report_field_edition");
b.HasIndex("ReportFieldId")
.HasName("ix_report_field_edition_report_field_id");
b.ToTable("report_field_edition");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
{
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
b.Property<string>("Choices")
.HasColumnName("choices")
.HasColumnType("text");
b.HasDiscriminator().HasValue("choice");
});
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
{
b.HasOne("InternshipSystem.Core.Company", null)
@ -775,23 +700,6 @@ namespace InternshipSystem.Repository.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("ReportSchema")
.HasForeignKey("EditionId")
.HasConstraintName("fk_report_field_edition_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
.WithMany()
.HasForeignKey("ReportFieldId")
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}

View File

@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
public partial class Init : Migration
public partial class init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
@ -60,8 +60,7 @@ namespace InternshipSystem.Repository.Migrations
label = table.Column<string>(nullable: true),
label_eng = table.Column<string>(nullable: true),
description = table.Column<string>(nullable: true),
description_eng = table.Column<string>(nullable: true),
require_deans_approval = table.Column<bool>(nullable: false)
description_eng = table.Column<string>(nullable: true)
},
constraints: table =>
{
@ -75,32 +74,14 @@ namespace InternshipSystem.Repository.Migrations
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
state = table.Column<int>(nullable: false),
value = table.Column<string>(type: "jsonb", nullable: true)
range = table.Column<int>(nullable: false),
site_address = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_report", x => x.id);
});
migrationBuilder.CreateTable(
name: "report_fields",
columns: table => new
{
id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
label = table.Column<string>(nullable: true),
label_eng = table.Column<string>(nullable: true),
description = table.Column<string>(nullable: true),
description_eng = table.Column<string>(nullable: true),
field_type = table.Column<int>(nullable: false),
field_discrimnator = table.Column<string>(nullable: false),
choices = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_report_fields", x => x.id);
});
migrationBuilder.CreateTable(
name: "static_pages",
columns: table => new
@ -273,30 +254,6 @@ namespace InternshipSystem.Repository.Migrations
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "report_field_edition",
columns: table => new
{
edition_id = table.Column<Guid>(nullable: false),
report_field_id = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_report_field_edition", x => new { x.edition_id, x.report_field_id });
table.ForeignKey(
name: "fk_report_field_edition_editions_edition_id",
column: x => x.edition_id,
principalTable: "editions",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_report_field_edition_report_fields_report_field_id",
column: x => x.report_field_id,
principalTable: "report_fields",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "internships",
columns: table => new
@ -371,7 +328,7 @@ namespace InternshipSystem.Repository.Migrations
description = table.Column<string>(nullable: true),
type = table.Column<int>(nullable: false),
state = table.Column<int>(nullable: false),
change_state_comment = table.Column<string>(nullable: true),
rejection_reason = table.Column<string>(nullable: true),
internship_id = table.Column<long>(nullable: true)
},
constraints: table =>
@ -470,11 +427,6 @@ namespace InternshipSystem.Repository.Migrations
name: "ix_program_subject_internship_subject_id",
table: "program_subject",
column: "internship_subject_id");
migrationBuilder.CreateIndex(
name: "ix_report_field_edition_report_field_id",
table: "report_field_edition",
column: "report_field_id");
}
protected override void Down(MigrationBuilder migrationBuilder)
@ -491,9 +443,6 @@ namespace InternshipSystem.Repository.Migrations
migrationBuilder.DropTable(
name: "program_subject");
migrationBuilder.DropTable(
name: "report_field_edition");
migrationBuilder.DropTable(
name: "static_pages");
@ -503,9 +452,6 @@ namespace InternshipSystem.Repository.Migrations
migrationBuilder.DropTable(
name: "internship_subject");
migrationBuilder.DropTable(
name: "report_fields");
migrationBuilder.DropTable(
name: "internships");

View File

@ -10,8 +10,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace InternshipSystem.Repository.Migrations
{
[DbContext(typeof(InternshipDbContext))]
[Migration("20210110210810_Init")]
partial class Init
[Migration("20210110181423_documentChangeStateComment")]
partial class documentChangeStateComment
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -342,57 +342,12 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<bool>("RequireDeansApproval")
.HasColumnName("require_deans_approval")
.HasColumnType("boolean");
b.HasKey("Id")
.HasName("pk_internship_types");
b.ToTable("internship_types");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", 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>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<int>("FieldType")
.HasColumnName("field_type")
.HasColumnType("integer");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<string>("field_discrimnator")
.IsRequired()
.HasColumnName("field_discrimnator")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_report_fields");
b.ToTable("report_fields");
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
{
b.Property<long>("Id")
@ -401,14 +356,18 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("Range")
.HasColumnName("range")
.HasColumnType("integer");
b.Property<string>("SiteAddress")
.HasColumnName("site_address")
.HasColumnType("text");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<string>("Value")
.HasColumnName("value")
.HasColumnType("jsonb");
b.HasKey("Id")
.HasName("pk_report");
@ -544,36 +503,6 @@ namespace InternshipSystem.Repository.Migrations
b.ToTable("program_subject");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("ReportFieldId")
.HasColumnName("report_field_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "ReportFieldId")
.HasName("pk_report_field_edition");
b.HasIndex("ReportFieldId")
.HasName("ix_report_field_edition_report_field_id");
b.ToTable("report_field_edition");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
{
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
b.Property<string>("Choices")
.HasColumnName("choices")
.HasColumnType("text");
b.HasDiscriminator().HasValue("choice");
});
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
{
b.HasOne("InternshipSystem.Core.Company", null)
@ -771,23 +700,6 @@ namespace InternshipSystem.Repository.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("ReportSchema")
.HasForeignKey("EditionId")
.HasConstraintName("fk_report_field_edition_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
.WithMany()
.HasForeignKey("ReportFieldId")
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}

View File

@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace InternshipSystem.Repository.Migrations
{
public partial class documentChangeStateComment : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "rejection_reason",
table: "document");
migrationBuilder.AddColumn<string>(
name: "change_state_comment",
table: "document",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "change_state_comment",
table: "document");
migrationBuilder.AddColumn<string>(
name: "rejection_reason",
table: "document",
type: "text",
nullable: true);
}
}
}

View File

@ -1,23 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace InternshipSystem.Repository.Migrations
{
public partial class Insurance : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "require_insurance",
table: "internship_types",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "require_insurance",
table: "internship_types");
}
}
}

View File

@ -340,61 +340,12 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<bool>("RequireDeansApproval")
.HasColumnName("require_deans_approval")
.HasColumnType("boolean");
b.Property<bool>("RequireInsurance")
.HasColumnName("require_insurance")
.HasColumnType("boolean");
b.HasKey("Id")
.HasName("pk_internship_types");
b.ToTable("internship_types");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportField", 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>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<int>("FieldType")
.HasColumnName("field_type")
.HasColumnType("integer");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.Property<string>("field_discrimnator")
.IsRequired()
.HasColumnName("field_discrimnator")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_report_fields");
b.ToTable("report_fields");
b.HasDiscriminator<string>("field_discrimnator").HasValue("single");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
{
b.Property<long>("Id")
@ -403,14 +354,18 @@ namespace InternshipSystem.Repository.Migrations
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("Range")
.HasColumnName("range")
.HasColumnType("integer");
b.Property<string>("SiteAddress")
.HasColumnName("site_address")
.HasColumnType("text");
b.Property<int>("State")
.HasColumnName("state")
.HasColumnType("integer");
b.Property<string>("Value")
.HasColumnName("value")
.HasColumnType("jsonb");
b.HasKey("Id")
.HasName("pk_report");
@ -546,36 +501,6 @@ namespace InternshipSystem.Repository.Migrations
b.ToTable("program_subject");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("ReportFieldId")
.HasColumnName("report_field_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "ReportFieldId")
.HasName("pk_report_field_edition");
b.HasIndex("ReportFieldId")
.HasName("ix_report_field_edition_report_field_id");
b.ToTable("report_field_edition");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.ReportChoiceField", b =>
{
b.HasBaseType("InternshipSystem.Core.Entity.ReportField");
b.Property<string>("Choices")
.HasColumnName("choices")
.HasColumnType("text");
b.HasDiscriminator().HasValue("choice");
});
modelBuilder.Entity("InternshipSystem.Core.BranchOffice", b =>
{
b.HasOne("InternshipSystem.Core.Company", null)
@ -773,23 +698,6 @@ namespace InternshipSystem.Repository.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.ReportFieldEdition", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("ReportSchema")
.HasForeignKey("EditionId")
.HasConstraintName("fk_report_field_edition_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.ReportField", "Field")
.WithMany()
.HasForeignKey("ReportFieldId")
.HasConstraintName("fk_report_field_edition_report_fields_report_field_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}

View File

@ -123,6 +123,7 @@ namespace InternshipSystem.Api.Test
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Subjects)
.Where(i => i.Student.Id == user.PersonNumber)
.Select(i => i.InternshipRegistration)
.First();
var useCase = new UpdateInternshipRegistrationUseCase(db, ir, ed, user);
@ -160,6 +161,7 @@ namespace InternshipSystem.Api.Test
.Include(i => i.InternshipRegistration)
.ThenInclude(c => c.Subjects)
.Where(i => i.Student.Id == user.PersonNumber)
.Select(i => i.InternshipRegistration)
.First();
};