├── NuGet.Config ├── Monstarlab.Templates.API.Domain ├── GlobalUsings.cs ├── Monstarlab.Templates.API.Domain.csproj └── Models │ ├── Employee.cs │ └── Department.cs ├── Monstarlab.Templates.API.Web ├── appsettings.Development.json ├── MonstarlabAppSettings.cs ├── DTOs │ ├── DomainDto.cs │ ├── Employee │ │ ├── EmployeeInsertDto.cs │ │ ├── EmployeeUpdateDto.cs │ │ └── EmployeeDto.cs │ └── Department │ │ ├── DepartmentDto.cs │ │ ├── DepartmentInsertDto.cs │ │ └── DepartmentUpdateDto.cs ├── appsettings.json ├── Profiles │ ├── DepartmentProfile.cs │ └── EmployeeProfile.cs ├── Controllers │ ├── DepartmentsController.cs │ ├── EmployeesController.cs │ └── BaseController.cs ├── GlobalUsings.cs ├── Properties │ └── launchSettings.json ├── Program.cs ├── Monstarlab.Templates.API.Web.csproj └── DI.cs ├── Monstarlab.Templates.API.Integrations └── Monstarlab.Templates.API.Integrations.csproj ├── Monstarlab.Templates.API.BusinessLogic ├── GlobalUsings.cs ├── Monstarlab.Templates.API.BusinessLogic.csproj ├── Services │ ├── EmployeeService.cs │ ├── DepartmentService.cs │ └── BaseService.cs └── Interfaces │ └── IEntityService.cs ├── Monstarlab.Templates.API.Infrastructure.Data ├── GlobalUsings.cs ├── Repositories │ └── EmployeeRepository.cs ├── Context │ └── MonstarlabDbContext.cs ├── Monstarlab.Templates.API.Infrastructure.Data.csproj ├── Configurations │ ├── DepartmentConfiguration.cs │ └── EmployeeConfiguration.cs └── Migrations │ ├── 20211116094416_MigrateToMonstarlabEFPackage.cs │ ├── 20211108075032_Initial.cs │ ├── 20211108075032_Initial.Designer.cs │ ├── MonstarlabDbContextModelSnapshot.cs │ └── 20211116094416_MigrateToMonstarlabEFPackage.Designer.cs ├── .github └── workflows │ └── pullrequest.yml ├── Monstarlab.Templates.API.sln └── .gitignore /NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Domain/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Monstarlab.EntityFramework.Extension.Models; 2 | global using System.ComponentModel.DataAnnotations; -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/MonstarlabAppSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web; 2 | 3 | public class MonstarlabAppSettings 4 | { 5 | public string DatabaseConnectionString { get; set; } 6 | } 7 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/DTOs/DomainDto.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.DTOs; 2 | 3 | public class DomainDto 4 | { 5 | public Guid Id { get; set; } 6 | 7 | public DateTime Created { get; set; } 8 | 9 | public DateTime Updated { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Integrations/Monstarlab.Templates.API.Integrations.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.BusinessLogic/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Monstarlab.EntityFramework.Extension.Models; 2 | global using Monstarlab.EntityFramework.Extension.Repositories; 3 | global using Monstarlab.Templates.API.BusinessLogic.Interfaces; 4 | global using Monstarlab.Templates.API.Domain.Models; 5 | global using System.Linq.Expressions; -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/DTOs/Employee/EmployeeInsertDto.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.DTOs.Employee; 2 | 3 | public class EmployeeInsertDto 4 | { 5 | public string FirstName { get; set; } 6 | 7 | public string LastName { get; set; } 8 | 9 | public uint Age { get; set; } 10 | 11 | public Guid DepartmentId { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/DTOs/Employee/EmployeeUpdateDto.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.DTOs.Employee; 2 | 3 | public class EmployeeUpdateDto 4 | { 5 | public string? FirstName { get; set; } 6 | 7 | public string? LastName { get; set; } 8 | 9 | public uint? Age { get; set; } 10 | 11 | public Guid? DepartmentId { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*", 9 | "DatabaseConnectionString": "Server=localhost;Database=MonstarlabApiTemplate;User Id=monstarlab;Password=test1234;MultipleActiveResultSets=true" 10 | } 11 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/Profiles/DepartmentProfile.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.Profiles; 2 | 3 | public class DepartmentProfile : Profile 4 | { 5 | public DepartmentProfile() 6 | { 7 | CreateMap(); 8 | 9 | CreateMap(); 10 | 11 | CreateMap(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/DTOs/Employee/EmployeeDto.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.DTOs.Employee; 2 | 3 | public class EmployeeDto : DomainDto 4 | { 5 | public string FirstName { get; set; } 6 | 7 | public string LastName { get; set; } 8 | 9 | public string FullName => $"{FirstName} {LastName}"; 10 | 11 | public uint Age { get; set; } 12 | 13 | public DepartmentDto Department { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Domain/Monstarlab.Templates.API.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/Profiles/EmployeeProfile.cs: -------------------------------------------------------------------------------- 1 | using Monstarlab.Templates.API.Web.DTOs.Employee; 2 | 3 | namespace Monstarlab.Templates.API.Web.Profiles; 4 | 5 | public class EmployeeProfile : Profile 6 | { 7 | public EmployeeProfile() 8 | { 9 | CreateMap(); 10 | 11 | CreateMap(); 12 | 13 | CreateMap(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Microsoft.EntityFrameworkCore; 2 | global using Microsoft.EntityFrameworkCore.Metadata.Builders; 3 | global using Monstarlab.EntityFramework.Extension.Repositories; 4 | global using Monstarlab.Templates.API.Domain.Models; 5 | global using Monstarlab.Templates.API.Infrastructure.Data.Configurations; 6 | global using Monstarlab.Templates.API.Infrastructure.Data.Context; 7 | global using System.Diagnostics.CodeAnalysis; -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/DTOs/Department/DepartmentDto.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.DTOs.Department; 2 | 3 | public class DepartmentDto : DomainDto 4 | { 5 | public string Country { get; set; } 6 | 7 | public string ZipCode { get; set; } 8 | 9 | public string City { get; set; } 10 | 11 | public string Street { get; set; } 12 | 13 | public string Number { get; set; } 14 | 15 | public string? Floor { get; set; } 16 | 17 | public string? Apartment { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/DTOs/Department/DepartmentInsertDto.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.DTOs.Department; 2 | 3 | public class DepartmentInsertDto 4 | { 5 | public string Country { get; set; } 6 | 7 | public string ZipCode { get; set; } 8 | 9 | public string City { get; set; } 10 | 11 | public string Street { get; set; } 12 | 13 | public string Number { get; set; } 14 | 15 | public string? Floor { get; set; } 16 | 17 | public string? Apartment { get; set; } 18 | } 19 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/DTOs/Department/DepartmentUpdateDto.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.DTOs.Department; 2 | 3 | public class DepartmentUpdateDto 4 | { 5 | public string? Country { get; set; } 6 | 7 | public string? ZipCode { get; set; } 8 | 9 | public string? City { get; set; } 10 | 11 | public string? Street { get; set; } 12 | 13 | public string? Number { get; set; } 14 | 15 | public string? Floor { get; set; } 16 | 17 | public string? Apartment { get; set; } 18 | } -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Repositories/EmployeeRepository.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Infrastructure.Data.Repositories; 2 | 3 | public class EmployeeRepository : EntityRepository 4 | { 5 | public EmployeeRepository(MonstarlabDbContext context) : base(context) 6 | { 7 | } 8 | 9 | protected override IQueryable BaseIncludes() 10 | { 11 | var query = base.BaseIncludes(); 12 | 13 | return query.Include(e => e.Department); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Domain/Models/Employee.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Domain.Models; 2 | 3 | public class Employee : EntityBase 4 | { 5 | [Required] 6 | public string FirstName { get; set; } 7 | 8 | [Required] 9 | public string LastName { get; set; } 10 | 11 | public string FullName => $"{FirstName} {LastName}"; 12 | 13 | [Required] 14 | public uint? Age { get; set; } 15 | 16 | [Required] 17 | public Guid? DepartmentId { get; set; } 18 | 19 | public Department Department { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/Controllers/DepartmentsController.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.Controllers; 2 | 3 | public class DepartmentsController : BaseController 4 | { 5 | public DepartmentsController(IEntityService entityService, IMapper mapper) : base(entityService, mapper) 6 | { 7 | } 8 | 9 | [HttpGet] 10 | public Task>> GetList(int page = 1, int pageSize = 20) => GetAll(page, pageSize); 11 | } 12 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.BusinessLogic/Monstarlab.Templates.API.BusinessLogic.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Domain/Models/Department.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Domain.Models; 2 | 3 | public class Department : EntityBase 4 | { 5 | [Required] 6 | public string Country { get; set; } 7 | 8 | [Required] 9 | public string ZipCode { get; set; } 10 | 11 | [Required] 12 | public string City { get; set; } 13 | 14 | [Required] 15 | public string Street { get; set; } 16 | 17 | [Required] 18 | public string Number { get; set; } 19 | 20 | public string? Floor { get; set; } 21 | 22 | public string? Apartment { get; set; } 23 | 24 | public IEnumerable Employees { get; set; } 25 | } 26 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Context/MonstarlabDbContext.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Infrastructure.Data.Context; 2 | 3 | public class MonstarlabDbContext : DbContext 4 | { 5 | public MonstarlabDbContext([NotNull] DbContextOptions options) : base(options) 6 | { 7 | } 8 | 9 | protected override void OnModelCreating(ModelBuilder modelBuilder) 10 | { 11 | base.OnModelCreating(modelBuilder); 12 | 13 | modelBuilder.ApplyConfiguration(new DepartmentConfiguration()); 14 | modelBuilder.ApplyConfiguration(new EmployeeConfiguration()); 15 | } 16 | 17 | public DbSet Departments { get; set; } 18 | 19 | public DbSet Employees { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using AutoMapper; 2 | global using Microsoft.EntityFrameworkCore; 3 | global using Microsoft.Extensions.Options; 4 | global using Monstarlab.EntityFramework.Extension.Models; 5 | global using Monstarlab.EntityFramework.Extension.Repositories; 6 | global using Monstarlab.Templates.API.BusinessLogic.Interfaces; 7 | global using Monstarlab.Templates.API.BusinessLogic.Services; 8 | global using Monstarlab.Templates.API.Domain.Models; 9 | global using Monstarlab.Templates.API.Infrastructure.Data.Context; 10 | global using Monstarlab.Templates.API.Infrastructure.Data.Repositories; 11 | global using Monstarlab.Templates.API.Web.DTOs.Department; 12 | global using Microsoft.AspNetCore.Mvc; 13 | global using System.Linq.Expressions; 14 | global using System.Net; -------------------------------------------------------------------------------- /.github/workflows/pullrequest.yml: -------------------------------------------------------------------------------- 1 | name: Pull request 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v2 14 | 15 | - name: Setup .NET Core 16 | uses: actions/setup-dotnet@v1 17 | with: 18 | dotnet-version: '6.0.x' 19 | 20 | - name: Clean 21 | run: dotnet clean Monstarlab.Templates.API.sln --configuration Release && dotnet nuget locals all --clear 22 | 23 | - name: Install dependencies 24 | run: dotnet restore Monstarlab.Templates.API.sln 25 | 26 | - name: Build 27 | run: dotnet build Monstarlab.Templates.API.sln --configuration Release --no-restore 28 | 29 | - name: Test 30 | run: dotnet test Monstarlab.Templates.API.sln --configuration Release --no-restore -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Monstarlab.Templates.API.Infrastructure.Data.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:49975", 8 | "sslPort": 44375 9 | } 10 | }, 11 | "profiles": { 12 | "Monstarlab.Templates.API.Web": { 13 | "commandName": "Project", 14 | "dotnetRunMessages": true, 15 | "launchBrowser": true, 16 | "launchUrl": "swagger", 17 | "applicationUrl": "https://localhost:7227;http://localhost:5227", 18 | "environmentVariables": { 19 | "ASPNETCORE_ENVIRONMENT": "Development" 20 | } 21 | }, 22 | "IIS Express": { 23 | "commandName": "IISExpress", 24 | "launchBrowser": true, 25 | "launchUrl": "swagger", 26 | "environmentVariables": { 27 | "ASPNETCORE_ENVIRONMENT": "Development" 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using Monstarlab.Templates.API.Web; 2 | 3 | var builder = WebApplication.CreateBuilder(args); 4 | 5 | // Add services to the container. 6 | 7 | builder.Services.AddControllers(); 8 | builder.Services.AddApiVersioning(config => 9 | { 10 | config.DefaultApiVersion = new ApiVersion(1, 0); 11 | config.AssumeDefaultVersionWhenUnspecified = true; 12 | config.ReportApiVersions = true; 13 | }); 14 | // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle 15 | builder.Services.AddEndpointsApiExplorer(); 16 | builder.Services.AddSwaggerGen(); 17 | 18 | //Put custom DI into another file 19 | builder.SetupDomainServices(); 20 | 21 | var app = builder.Build(); 22 | 23 | // Configure the HTTP request pipeline. 24 | if (app.Environment.IsDevelopment()) 25 | { 26 | app.UseSwagger(); 27 | app.UseSwaggerUI(); 28 | } 29 | 30 | app.UseHttpsRedirection(); 31 | 32 | app.UseAuthorization(); 33 | 34 | app.MapControllers(); 35 | 36 | app.Run(); 37 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.BusinessLogic/Services/EmployeeService.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.BusinessLogic.Services; 2 | 3 | public class EmployeeService : BaseService 4 | { 5 | public EmployeeService(IEntityRepository repository) : base(repository) 6 | { 7 | } 8 | 9 | protected override Task<(bool Result, Exception Error)> ValidateEntity(Employee entity) 10 | { 11 | if (string.IsNullOrWhiteSpace(entity.FirstName)) 12 | return Task.FromResult((false, new ArgumentNullException(nameof(entity.FirstName)) as Exception)); 13 | 14 | if (string.IsNullOrWhiteSpace(entity.LastName)) 15 | return Task.FromResult((false, new ArgumentNullException(nameof(entity.LastName)) as Exception)); 16 | 17 | if (entity.DepartmentId.Equals(Guid.Empty)) 18 | return Task.FromResult((false, new ArgumentException("Department ID was not set", nameof(entity.DepartmentId)) as Exception)); 19 | 20 | return Task.FromResult((true, null as Exception)); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/Controllers/EmployeesController.cs: -------------------------------------------------------------------------------- 1 | using Monstarlab.Templates.API.Web.DTOs.Employee; 2 | 3 | namespace Monstarlab.Templates.API.Web.Controllers; 4 | 5 | public class EmployeesController : BaseController 6 | { 7 | public EmployeesController(IEntityService entityService, IMapper mapper) : base(entityService, mapper) 8 | { 9 | } 10 | 11 | [HttpGet] 12 | [ProducesResponseType((int)HttpStatusCode.OK)] 13 | [ProducesResponseType((int)HttpStatusCode.BadRequest)] 14 | public async Task>> GetAll(int page = 1, int pageSize = 20, Guid? departmentId = null) 15 | { 16 | var employees = await EntityService.GetAllAsync(page, pageSize, departmentId != null ? new Expression>[] { f => f.DepartmentId == departmentId } : null); 17 | 18 | var mappedEntities = new ListWrapper 19 | { 20 | Data = Mapper.Map>(employees.Data), 21 | Meta = employees.Meta 22 | }; 23 | 24 | return new OkObjectResult(mappedEntities); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Configurations/DepartmentConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Infrastructure.Data.Configurations; 2 | 3 | internal class DepartmentConfiguration : IEntityTypeConfiguration 4 | { 5 | internal static Guid AarhusId = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"); 6 | internal static Guid CopenhagenId = new Guid("d8f7f42e-23a6-48b8-af97-a8cc3cb6c58b"); 7 | 8 | public void Configure(EntityTypeBuilder builder) 9 | { 10 | var aarhus = new Department 11 | { 12 | Id = AarhusId, 13 | City = "Aarhus", 14 | Country = "Denmark", 15 | Floor = "9", 16 | Number = "2F", 17 | Street = "Mariane Thomsens Gade", 18 | ZipCode = "8000" 19 | }; 20 | var copenhagen = new Department 21 | { 22 | Id = CopenhagenId, 23 | City = "Copenhagen", 24 | Country = "Denmark", 25 | Street = "Orientkaj", 26 | Number = "4", 27 | ZipCode = "2150" 28 | }; 29 | 30 | builder.HasData(new[] 31 | { 32 | aarhus, 33 | copenhagen 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/Monstarlab.Templates.API.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.BusinessLogic/Services/DepartmentService.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.BusinessLogic.Services; 2 | 3 | public class DepartmentService : BaseService 4 | { 5 | public DepartmentService(IEntityRepository repository) : base(repository) 6 | { 7 | } 8 | 9 | protected override Task<(bool Result, Exception Error)> ValidateEntity(Department entity) 10 | { 11 | if (string.IsNullOrWhiteSpace(entity.City)) 12 | return Task.FromResult((false, new ArgumentNullException(nameof(entity.City)) as Exception)); 13 | 14 | if (string.IsNullOrWhiteSpace(entity.Country)) 15 | return Task.FromResult((false, new ArgumentNullException(nameof(entity.Country)) as Exception)); 16 | 17 | if (string.IsNullOrWhiteSpace(entity.ZipCode)) 18 | return Task.FromResult((false, new ArgumentNullException(nameof(entity.ZipCode)) as Exception)); 19 | 20 | if (string.IsNullOrWhiteSpace(entity.Street)) 21 | return Task.FromResult((false, new ArgumentNullException(nameof(entity.Street)) as Exception)); 22 | 23 | if (string.IsNullOrWhiteSpace(entity.Number)) 24 | return Task.FromResult((false, new ArgumentNullException(nameof(entity.Number)) as Exception)); 25 | 26 | return Task.FromResult((true, null as Exception)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.BusinessLogic/Services/BaseService.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.BusinessLogic.Services; 2 | 3 | public abstract class BaseService : IEntityService where TEntity : EntityBase 4 | { 5 | protected readonly IEntityRepository Repository; 6 | 7 | public BaseService(IEntityRepository repository) 8 | { 9 | Repository = repository ?? throw new ArgumentNullException(nameof(repository)); 10 | } 11 | 12 | public Task GetAsync(TId id) => Repository.GetAsync(id); 13 | 14 | public Task> GetAllAsync(int page, int pageSize, Expression>[]? filters = null) => Repository.GetListAsync(page, pageSize, filters); 15 | 16 | public async Task InsertAsync(TEntity entity) 17 | { 18 | if (entity == null) 19 | throw new ArgumentNullException(nameof(entity)); 20 | 21 | var (result, error) = await ValidateEntity(entity); 22 | 23 | if (!result) 24 | throw error; 25 | 26 | return await Repository.AddAsync(entity); 27 | } 28 | 29 | public Task UpdateAsync(TEntity entity) => Repository.UpdateAsync(entity); 30 | 31 | public Task DeleteAsync(TId id) => Repository.DeleteAsync(id); 32 | 33 | protected abstract Task<(bool Result, Exception Error)> ValidateEntity(TEntity entity); 34 | } 35 | 36 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/DI.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web; 2 | 3 | public static class DI 4 | { 5 | public static void SetupDomainServices(this WebApplicationBuilder builder) 6 | { 7 | builder.Services.AddOptions() 8 | .Configure((settings, configuration) => configuration.Bind(settings)); 9 | 10 | builder.Services.AddAutoMapper(a => a.AllowNullCollections = true, typeof(DI).Assembly); 11 | 12 | builder.Services.AddDbContext((s, options) => 13 | { 14 | var settings = s.GetService>()?.Value ?? throw new ArgumentNullException(); 15 | 16 | options.UseSqlServer(settings.DatabaseConnectionString); 17 | }); 18 | 19 | builder.Services.SetupRepositories(); 20 | 21 | builder.Services.SetupServices(); 22 | } 23 | 24 | private static void SetupRepositories(this IServiceCollection services) 25 | { 26 | services.AddTransient, EntityRepository>(); 27 | services.AddTransient, EmployeeRepository>(); 28 | } 29 | 30 | private static void SetupServices(this IServiceCollection services) 31 | { 32 | services.AddTransient, DepartmentService>(); 33 | services.AddTransient, EmployeeService>(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Configurations/EmployeeConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Infrastructure.Data.Configurations; 2 | 3 | internal class EmployeeConfiguration : IEntityTypeConfiguration 4 | { 5 | public void Configure(EntityTypeBuilder builder) 6 | { 7 | builder 8 | .HasOne(e => e.Department) 9 | .WithMany(d => d.Employees) 10 | .OnDelete(DeleteBehavior.Cascade); 11 | 12 | builder 13 | .HasData(new[] 14 | { 15 | new Employee 16 | { 17 | Id = new Guid("efb8f31e-cdd3-4d6b-96a3-3ee6fe9ae679"), 18 | FirstName = "Morten", 19 | LastName = "Turn Pedersen", 20 | Age = 32, 21 | DepartmentId = DepartmentConfiguration.AarhusId 22 | }, 23 | new Employee 24 | { 25 | Id = new Guid("35607bf7-9a00-489d-bf71-bbdb53f2f7d8"), 26 | FirstName = "Morten", 27 | LastName = "Pløger", 28 | Age = 29, 29 | DepartmentId = DepartmentConfiguration.AarhusId 30 | }, 31 | new Employee 32 | { 33 | Id = new Guid("fa4b4f52-0c8b-4839-bbc1-d33a9bf2ca38"), 34 | FirstName = "Kasper", 35 | LastName = "Welner", 36 | Age = 31, 37 | DepartmentId = DepartmentConfiguration.CopenhagenId 38 | } 39 | }); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.BusinessLogic/Interfaces/IEntityService.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.BusinessLogic.Interfaces; 2 | 3 | public interface IEntityService where TEntity : EntityBase 4 | { 5 | /// 6 | /// Get entity with given 7 | /// 8 | /// The ID of the entity to fetch 9 | /// 10 | Task GetAsync(TId id); 11 | 12 | /// 13 | /// Get all entities 14 | /// 15 | /// Which page to fetch 16 | /// The size of each page 17 | /// 18 | Task> GetAllAsync(int page, int pageSize, Expression>[]? filters = null); 19 | 20 | /// 21 | /// Insert new entity 22 | /// 23 | /// The entity to insert/add 24 | /// 25 | /// 26 | Task InsertAsync(TEntity entity); 27 | 28 | /// 29 | /// Delete the entity with the given 30 | /// 31 | /// The ID of the entity to delete 32 | /// 33 | Task DeleteAsync(TId id); 34 | 35 | /// 36 | /// Update the entity 37 | /// 38 | /// Entity to update 39 | /// 40 | Task UpdateAsync(TEntity entity); 41 | } 42 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Migrations/20211116094416_MigrateToMonstarlabEFPackage.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | #nullable disable 4 | 5 | namespace Monstarlab.Templates.API.Infrastructure.Data.Migrations 6 | { 7 | public partial class MigrateToMonstarlabEFPackage : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.AddColumn( 12 | name: "Created", 13 | table: "Employees", 14 | type: "datetime2", 15 | nullable: false, 16 | defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); 17 | 18 | migrationBuilder.AddColumn( 19 | name: "Updated", 20 | table: "Employees", 21 | type: "datetime2", 22 | nullable: false, 23 | defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); 24 | 25 | migrationBuilder.AddColumn( 26 | name: "Created", 27 | table: "Departments", 28 | type: "datetime2", 29 | nullable: false, 30 | defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); 31 | 32 | migrationBuilder.AddColumn( 33 | name: "Updated", 34 | table: "Departments", 35 | type: "datetime2", 36 | nullable: false, 37 | defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); 38 | 39 | migrationBuilder.Sql($"UPDATE Departments SET Created = '{DateTime.Now.AddMinutes(-1):yyyy-MM-dd HH:mm:ss.fff}', Updated = '{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}'"); 40 | 41 | migrationBuilder.Sql($"UPDATE Employees SET Created = '{DateTime.Now.AddMinutes(-1):yyyy-MM-dd HH:mm:ss.fff}', Updated = '{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}'"); 42 | } 43 | 44 | protected override void Down(MigrationBuilder migrationBuilder) 45 | { 46 | migrationBuilder.DropColumn( 47 | name: "Created", 48 | table: "Employees"); 49 | 50 | migrationBuilder.DropColumn( 51 | name: "Updated", 52 | table: "Employees"); 53 | 54 | migrationBuilder.DropColumn( 55 | name: "Created", 56 | table: "Departments"); 57 | 58 | migrationBuilder.DropColumn( 59 | name: "Updated", 60 | table: "Departments"); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Web/Controllers/BaseController.cs: -------------------------------------------------------------------------------- 1 | namespace Monstarlab.Templates.API.Web.Controllers; 2 | 3 | [Route("api/v{version:apiVersion}/[controller]")] 4 | [ApiController] 5 | [ApiVersion("1.0")] 6 | public abstract class BaseController : ControllerBase 7 | where TEntity : EntityBase 8 | where TDto : class 9 | where TInsertDto : class 10 | where TUpdateDto : class 11 | { 12 | protected readonly IEntityService EntityService; 13 | protected readonly IMapper Mapper; 14 | 15 | public BaseController(IEntityService entityService, IMapper mapper) 16 | { 17 | EntityService = entityService ?? throw new ArgumentNullException(nameof(entityService)); 18 | Mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); 19 | } 20 | 21 | [HttpGet("{id}")] 22 | [ProducesResponseType((int)HttpStatusCode.OK)] 23 | [ProducesResponseType((int)HttpStatusCode.NotFound)] 24 | public virtual async Task> Get(TId id) 25 | { 26 | var entity = await EntityService.GetAsync(id); 27 | 28 | if (entity == null) 29 | return NotFound(); 30 | 31 | var mappedEntity = Mapper.Map(entity); 32 | 33 | return new OkObjectResult(mappedEntity); 34 | } 35 | 36 | protected virtual async Task>> GetAll(int page = 1, int pageSize = 20) 37 | { 38 | var entities = await EntityService.GetAllAsync(page, pageSize); 39 | 40 | var mappedEntities = new ListWrapper 41 | { 42 | Data = Mapper.Map>(entities.Data), 43 | Meta = entities.Meta 44 | }; 45 | 46 | return new OkObjectResult(mappedEntities); 47 | } 48 | 49 | [HttpPost] 50 | [ProducesResponseType((int)HttpStatusCode.OK)] 51 | [ProducesResponseType((int)HttpStatusCode.BadRequest)] 52 | public virtual async Task> Insert(TInsertDto dto) 53 | { 54 | var mappedEntity = Mapper.Map(dto); 55 | 56 | var insertedEntity = await EntityService.InsertAsync(mappedEntity); 57 | 58 | var returnEntity = Mapper.Map(insertedEntity); 59 | 60 | return new OkObjectResult(returnEntity); 61 | } 62 | 63 | [HttpPatch("{id}")] 64 | [ProducesResponseType((int)HttpStatusCode.OK)] 65 | [ProducesResponseType((int)HttpStatusCode.BadRequest)] 66 | public virtual async Task> Update(TId id, TUpdateDto dto) 67 | { 68 | if (id?.Equals(default(TId)) ?? false) 69 | return new BadRequestObjectResult($"{nameof(id)} was not set"); 70 | 71 | if (dto == null) 72 | return new BadRequestObjectResult("No body was set"); 73 | 74 | var mappedEntity = Mapper.Map(dto); 75 | 76 | mappedEntity.Id = id; 77 | 78 | var updatedEntity = await EntityService.UpdateAsync(mappedEntity); 79 | 80 | var returnDto = Mapper.Map(updatedEntity); 81 | 82 | return new OkObjectResult(returnDto); 83 | } 84 | 85 | [HttpDelete("{id}")] 86 | [ProducesResponseType((int)HttpStatusCode.NoContent)] 87 | public virtual async Task Delete(TId id) 88 | { 89 | await EntityService.DeleteAsync(id); 90 | 91 | return new NoContentResult(); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.31825.309 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monstarlab.Templates.API.Web", "Monstarlab.Templates.API.Web\Monstarlab.Templates.API.Web.csproj", "{5AF25A68-BA97-4840-ACD4-1939A676E69A}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monstarlab.Templates.API.Infrastructure.Data", "Monstarlab.Templates.API.Infrastructure.Data\Monstarlab.Templates.API.Infrastructure.Data.csproj", "{16955470-1D8F-471A-B625-C86D5BF5A0E0}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monstarlab.Templates.API.Integrations", "Monstarlab.Templates.API.Integrations\Monstarlab.Templates.API.Integrations.csproj", "{A56E90D5-49A8-446A-B368-419B541FA4A5}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monstarlab.Templates.API.Domain", "Monstarlab.Templates.API.Domain\Monstarlab.Templates.API.Domain.csproj", "{24219700-5888-492A-BFB5-AF6BC4563EB4}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monstarlab.Templates.API.BusinessLogic", "Monstarlab.Templates.API.BusinessLogic\Monstarlab.Templates.API.BusinessLogic.csproj", "{F5A2FBE9-03CC-451C-AF95-EC8CA8B4EF47}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Any CPU = Debug|Any CPU 19 | Release|Any CPU = Release|Any CPU 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {5AF25A68-BA97-4840-ACD4-1939A676E69A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {5AF25A68-BA97-4840-ACD4-1939A676E69A}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {5AF25A68-BA97-4840-ACD4-1939A676E69A}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {5AF25A68-BA97-4840-ACD4-1939A676E69A}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {16955470-1D8F-471A-B625-C86D5BF5A0E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {16955470-1D8F-471A-B625-C86D5BF5A0E0}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {16955470-1D8F-471A-B625-C86D5BF5A0E0}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {16955470-1D8F-471A-B625-C86D5BF5A0E0}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {A56E90D5-49A8-446A-B368-419B541FA4A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {A56E90D5-49A8-446A-B368-419B541FA4A5}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {A56E90D5-49A8-446A-B368-419B541FA4A5}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {A56E90D5-49A8-446A-B368-419B541FA4A5}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {24219700-5888-492A-BFB5-AF6BC4563EB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {24219700-5888-492A-BFB5-AF6BC4563EB4}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {24219700-5888-492A-BFB5-AF6BC4563EB4}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {24219700-5888-492A-BFB5-AF6BC4563EB4}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {F5A2FBE9-03CC-451C-AF95-EC8CA8B4EF47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {F5A2FBE9-03CC-451C-AF95-EC8CA8B4EF47}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {F5A2FBE9-03CC-451C-AF95-EC8CA8B4EF47}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {F5A2FBE9-03CC-451C-AF95-EC8CA8B4EF47}.Release|Any CPU.Build.0 = Release|Any CPU 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | GlobalSection(ExtensibilityGlobals) = postSolution 47 | SolutionGuid = {1812CE5F-986A-48DA-B0AA-E1ECC632A46F} 48 | EndGlobalSection 49 | EndGlobal 50 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Migrations/20211108075032_Initial.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | #nullable disable 4 | 5 | namespace Monstarlab.Templates.API.Infrastructure.Data.Migrations 6 | { 7 | public partial class Initial : Migration 8 | { 9 | protected override void Up(MigrationBuilder migrationBuilder) 10 | { 11 | migrationBuilder.CreateTable( 12 | name: "Departments", 13 | columns: table => new 14 | { 15 | Id = table.Column(type: "uniqueidentifier", nullable: false), 16 | Country = table.Column(type: "nvarchar(max)", nullable: false), 17 | ZipCode = table.Column(type: "nvarchar(max)", nullable: false), 18 | City = table.Column(type: "nvarchar(max)", nullable: false), 19 | Street = table.Column(type: "nvarchar(max)", nullable: false), 20 | Number = table.Column(type: "nvarchar(max)", nullable: false), 21 | Floor = table.Column(type: "nvarchar(max)", nullable: true), 22 | Apartment = table.Column(type: "nvarchar(max)", nullable: true) 23 | }, 24 | constraints: table => 25 | { 26 | table.PrimaryKey("PK_Departments", x => x.Id); 27 | }); 28 | 29 | migrationBuilder.CreateTable( 30 | name: "Employees", 31 | columns: table => new 32 | { 33 | Id = table.Column(type: "uniqueidentifier", nullable: false), 34 | FirstName = table.Column(type: "nvarchar(max)", nullable: false), 35 | LastName = table.Column(type: "nvarchar(max)", nullable: false), 36 | Age = table.Column(type: "bigint", nullable: false), 37 | DepartmentId = table.Column(type: "uniqueidentifier", nullable: false) 38 | }, 39 | constraints: table => 40 | { 41 | table.PrimaryKey("PK_Employees", x => x.Id); 42 | table.ForeignKey( 43 | name: "FK_Employees_Departments_DepartmentId", 44 | column: x => x.DepartmentId, 45 | principalTable: "Departments", 46 | principalColumn: "Id", 47 | onDelete: ReferentialAction.Cascade); 48 | }); 49 | 50 | migrationBuilder.InsertData( 51 | table: "Departments", 52 | columns: new[] { "Id", "Apartment", "City", "Country", "Floor", "Number", "Street", "ZipCode" }, 53 | values: new object[] { new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), null, "Aarhus", "Denmark", "9", "2F", "Mariane Thomsens Gade", "8000" }); 54 | 55 | migrationBuilder.InsertData( 56 | table: "Departments", 57 | columns: new[] { "Id", "Apartment", "City", "Country", "Floor", "Number", "Street", "ZipCode" }, 58 | values: new object[] { new Guid("d8f7f42e-23a6-48b8-af97-a8cc3cb6c58b"), null, "Copenhagen", "Denmark", null, "4", "Orientkaj", "2150" }); 59 | 60 | migrationBuilder.InsertData( 61 | table: "Employees", 62 | columns: new[] { "Id", "Age", "DepartmentId", "FirstName", "LastName" }, 63 | values: new object[] { new Guid("35607bf7-9a00-489d-bf71-bbdb53f2f7d8"), 29L, new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), "Morten", "Pløger" }); 64 | 65 | migrationBuilder.InsertData( 66 | table: "Employees", 67 | columns: new[] { "Id", "Age", "DepartmentId", "FirstName", "LastName" }, 68 | values: new object[] { new Guid("efb8f31e-cdd3-4d6b-96a3-3ee6fe9ae679"), 32L, new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), "Morten", "Turn Pedersen" }); 69 | 70 | migrationBuilder.InsertData( 71 | table: "Employees", 72 | columns: new[] { "Id", "Age", "DepartmentId", "FirstName", "LastName" }, 73 | values: new object[] { new Guid("fa4b4f52-0c8b-4839-bbc1-d33a9bf2ca38"), 31L, new Guid("d8f7f42e-23a6-48b8-af97-a8cc3cb6c58b"), "Kasper", "Welner" }); 74 | 75 | migrationBuilder.CreateIndex( 76 | name: "IX_Employees_DepartmentId", 77 | table: "Employees", 78 | column: "DepartmentId"); 79 | } 80 | 81 | protected override void Down(MigrationBuilder migrationBuilder) 82 | { 83 | migrationBuilder.DropTable( 84 | name: "Employees"); 85 | 86 | migrationBuilder.DropTable( 87 | name: "Departments"); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Migrations/20211108075032_Initial.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | using Monstarlab.Templates.API.Infrastructure.Data.Context; 9 | 10 | #nullable disable 11 | 12 | namespace Monstarlab.Templates.API.Infrastructure.Data.Migrations 13 | { 14 | [DbContext(typeof(MonstarlabDbContext))] 15 | [Migration("20211108075032_Initial")] 16 | partial class Initial 17 | { 18 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 19 | { 20 | #pragma warning disable 612, 618 21 | modelBuilder 22 | .HasAnnotation("ProductVersion", "6.0.0") 23 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 24 | 25 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); 26 | 27 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Department", b => 28 | { 29 | b.Property("Id") 30 | .ValueGeneratedOnAdd() 31 | .HasColumnType("uniqueidentifier"); 32 | 33 | b.Property("Apartment") 34 | .HasColumnType("nvarchar(max)"); 35 | 36 | b.Property("City") 37 | .IsRequired() 38 | .HasColumnType("nvarchar(max)"); 39 | 40 | b.Property("Country") 41 | .IsRequired() 42 | .HasColumnType("nvarchar(max)"); 43 | 44 | b.Property("Floor") 45 | .HasColumnType("nvarchar(max)"); 46 | 47 | b.Property("Number") 48 | .IsRequired() 49 | .HasColumnType("nvarchar(max)"); 50 | 51 | b.Property("Street") 52 | .IsRequired() 53 | .HasColumnType("nvarchar(max)"); 54 | 55 | b.Property("ZipCode") 56 | .IsRequired() 57 | .HasColumnType("nvarchar(max)"); 58 | 59 | b.HasKey("Id"); 60 | 61 | b.ToTable("Departments"); 62 | 63 | b.HasData( 64 | new 65 | { 66 | Id = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), 67 | City = "Aarhus", 68 | Country = "Denmark", 69 | Floor = "9", 70 | Number = "2F", 71 | Street = "Mariane Thomsens Gade", 72 | ZipCode = "8000" 73 | }, 74 | new 75 | { 76 | Id = new Guid("d8f7f42e-23a6-48b8-af97-a8cc3cb6c58b"), 77 | City = "Copenhagen", 78 | Country = "Denmark", 79 | Number = "4", 80 | Street = "Orientkaj", 81 | ZipCode = "2150" 82 | }); 83 | }); 84 | 85 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Employee", b => 86 | { 87 | b.Property("Id") 88 | .ValueGeneratedOnAdd() 89 | .HasColumnType("uniqueidentifier"); 90 | 91 | b.Property("Age") 92 | .HasColumnType("bigint"); 93 | 94 | b.Property("DepartmentId") 95 | .HasColumnType("uniqueidentifier"); 96 | 97 | b.Property("FirstName") 98 | .IsRequired() 99 | .HasColumnType("nvarchar(max)"); 100 | 101 | b.Property("LastName") 102 | .IsRequired() 103 | .HasColumnType("nvarchar(max)"); 104 | 105 | b.HasKey("Id"); 106 | 107 | b.HasIndex("DepartmentId"); 108 | 109 | b.ToTable("Employees"); 110 | 111 | b.HasData( 112 | new 113 | { 114 | Id = new Guid("efb8f31e-cdd3-4d6b-96a3-3ee6fe9ae679"), 115 | Age = 32L, 116 | DepartmentId = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), 117 | FirstName = "Morten", 118 | LastName = "Turn Pedersen" 119 | }, 120 | new 121 | { 122 | Id = new Guid("35607bf7-9a00-489d-bf71-bbdb53f2f7d8"), 123 | Age = 29L, 124 | DepartmentId = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), 125 | FirstName = "Morten", 126 | LastName = "Pløger" 127 | }, 128 | new 129 | { 130 | Id = new Guid("fa4b4f52-0c8b-4839-bbc1-d33a9bf2ca38"), 131 | Age = 31L, 132 | DepartmentId = new Guid("d8f7f42e-23a6-48b8-af97-a8cc3cb6c58b"), 133 | FirstName = "Kasper", 134 | LastName = "Welner" 135 | }); 136 | }); 137 | 138 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Employee", b => 139 | { 140 | b.HasOne("Monstarlab.Templates.API.Domain.Models.Department", "Department") 141 | .WithMany("Employees") 142 | .HasForeignKey("DepartmentId") 143 | .OnDelete(DeleteBehavior.Cascade) 144 | .IsRequired(); 145 | 146 | b.Navigation("Department"); 147 | }); 148 | 149 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Department", b => 150 | { 151 | b.Navigation("Employees"); 152 | }); 153 | #pragma warning restore 612, 618 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Migrations/MonstarlabDbContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 7 | using Monstarlab.Templates.API.Infrastructure.Data.Context; 8 | 9 | #nullable disable 10 | 11 | namespace Monstarlab.Templates.API.Infrastructure.Data.Migrations 12 | { 13 | [DbContext(typeof(MonstarlabDbContext))] 14 | partial class MonstarlabDbContextModelSnapshot : ModelSnapshot 15 | { 16 | protected override void BuildModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "6.0.0") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 22 | 23 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); 24 | 25 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Department", b => 26 | { 27 | b.Property("Id") 28 | .ValueGeneratedOnAdd() 29 | .HasColumnType("uniqueidentifier"); 30 | 31 | b.Property("Apartment") 32 | .HasColumnType("nvarchar(max)"); 33 | 34 | b.Property("City") 35 | .IsRequired() 36 | .HasColumnType("nvarchar(max)"); 37 | 38 | b.Property("Country") 39 | .IsRequired() 40 | .HasColumnType("nvarchar(max)"); 41 | 42 | b.Property("Created") 43 | .HasColumnType("datetime2"); 44 | 45 | b.Property("Floor") 46 | .HasColumnType("nvarchar(max)"); 47 | 48 | b.Property("Number") 49 | .IsRequired() 50 | .HasColumnType("nvarchar(max)"); 51 | 52 | b.Property("Street") 53 | .IsRequired() 54 | .HasColumnType("nvarchar(max)"); 55 | 56 | b.Property("Updated") 57 | .HasColumnType("datetime2"); 58 | 59 | b.Property("ZipCode") 60 | .IsRequired() 61 | .HasColumnType("nvarchar(max)"); 62 | 63 | b.HasKey("Id"); 64 | 65 | b.ToTable("Departments", (string)null); 66 | 67 | b.HasData( 68 | new 69 | { 70 | Id = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), 71 | City = "Aarhus", 72 | Country = "Denmark", 73 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 74 | Floor = "9", 75 | Number = "2F", 76 | Street = "Mariane Thomsens Gade", 77 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 78 | ZipCode = "8000" 79 | }, 80 | new 81 | { 82 | Id = new Guid("d8f7f42e-23a6-48b8-af97-a8cc3cb6c58b"), 83 | City = "Copenhagen", 84 | Country = "Denmark", 85 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 86 | Number = "4", 87 | Street = "Orientkaj", 88 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 89 | ZipCode = "2150" 90 | }); 91 | }); 92 | 93 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Employee", b => 94 | { 95 | b.Property("Id") 96 | .ValueGeneratedOnAdd() 97 | .HasColumnType("uniqueidentifier"); 98 | 99 | b.Property("Age") 100 | .HasColumnType("bigint"); 101 | 102 | b.Property("Created") 103 | .HasColumnType("datetime2"); 104 | 105 | b.Property("DepartmentId") 106 | .HasColumnType("uniqueidentifier"); 107 | 108 | b.Property("FirstName") 109 | .IsRequired() 110 | .HasColumnType("nvarchar(max)"); 111 | 112 | b.Property("LastName") 113 | .IsRequired() 114 | .HasColumnType("nvarchar(max)"); 115 | 116 | b.Property("Updated") 117 | .HasColumnType("datetime2"); 118 | 119 | b.HasKey("Id"); 120 | 121 | b.HasIndex("DepartmentId"); 122 | 123 | b.ToTable("Employees", (string)null); 124 | 125 | b.HasData( 126 | new 127 | { 128 | Id = new Guid("efb8f31e-cdd3-4d6b-96a3-3ee6fe9ae679"), 129 | Age = 32L, 130 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 131 | DepartmentId = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), 132 | FirstName = "Morten", 133 | LastName = "Turn Pedersen", 134 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) 135 | }, 136 | new 137 | { 138 | Id = new Guid("35607bf7-9a00-489d-bf71-bbdb53f2f7d8"), 139 | Age = 29L, 140 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 141 | DepartmentId = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), 142 | FirstName = "Morten", 143 | LastName = "Pløger", 144 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) 145 | }, 146 | new 147 | { 148 | Id = new Guid("fa4b4f52-0c8b-4839-bbc1-d33a9bf2ca38"), 149 | Age = 31L, 150 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 151 | DepartmentId = new Guid("d8f7f42e-23a6-48b8-af97-a8cc3cb6c58b"), 152 | FirstName = "Kasper", 153 | LastName = "Welner", 154 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) 155 | }); 156 | }); 157 | 158 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Employee", b => 159 | { 160 | b.HasOne("Monstarlab.Templates.API.Domain.Models.Department", "Department") 161 | .WithMany("Employees") 162 | .HasForeignKey("DepartmentId") 163 | .OnDelete(DeleteBehavior.Cascade) 164 | .IsRequired(); 165 | 166 | b.Navigation("Department"); 167 | }); 168 | 169 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Department", b => 170 | { 171 | b.Navigation("Employees"); 172 | }); 173 | #pragma warning restore 612, 618 174 | } 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /Monstarlab.Templates.API.Infrastructure.Data/Migrations/20211116094416_MigrateToMonstarlabEFPackage.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | using Monstarlab.Templates.API.Infrastructure.Data.Context; 9 | 10 | #nullable disable 11 | 12 | namespace Monstarlab.Templates.API.Infrastructure.Data.Migrations 13 | { 14 | [DbContext(typeof(MonstarlabDbContext))] 15 | [Migration("20211116094416_MigrateToMonstarlabEFPackage")] 16 | partial class MigrateToMonstarlabEFPackage 17 | { 18 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 19 | { 20 | #pragma warning disable 612, 618 21 | modelBuilder 22 | .HasAnnotation("ProductVersion", "6.0.0") 23 | .HasAnnotation("Relational:MaxIdentifierLength", 128); 24 | 25 | SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); 26 | 27 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Department", b => 28 | { 29 | b.Property("Id") 30 | .ValueGeneratedOnAdd() 31 | .HasColumnType("uniqueidentifier"); 32 | 33 | b.Property("Apartment") 34 | .HasColumnType("nvarchar(max)"); 35 | 36 | b.Property("City") 37 | .IsRequired() 38 | .HasColumnType("nvarchar(max)"); 39 | 40 | b.Property("Country") 41 | .IsRequired() 42 | .HasColumnType("nvarchar(max)"); 43 | 44 | b.Property("Created") 45 | .HasColumnType("datetime2"); 46 | 47 | b.Property("Floor") 48 | .HasColumnType("nvarchar(max)"); 49 | 50 | b.Property("Number") 51 | .IsRequired() 52 | .HasColumnType("nvarchar(max)"); 53 | 54 | b.Property("Street") 55 | .IsRequired() 56 | .HasColumnType("nvarchar(max)"); 57 | 58 | b.Property("Updated") 59 | .HasColumnType("datetime2"); 60 | 61 | b.Property("ZipCode") 62 | .IsRequired() 63 | .HasColumnType("nvarchar(max)"); 64 | 65 | b.HasKey("Id"); 66 | 67 | b.ToTable("Departments"); 68 | 69 | b.HasData( 70 | new 71 | { 72 | Id = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), 73 | City = "Aarhus", 74 | Country = "Denmark", 75 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 76 | Floor = "9", 77 | Number = "2F", 78 | Street = "Mariane Thomsens Gade", 79 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 80 | ZipCode = "8000" 81 | }, 82 | new 83 | { 84 | Id = new Guid("d8f7f42e-23a6-48b8-af97-a8cc3cb6c58b"), 85 | City = "Copenhagen", 86 | Country = "Denmark", 87 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 88 | Number = "4", 89 | Street = "Orientkaj", 90 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 91 | ZipCode = "2150" 92 | }); 93 | }); 94 | 95 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Employee", b => 96 | { 97 | b.Property("Id") 98 | .ValueGeneratedOnAdd() 99 | .HasColumnType("uniqueidentifier"); 100 | 101 | b.Property("Age") 102 | .HasColumnType("bigint"); 103 | 104 | b.Property("Created") 105 | .HasColumnType("datetime2"); 106 | 107 | b.Property("DepartmentId") 108 | .HasColumnType("uniqueidentifier"); 109 | 110 | b.Property("FirstName") 111 | .IsRequired() 112 | .HasColumnType("nvarchar(max)"); 113 | 114 | b.Property("LastName") 115 | .IsRequired() 116 | .HasColumnType("nvarchar(max)"); 117 | 118 | b.Property("Updated") 119 | .HasColumnType("datetime2"); 120 | 121 | b.HasKey("Id"); 122 | 123 | b.HasIndex("DepartmentId"); 124 | 125 | b.ToTable("Employees"); 126 | 127 | b.HasData( 128 | new 129 | { 130 | Id = new Guid("efb8f31e-cdd3-4d6b-96a3-3ee6fe9ae679"), 131 | Age = 32L, 132 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 133 | DepartmentId = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), 134 | FirstName = "Morten", 135 | LastName = "Turn Pedersen", 136 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) 137 | }, 138 | new 139 | { 140 | Id = new Guid("35607bf7-9a00-489d-bf71-bbdb53f2f7d8"), 141 | Age = 29L, 142 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 143 | DepartmentId = new Guid("4f1759f7-58fa-429b-a7b9-2fb375258df3"), 144 | FirstName = "Morten", 145 | LastName = "Pløger", 146 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) 147 | }, 148 | new 149 | { 150 | Id = new Guid("fa4b4f52-0c8b-4839-bbc1-d33a9bf2ca38"), 151 | Age = 31L, 152 | Created = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 153 | DepartmentId = new Guid("d8f7f42e-23a6-48b8-af97-a8cc3cb6c58b"), 154 | FirstName = "Kasper", 155 | LastName = "Welner", 156 | Updated = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified) 157 | }); 158 | }); 159 | 160 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Employee", b => 161 | { 162 | b.HasOne("Monstarlab.Templates.API.Domain.Models.Department", "Department") 163 | .WithMany("Employees") 164 | .HasForeignKey("DepartmentId") 165 | .OnDelete(DeleteBehavior.Cascade) 166 | .IsRequired(); 167 | 168 | b.Navigation("Department"); 169 | }); 170 | 171 | modelBuilder.Entity("Monstarlab.Templates.API.Domain.Models.Department", b => 172 | { 173 | b.Navigation("Employees"); 174 | }); 175 | #pragma warning restore 612, 618 176 | } 177 | } 178 | } 179 | --------------------------------------------------------------------------------