Changed models, added Application layer models

This commit is contained in:
2024-08-15 14:54:23 +03:00
parent 1d8405b4ec
commit c1a4acf414
50 changed files with 628 additions and 647 deletions

View File

@@ -1,4 +1,5 @@
using Domains.ApplicantDomain;
using ApplicationLayer.VisaApplication.Models;
using Domains.ApplicantDomain;
using Domains.VisaApplicationDomain;
namespace ApplicationLayer.VisaApplication;
@@ -19,7 +20,7 @@ public record CreateVisaApplicationRequest(
bool IsNonResident,
ReentryPermit ReentryPermit,
string JobTitle,
PlaceOfWork PlaceOfWork,
PlaceOfWorkModel PlaceOfWork,
string DestinationCountry,
VisaCategory VisaCategory,
bool IsForGroup,

View File

@@ -0,0 +1,16 @@
namespace ApplicationLayer.VisaApplication.Models;
public class AddressModel
{
/// Country part of address
public string Country { get; set; } = null!;
/// City part of address
public string City { get; set; } = null!;
/// Street part of address
public string Street { get; set; } = null!;
/// Building part of address
public string Building { get; set; } = null!;
}

View File

@@ -0,0 +1,13 @@
namespace ApplicationLayer.VisaApplication.Models;
public class PlaceOfWorkModel
{
/// Name of hirer
public string Name { get; set; } = null!;
/// <see cref="AddressModel"/> of hirer
public AddressModel Address { get; set; } = null!;
/// Phone number of hirer
public string PhoneNum { get; set; } = null!;
}

View File

@@ -1,7 +1,7 @@
using Domains.LocationDomain;
namespace Domains.ApplicantDomain
{
namespace Domains.ApplicantDomain;
/// Model of address
/// <remarks>Owned</remarks>
public class Address
@@ -18,4 +18,3 @@ namespace Domains.ApplicantDomain
/// Building part of address
public string Building { get; set; } = null!;
}
}

View File

