feat/random (#65)

fix documents and other stuff

whatever

Merge branch 'master' of http://git.kadet.net/system-praktyk/system-praktyk-api into master

merge

add document scan endpoint

Co-authored-by: MaxchilKH <m.w.bohdanowicz@gmail.com>
This commit is contained in:
maxchil 2020-10-18 02:16:22 +02:00
parent 2f6a1ab324
commit 614054acba
12 changed files with 821 additions and 83 deletions

View File

@ -38,6 +38,7 @@ namespace InternshipSystem.Api.Controllers
public async Task<ActionResult<IReadOnlyCollection<Company>>> SearchByNameAsync([FromQuery] CompanySearchQuery searchQuery, CancellationToken cancellationToken) =>
await Context.Companies
.Where(c => c.Name.ToLower().Contains(searchQuery.Name.ToLower()))
.Where(c => c.Provider == 0)
.OrderBy(o => o.Name)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
@ -62,6 +63,7 @@ namespace InternshipSystem.Api.Controllers
.Collection(c => c.Branches)
.Query()
.Where(office => office.Address.City.ToLower().Contains(searchQuery.City.ToLower()))
.Where(office => office.Provider == 0)
.Skip(searchQuery.Page * searchQuery.PerPage)
.Take(searchQuery.PerPage)
.ToListAsync(token);

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using InternshipSystem.Api.Queries;
using InternshipSystem.Api.Security;
using InternshipSystem.Api.Service;
using InternshipSystem.Core;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@ -47,7 +48,7 @@ namespace InternshipSystem.Api.Controllers
CancellationToken cancellationToken)
{
var validator = new DocumentPublishRequest.Validator();
var result = await validator.ValidateAsync(documentRequest, cancellationToken);
var result = await validator.ValidateAsync(documentRequest, cancellationToken);
if (!result.IsValid)
{
@ -85,11 +86,18 @@ namespace InternshipSystem.Api.Controllers
await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Documentation)
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
internship.UpdateDocumentScan(documentId, memoryStream.ToArray());
var document = await _context.Entry(internship)
.Collection(i => i.Documentation)
.Query()
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
document.Scan = memoryStream.ToArray();
document.State = DocumentState.Submitted;
await _context.SaveChangesAsync(cancellationToken);
return Ok();
}
@ -103,10 +111,14 @@ namespace InternshipSystem.Api.Controllers
await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Documentation)
.FirstAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
var document = internship.Documentation.First(d => d.Id == documentId);
var document =
await _context.Entry(internship)
.Collection(i => i.Documentation)
.Query()
.FirstOrDefaultAsync(d => d.Id == documentId, cancellationToken);
var stream = new MemoryStream(document.Scan);
return File(stream, "application/pdf");

View File

@ -0,0 +1,54 @@
using System.Threading;
using System.Threading.Tasks;
using InternshipSystem.Api.Security;
using InternshipSystem.Core.Entity.Internship;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("internship")]
public class InternshipController : ControllerBase
{
private readonly InternshipDbContext _context;
public InternshipController(InternshipDbContext context)
{
_context = context;
}
/// <summary>
/// Get internship for current edition
/// </summary>
/// <response code="200">If current internship returned successfully</response>
/// <response code="401">This action is only available for authorized student registered for current edition</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult<Internship>> GetCurrentEditionInternship([FromServices] User user, CancellationToken cancellationToken)
{
var edition = await _context.Editions
.FindAsync(user.EditionId);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Student)
.Include(i => i.InternshipRegistration)
.Include(i => i.InternshipRegistration.Company)
.Include(i => i.InternshipRegistration.BranchAddress)
.Include(i => i.InternshipRegistration.Type)
.Include(i => i.Report)
.Include(i => i.Documentation)
.SingleAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
return Ok(internship);
}
}
}

View File