@@ -1,8 +1,8 @@
using Domains.LocationDomain;
using Domains.VisaApplicationDomain;
namespace Domains.ApplicantDomain
{
namespace Domains.ApplicantDomain;
/// Model of an applicant
public class Applicant : IEntity
{
@@ -54,4 +54,3 @@ namespace Domains.ApplicantDomain
/// List of <see cref="Applicant"/>'s applications
public List<VisaApplication> VisaApplications { get; set; } = null!;
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.ApplicantDomain
{
namespace Domains.ApplicantDomain;
public enum Gender
{
Unknown,
@@ -7,4 +7,3 @@
Female,
Turkish
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.ApplicantDomain
{
namespace Domains.ApplicantDomain;
public enum MaritalStatus
{
Other,
@@ -8,4 +8,3 @@
Separated,
WidowOrWidower
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.ApplicantDomain
{
namespace Domains.ApplicantDomain;
/// Model of full name
/// <remarks>Owned</remarks>
public class Name
@@ -10,4 +10,3 @@
public string? Patronymic { get; set; }
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.ApplicantDomain
{
namespace Domains.ApplicantDomain;
/// Model of passport
/// <remarks>Owned</remarks>
public class Passport
@@ -16,4 +16,3 @@
/// Date when the <see cref="Passport"/> expires
public DateTime ExpirationDate { get; set; }
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.ApplicantDomain
{
namespace Domains.ApplicantDomain;
public class PlaceOfWork : IEntity
{
/// Unique identifier of <see cref="PlaceOfWork"/>
@@ -14,4 +14,3 @@
/// Phone number of hirer
public string PhoneNum { get; set; } = null!;
}
}

View File

@@ -1,8 +1,7 @@
namespace Domains
{
namespace Domains;
/// Interface that every entity should inherit from
public interface IEntity
{
public Guid Id { get; }
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.LocationDomain
{
namespace Domains.LocationDomain;
/// Model of a city
public class City : IEntity
{
@@ -12,4 +12,3 @@
/// <see cref="LocationDomain.Country"/> in which the city is located
public Country Country { get; set; } = null!;
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.LocationDomain
{
namespace Domains.LocationDomain;
/// Model of a country
public class Country : IEntity
{
@@ -15,4 +15,3 @@
/// List of <see cref="City"/> that country have
public List<City> Cities { get; set; } = null!;
}
}

View File

@@ -1,13 +1,11 @@
using Domains.ApplicantDomain;
namespace Domains.VisaApplicationDomain
{
/// Visa that <see cref="Applicant"/> already had
public class PastVisa : IEntity
{
/// Unique identifier of <see cref="PastVisa"/>
public Guid Id { get; private set; } = Guid.NewGuid();
namespace Domains.VisaApplicationDomain;
/// Visa that <see cref="Applicant"/> already had
/// <remarks>Owned</remarks>
public class PastVisa
{
/// Date of issue
public DateTime IssueDate { get; set; }
@@ -17,4 +15,3 @@ namespace Domains.VisaApplicationDomain
/// Date when visa expires
public DateTime ExpirationDate { get; set; }
}
}

View File

@@ -1,17 +1,14 @@
using Domains.ApplicantDomain;
namespace Domains.VisaApplicationDomain
{
/// Visit in a Schengen country that <see cref="Applicant"/> already had
public class PastVisit : IEntity
{
/// Unique identifier of <see cref="PastVisit"/>
public Guid Id { get; private set; } = Guid.NewGuid();
namespace Domains.VisaApplicationDomain;
/// Visit in a Schengen country that <see cref="Applicant"/> already had
/// <remarks>Owned</remarks>
public class PastVisit
{
/// First day of <see cref="PastVisit"/>
public DateTime StartDate { get; set; }
/// Last day of <see cref="PastVisit"/>
public DateTime EndDate { get; set; }
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.VisaApplicationDomain
{
namespace Domains.VisaApplicationDomain;
/// Permission to enter the destination country
/// <remarks>Owned</remarks>
public class PermissionToDestCountry
@@ -10,4 +10,3 @@
/// Issuing authority
public string Issuer { get; set; } = null!;
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.VisaApplicationDomain
{
namespace Domains.VisaApplicationDomain;
/// Permission to enter a country the issuer wants to come from
/// <remarks>Owned</remarks>
public class ReentryPermit
@@ -10,4 +10,3 @@
/// Date when <see cref="ReentryPermit"/> expires
public DateTime ExpirationDate { get; set; }
}
}

View File

@@ -1,5 +1,5 @@
namespace Domains.VisaApplicationDomain
{
namespace Domains.VisaApplicationDomain;
/// Requested number of entries
public enum RequestedNumberOfEntries
{
@@ -7,4 +7,3 @@
One,
Two
}
}

View File

@@ -1,8 +1,8 @@
using Domains.ApplicantDomain;
using Domains.LocationDomain;
namespace Domains.VisaApplicationDomain
{
namespace Domains.VisaApplicationDomain;
/// Model of visit request
public class VisaApplication : IEntity
{
@@ -48,4 +48,3 @@ namespace Domains.VisaApplicationDomain
/// Valid days requested
public int ValidDaysRequested { get; set; }
}
}

View File

@@ -1,9 +1,8 @@
namespace Domains.VisaApplicationDomain
{
namespace Domains.VisaApplicationDomain;
/// Category of visa
public enum VisaCategory
{
Transit,
ShortDated
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration
{
namespace Infrastructure.Database.Applicants.Configuration;
public class AddressConfiguration : IEntityTypeConfiguration<Address>
{
public void Configure(EntityTypeBuilder<Address> entity)
@@ -16,4 +16,3 @@ namespace Infrastructure.Database.Applicants.Configuration
.HasMaxLength(10);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration
{
namespace Infrastructure.Database.Applicants.Configuration;
public class ApplicantConfiguration : IEntityTypeConfiguration<Applicant>
{
public void Configure(EntityTypeBuilder<Applicant> entity)
@@ -24,4 +24,3 @@ namespace Infrastructure.Database.Applicants.Configuration
.HasMaxLength(30);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration
{
namespace Infrastructure.Database.Applicants.Configuration;
public class NameConfiguration : IEntityTypeConfiguration<Name>
{
public void Configure(EntityTypeBuilder<Name> entity)
@@ -21,4 +21,3 @@ namespace Infrastructure.Database.Applicants.Configuration
.HasMaxLength(50);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration
{
namespace Infrastructure.Database.Applicants.Configuration;
public class PassportConfiguration : IEntityTypeConfiguration<Passport>
{
public void Configure(EntityTypeBuilder<Passport> entity)
@@ -17,4 +17,3 @@ namespace Infrastructure.Database.Applicants.Configuration
.HasMaxLength(200);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration
{
namespace Infrastructure.Database.Applicants.Configuration;
public class PlaceOfWorkConfiguration : IEntityTypeConfiguration<PlaceOfWork>
{
public void Configure(EntityTypeBuilder<PlaceOfWork> entity)
@@ -19,4 +19,3 @@ namespace Infrastructure.Database.Applicants.Configuration
.HasMaxLength(20);
}
}
}

View File

@@ -2,8 +2,8 @@
using Infrastructure.Database.Generic;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Database.Applicants.Repositories
{
namespace Infrastructure.Database.Applicants.Repositories;
/// Repository pattern for <see cref="Applicant"/>
/// <param name="reader"><inheritdoc cref="IGenericReader"/></param>
/// <param name="writer"><inheritdoc cref="IGenericWriter"/></param>
@@ -19,4 +19,3 @@ namespace Infrastructure.Database.Applicants.Repositories
.Include(a => a.PlaceOfWork);
}
}
}

View File

@@ -1,8 +1,7 @@
using Domains.ApplicantDomain;
using Infrastructure.Database.Generic;
namespace Infrastructure.Database.Applicants.Repositories
{
namespace Infrastructure.Database.Applicants.Repositories;
/// Repository pattern for <see cref="Applicant"/>
public interface IApplicantsRepository : IGenericRepository<Applicant> { }
}

View File

@@ -2,8 +2,8 @@
using Infrastructure.Database.Generic;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Database
{
namespace Infrastructure.Database;
public class DbContext(DbContextOptions<DbContext> opts)
: Microsoft.EntityFrameworkCore.DbContext(opts), IGenericWriter, IGenericReader, IUnitOfWork
{
@@ -37,4 +37,3 @@ namespace Infrastructure.Database
await SaveChangesAsync(cancellationToken);
}
}
}

View File

@@ -1,10 +1,9 @@
using Domains;
namespace Infrastructure.Database.GeneralExceptions
{
namespace Infrastructure.Database.GeneralExceptions;
/// Exception to throw when entity with specific id not found
/// <param name="id">Identifier of entity</param>
/// <typeparam name="T">Not found entity type</typeparam>
public class EntityNotFoundException<T>(Guid id) : Exception($"Entity {typeof(T).Name} with id '{id}' not found")
where T : class, IEntity;
}

View File

@@ -2,8 +2,8 @@
using Infrastructure.Database.GeneralExceptions;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Database.Generic
{
namespace Infrastructure.Database.Generic;
/// Generic repository pattern
/// <param name="writer"><inheritdoc cref="IGenericWriter"/></param>
/// <param name="unitOfWork"><inheritdoc cref="IUnitOfWork"/></param>
@@ -50,4 +50,3 @@ namespace Infrastructure.Database.Generic
return reader.GetAll<T>();
}
}
}

View File

@@ -1,7 +1,7 @@
using Domains;
namespace Infrastructure.Database.Generic
{
namespace Infrastructure.Database.Generic;
/// Reads from data storage
public interface IGenericReader
{
@@ -9,4 +9,3 @@ namespace Infrastructure.Database.Generic
/// <typeparam name="T">Entity type to seek in storage</typeparam>
IQueryable<T> GetAll<T>() where T : class, IEntity;
}
}

View File

@@ -1,7 +1,7 @@
using Domains;
namespace Infrastructure.Database.Generic
{
namespace Infrastructure.Database.Generic;
/// <summary>
/// Generic repository pattern
/// </summary>
@@ -34,4 +34,3 @@ namespace Infrastructure.Database.Generic
/// Save changes in storage
Task SaveAsync(CancellationToken cancellationToken);
}
}

View File

@@ -1,7 +1,7 @@
using Domains;
namespace Infrastructure.Database.Generic
{
namespace Infrastructure.Database.Generic;
/// Writes data to data storage
/// <remarks><see cref="IUnitOfWork"/> should be used to save changes</remarks>
public interface IGenericWriter
@@ -22,4 +22,3 @@ namespace Infrastructure.Database.Generic
/// <typeparam name="T">Entity type</typeparam>
void Remove<T>(T entity) where T : class, IEntity;
}
}

View File

@@ -1,9 +1,8 @@
namespace Infrastructure.Database
{
namespace Infrastructure.Database;
public interface IUnitOfWork
{
/// Saves changes in data storage
/// <param name="cancellationToken">Cancellation Token</param>
Task SaveAsync(CancellationToken cancellationToken);
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Locations.Configuration
{
namespace Infrastructure.Database.Locations.Configuration;
public class CityConfiguration : IEntityTypeConfiguration<City>
{
public void Configure(EntityTypeBuilder<City> entity)
@@ -13,4 +13,3 @@ namespace Infrastructure.Database.Locations.Configuration
.HasMaxLength(70);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Locations.Configuration
{
namespace Infrastructure.Database.Locations.Configuration;
public class CountryConfiguration : IEntityTypeConfiguration<Country>
{
public void Configure(EntityTypeBuilder<Country> entity)
@@ -13,4 +13,3 @@ namespace Infrastructure.Database.Locations.Configuration
.HasMaxLength(70);
}
}
}

View File

@@ -2,8 +2,8 @@
using Infrastructure.Database.Generic;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Database.Locations.Repositories.Cities
{
namespace Infrastructure.Database.Locations.Repositories.Cities;
public sealed class CitiesRepository(IGenericReader reader, IGenericWriter writer, IUnitOfWork unitOfWork)
: GenericRepository<City>(reader, writer, unitOfWork), ICitiesRepository
{
@@ -12,4 +12,3 @@ namespace Infrastructure.Database.Locations.Repositories.Cities
return base.LoadDomain().Include(c => c.Country);
}
}
}

View File

@@ -1,7 +1,6 @@
using Domains.LocationDomain;
using Infrastructure.Database.Generic;
namespace Infrastructure.Database.Locations.Repositories.Cities
{
namespace Infrastructure.Database.Locations.Repositories.Cities;
public interface ICitiesRepository : IGenericRepository<City> { }
}

View File

@@ -2,8 +2,8 @@
using Infrastructure.Database.Generic;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Database.Locations.Repositories.Countries
{
namespace Infrastructure.Database.Locations.Repositories.Countries;
public sealed class CountriesRepository(IGenericReader reader, IGenericWriter writer, IUnitOfWork unitOfWork)
: GenericRepository<Country>(reader, writer, unitOfWork), ICountriesRepository
{
@@ -12,4 +12,3 @@ namespace Infrastructure.Database.Locations.Repositories.Countries
return base.LoadDomain().Include(c => c.Cities);
}
}
}

View File

@@ -1,7 +1,6 @@
using Domains.LocationDomain;
using Infrastructure.Database.Generic;
namespace Infrastructure.Database.Locations.Repositories.Countries
{
namespace Infrastructure.Database.Locations.Repositories.Countries;
public interface ICountriesRepository : IGenericRepository<Country> { }
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.VisaApplications.Configuration
{
namespace Infrastructure.Database.VisaApplications.Configuration;
public class PastVisaConfiguration : IEntityTypeConfiguration<PastVisa>
{
public void Configure(EntityTypeBuilder<PastVisa> entity)
@@ -13,4 +13,3 @@ namespace Infrastructure.Database.VisaApplications.Configuration
.HasMaxLength(70);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.VisaApplications.Configuration
{
namespace Infrastructure.Database.VisaApplications.Configuration;
public class PermissionToDestCountryConfiguration : IEntityTypeConfiguration<PermissionToDestCountry>
{
public void Configure(EntityTypeBuilder<PermissionToDestCountry> entity)
@@ -13,4 +13,3 @@ namespace Infrastructure.Database.VisaApplications.Configuration
.HasMaxLength(200);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.VisaApplications.Configuration
{
namespace Infrastructure.Database.VisaApplications.Configuration;
public class ReentryPermitConfiguration : IEntityTypeConfiguration<ReentryPermit>
{
public void Configure(EntityTypeBuilder<ReentryPermit> entity)
@@ -13,4 +13,3 @@ namespace Infrastructure.Database.VisaApplications.Configuration
.HasMaxLength(25);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.VisaApplications.Configuration
{
namespace Infrastructure.Database.VisaApplications.Configuration;
public class VisaApplicationConfiguration : IEntityTypeConfiguration<VisaApplication>
{
public void Configure(EntityTypeBuilder<VisaApplication> entity)
@@ -17,6 +17,7 @@ namespace Infrastructure.Database.VisaApplications.Configuration
entity.OwnsOne(p => p.ReentryPermit);
entity.OwnsOne(p => p.PermissionToDestCountry);
}
entity.OwnsMany(p => p.PastVisits).ToTable("PastVisits");
entity.OwnsMany(p => p.PastVisas).ToTable("PastVisas");
}
}

View File

@@ -1,7 +1,6 @@
using Domains.VisaApplicationDomain;
using Infrastructure.Database.Generic;
namespace Infrastructure.Database.VisaApplications.Repositories
{
namespace Infrastructure.Database.VisaApplications.Repositories;
public interface IVisaApplicationsRepository : IGenericRepository<VisaApplication> { }
}

View File

@@ -2,8 +2,8 @@
using Infrastructure.Database.Generic;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Database.VisaApplications.Repositories
{
namespace Infrastructure.Database.VisaApplications.Repositories;
public sealed class VisaApplicationsRepository(IGenericReader reader, IGenericWriter writer, IUnitOfWork unitOfWork)
: GenericRepository<VisaApplication>(reader, writer, unitOfWork), IVisaApplicationsRepository
{
@@ -15,4 +15,3 @@ namespace Infrastructure.Database.VisaApplications.Repositories
.Include(a => a.PastVisits);
}
}
}

View File

@@ -8,8 +8,8 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using DbContext = Infrastructure.Database.DbContext;
namespace Infrastructure
{
namespace Infrastructure;
/// Provides methods to add services to DI-container
public static class DependencyInjection
{
@@ -32,4 +32,3 @@ namespace Infrastructure
return services;
}
}
}

View File

@@ -1,8 +1,8 @@
using System.Reflection;
using Infrastructure;
namespace SchengenVisaApi
{
namespace SchengenVisaApi;
/// Provides methods to add services to DI-container
public static class DependencyInjection
{
@@ -28,4 +28,3 @@ namespace SchengenVisaApi
});
}
}
}

View File

@@ -1,5 +1,4 @@
namespace SchengenVisaApi;
#pragma warning disable CS1591
public class Program
{

View File

@@ -1,5 +1,5 @@
namespace SchengenVisaApi
{
namespace SchengenVisaApi;
/// Provides methods for configuring middleware
public static class PipelineRequest
{
@@ -16,4 +16,3 @@
return app;
}
}
}