@ -7,13 +7,13 @@ using InternshipSystem.Api.Security;
using InternshipSystem.Api.UseCases;
using InternshipSystem.Repository;
using Microsoft.AspNetCore.Authorization;
using InternshipSystem.Core.Entity.Internship;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
namespace InternshipSystem.Api.Controllers
{
[ApiController]
[Route("internshipRegistration")]
public class InternshipRegistrationController : ControllerBase
{
@ -81,38 +81,6 @@ namespace InternshipSystem.Api.Controllers
{
return BadRequest(e.Message);
}
}
/// <summary>
/// Get internship for current edition
/// </summary>
/// <response code="200">If current internship returned successfully</response>
/// <response code="401">This action is only available for authorized student registered for current edition</response>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[Authorize(Policy = Policies.RegisteredOnly)]
public async Task<ActionResult<Internship>> GetCurrentEditionInternship([FromServices] User user, CancellationToken cancellationToken)
{
var edition = await _context.Editions
.FindAsync(user.EditionId);
var internship = await _context.Entry(edition)
.Collection(e => e.Internships)
.Query()
.Include(i => i.Student)
.Include(i => i.InternshipRegistration)
.Include(i => i.InternshipRegistration.Company)
.Include(i => i.InternshipRegistration.BranchAddress)
.Include(i => i.InternshipRegistration.Type)
.Include(i => i.Report)
.Include(i => i.Approvals)
.Include(i => i.Documentation)
.SingleAsync(i => i.Student.Id == user.PersonNumber, cancellationToken);
return Ok(internship);
}
}
}

View File

@ -6,16 +6,11 @@ namespace InternshipSystem.Api.Queries
{
public class DocumentPublishRequest
{
public long? Id { get; set; }
public string Description { get; set; }
public DocumentType Type { get; set; }
public class Validator : AbstractValidator<DocumentPublishRequest>
{
public Validator()
{
RuleFor(document => document.Type).NotEmpty();
}
}
}
}

View File

@ -17,6 +17,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace InternshipSystem.Api
{
@ -57,7 +58,11 @@ namespace InternshipSystem.Api
options.IncludeXmlComments(xmlPath);
})
.AddControllers(o => { o.ModelBinderProviders.Insert(0, new UserBinderProvider()); })
.AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.Converters.Add(new StringEnumConverter());
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

View File

@ -10,7 +10,6 @@ namespace InternshipSystem.Core.Entity.Internship
public Student Student { get; set; }
public InternshipRegistration InternshipRegistration { get; set; }
public Report Report { get; set; }
public List<Document> Approvals { get; set; }
public List<Document> Documentation { get; set; }
public Edition Edition { get; set; }
@ -25,7 +24,6 @@ namespace InternshipSystem.Core.Entity.Internship
internship.InternshipRegistration = InternshipRegistration.Create();
internship.Report = Report.Create();
internship.Approvals = new List<Document>();
internship.Documentation = new List<Document>();
return internship;

View File

@ -31,6 +31,16 @@ namespace InternshipSystem.Repository
modelBuilder.Entity<InternshipRegistration>()
.OwnsOne(ir => ir.Mentor);
modelBuilder.Entity<DocumentScan>(builder =>
{
builder
.HasKey(scan => scan.DocumentId);
builder
.HasOne(s => s.Document)
.WithOne(d => d.Scan);
});
modelBuilder.Entity<ProgramSubject>(builder =>
{
builder

View File

@ -20,8 +20,4 @@
<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("20201015165238_init")]
partial class init
[Migration("20201018000658_Init")]
partial class Init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@ -106,18 +106,10 @@ namespace InternshipSystem.Repository.Migrations
.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");
@ -132,12 +124,25 @@ namespace InternshipSystem.Repository.Migrations
b.HasIndex("InternshipId")
.HasName("ix_document_internship_id");
b.HasIndex("InternshipId1")
.HasName("ix_document_internship_id1");
b.ToTable("document");
});
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.Property<long>("DocumentId")
.HasColumnName("document_id")
.HasColumnType("bigint");
b.Property<byte[]>("File")
.HasColumnName("file")
.HasColumnType("bytea");
b.HasKey("DocumentId")
.HasName("pk_document_scan");
b.ToTable("document_scan");
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>
{
b.Property<Guid>("Id")
@ -523,14 +528,19 @@ namespace InternshipSystem.Repository.Migrations
modelBuilder.Entity("InternshipSystem.Core.Document", b =>
{
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
.WithMany("Approvals")
.WithMany("Documentation")
.HasForeignKey("InternshipId")
.HasConstraintName("fk_document_internship_internship_id");
});
b.HasOne("InternshipSystem.Core.Entity.Internship.Internship", null)
.WithMany("Documentation")
.HasForeignKey("InternshipId1")
.HasConstraintName("fk_document_internship_internship_id1");
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.HasOne("InternshipSystem.Core.Document", "Document")
.WithOne("Scan")
.HasForeignKey("InternshipSystem.Core.DocumentScan", "DocumentId")
.HasConstraintName("fk_document_scan_document_document_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("InternshipSystem.Core.Edition", b =>

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)
{
@ -323,12 +323,10 @@ namespace InternshipSystem.Repository.Migrations
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)
internship_id = table.Column<long>(nullable: true)
},
constraints: table =>
{
@ -339,12 +337,24 @@ namespace InternshipSystem.Repository.Migrations
principalTable: "internship",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "document_scan",
columns: table => new
{
document_id = table.Column<long>(nullable: false),
file = table.Column<byte[]>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_document_scan", x => x.document_id);
table.ForeignKey(
name: "fk_document_internship_internship_id1",
column: x => x.internship_id1,
principalTable: "internship",
name: "fk_document_scan_document_document_id",
column: x => x.document_id,
principalTable: "document",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
@ -357,11 +367,6 @@ namespace InternshipSystem.Repository.Migrations
table: "document",
column: "internship_id");
migrationBuilder.CreateIndex(
name: "ix_document_internship_id1",
table: "document",
column: "internship_id1");
migrationBuilder.CreateIndex(
name: "ix_edition_internship_type_internship_type_id",
table: "edition_internship_type",
@ -421,7 +426,7 @@ namespace InternshipSystem.Repository.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "document");
name: "document_scan");
migrationBuilder.DropTable(
name: "edition_internship_type");
@ -436,11 +441,14 @@ namespace InternshipSystem.Repository.Migrations
name: "static_pages");
migrationBuilder.DropTable(
name: "internship");
name: "document");
migrationBuilder.DropTable(
name: "internship_subject");
migrationBuilder.DropTable(
name: "internship");
migrationBuilder.DropTable(
name: "editions");

View File

@ -0,0 +1,680 @@
// <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.Property<long>("Provider")
.HasColumnName("provider")
.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")
.HasColumnName("nip")
.HasColumnType("text");
b.Property<long>("Provider")
.HasColumnName("provider")
.HasColumnType("bigint");
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<string>("RejectionReason")
.HasColumnName("rejection_reason")
.HasColumnType("text");
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.ToTable("document");
});
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.Property<long>("DocumentId")
.HasColumnName("document_id")
.HasColumnType("bigint");
b.Property<byte[]>("File")
.HasColumnName("file")
.HasColumnType("bytea");
b.HasKey("DocumentId")
.HasName("pk_document_scan");
b.ToTable("document_scan");
});
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.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?>("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("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.Entity.Internship.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<int>("DeclaredHours")
.HasColumnName("declared_hours")
.HasColumnType("integer");
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.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.Property<string>("DescriptionEng")
.HasColumnName("description_eng")
.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>("DescriptionEng")
.HasColumnName("description_eng")
.HasColumnType("text");
b.Property<string>("Label")
.HasColumnName("label")
.HasColumnType("text");
b.Property<string>("LabelEng")
.HasColumnName("label_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_internship_types");
b.ToTable("internship_types");
});
modelBuilder.Entity("InternshipSystem.Core.Report", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.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.HasKey("Id")
.HasName("pk_report");
b.ToTable("report");
});
modelBuilder.Entity("InternshipSystem.Core.StaticPage", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnName("id")
.HasColumnType("bigint")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("AccessName")
.HasColumnName("access_name")
.HasColumnType("text");
b.Property<string>("Content")
.HasColumnName("content")
.HasColumnType("text");
b.Property<string>("ContentEng")
.HasColumnName("content_eng")
.HasColumnType("text");
b.Property<string>("Title")
.HasColumnName("title")
.HasColumnType("text");
b.Property<string>("TitleEng")
.HasColumnName("title_eng")
.HasColumnType("text");
b.HasKey("Id")
.HasName("pk_static_pages");
b.ToTable("static_pages");
});
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>("Course")
.HasColumnName("course")
.HasColumnType("text");
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_students");
b.ToTable("students");
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
{
b.Property<Guid>("EditionId")
.HasColumnName("edition_id")
.HasColumnType("uuid");
b.Property<long>("InternshipTypeId")
.HasColumnName("internship_type_id")
.HasColumnType("bigint");
b.HasKey("EditionId", "InternshipTypeId")
.HasName("pk_edition_internship_type");
b.HasIndex("InternshipTypeId")
.HasName("ix_edition_internship_type_internship_type_id");
b.ToTable("edition_internship_type");
});
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>("InternshipRegistrationId")
.HasColumnName("internship_registration_id")
.HasColumnType("bigint");
b.Property<long>("InternshipSubjectId")
.HasColumnName("internship_subject_id")
.HasColumnType("bigint");
b.HasKey("InternshipRegistrationId", "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.Entity.Internship.Internship", null)
.WithMany("Documentation")
.HasForeignKey("InternshipId")
.HasConstraintName("fk_document_internship_internship_id");
});
modelBuilder.Entity("InternshipSystem.Core.DocumentScan", b =>
{
b.HasOne("InternshipSystem.Core.Document", "Document")
.WithOne("Scan")
.HasForeignKey("InternshipSystem.Core.DocumentScan", "DocumentId")
.HasConstraintName("fk_document_scan_document_document_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
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.Entity.Internship.Internship", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("Internships")
.HasForeignKey("EditionId")
.HasConstraintName("fk_internship_editions_edition_id");
b.HasOne("InternshipSystem.Core.Entity.Internship.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_students_student_id");
});
modelBuilder.Entity("InternshipSystem.Core.Entity.Internship.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_types_type_id");
b.OwnsOne("InternshipSystem.Core.Mentor", "Mentor", b1 =>
{
b1.Property<long>("InternshipRegistrationId")
.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")
.HasColumnName("phone_number")
.HasColumnType("text");
b1.HasKey("InternshipRegistrationId")
.HasName("pk_internship_registration");
b1.ToTable("internship_registration");
b1.WithOwner()
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_mentor_internship_registration_internship_registration_id");
});
});
modelBuilder.Entity("InternshipSystem.Core.UglyOrmArtifacts.EditionInternshipType", b =>
{
b.HasOne("InternshipSystem.Core.Edition", "Edition")
.WithMany("AvailableInternshipTypes")
.HasForeignKey("EditionId")
.HasConstraintName("fk_edition_internship_type_editions_edition_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("InternshipSystem.Core.Entity.Internship.InternshipType", "InternshipType")
.WithMany()
.HasForeignKey("InternshipTypeId")
.HasConstraintName("fk_edition_internship_type_internship_types_internship_type_id")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
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.Entity.Internship.InternshipRegistration", "Registration")
.WithMany("Subjects")
.HasForeignKey("InternshipRegistrationId")
.HasConstraintName("fk_program_subject_internship_registration_internship_registrat")
.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
}
}
}