#25 Ads BE implementation

Samengevoegd
safet.purkovic heeft 1 commits samengevoegd van feature/1514_ads_be_implementation naar BE_dev 3 jaren geleden
  1. 18
    0
      Diligent.WebAPI.Business/MappingProfiles/AdMappingProfile.cs
  2. 13
    0
      Diligent.WebAPI.Business/MappingProfiles/TechnologyMappingProfile.cs
  3. 60
    0
      Diligent.WebAPI.Business/Services/AdService.cs
  4. 16
    0
      Diligent.WebAPI.Business/Services/Interfaces/IAdService.cs
  5. 1
    2
      Diligent.WebAPI.Business/Services/Interfaces/IApplicantService.cs
  6. 10
    0
      Diligent.WebAPI.Business/Services/Interfaces/ITechnologyService.cs
  7. 33
    0
      Diligent.WebAPI.Business/Services/TechnologyService.cs
  8. 3
    3
      Diligent.WebAPI.Business/Services/UserService.cs
  9. 3
    0
      Diligent.WebAPI.Business/Usings.cs
  10. 25
    0
      Diligent.WebAPI.Contracts/DTOs/Ad/AdCreateDto.cs
  11. 27
    0
      Diligent.WebAPI.Contracts/DTOs/Ad/AdResponseDto.cs
  12. 25
    0
      Diligent.WebAPI.Contracts/DTOs/Ad/AdUpdateDto.cs
  13. 15
    0
      Diligent.WebAPI.Contracts/DTOs/Technology/TechnologyResponseDto.cs
  14. 1
    1
      Diligent.WebAPI.Contracts/Usings.cs
  15. 1
    0
      Diligent.WebAPI.Data/DatabaseContext.cs
  16. 24
    0
      Diligent.WebAPI.Data/Entities/Ad.cs
  17. 1
    0
      Diligent.WebAPI.Data/Entities/Applicant.cs
  18. 3
    0
      Diligent.WebAPI.Data/Entities/Technology.cs
  19. 788
    0
      Diligent.WebAPI.Data/Migrations/20221103144335_AddedAd.Designer.cs
  20. 70
    0
      Diligent.WebAPI.Data/Migrations/20221103144335_AddedAd.cs
  21. 68
    0
      Diligent.WebAPI.Data/Migrations/DatabaseContextModelSnapshot.cs
  22. 45
    0
      Diligent.WebAPI.Host/Controllers/V1/AdsController.cs
  23. 23
    0
      Diligent.WebAPI.Host/Controllers/V1/TechnologiesController.cs
  24. 2
    0
      Diligent.WebAPI.Host/Extensions/BusinessConfigurationExtension.cs
  25. 1
    0
      Diligent.WebAPI.Host/Usings.cs

+ 18
- 0
Diligent.WebAPI.Business/MappingProfiles/AdMappingProfile.cs Bestand weergeven

@@ -0,0 +1,18 @@

namespace Diligent.WebAPI.Business.MappingProfiles
{
public class AdMappingProfile : Profile
{
public AdMappingProfile()
{
#region DTO to Model
CreateMap<AdCreateDto, Ad>();
CreateMap<AdUpdateDto, Ad>();
#endregion

#region Model to DTO
CreateMap<Ad, AdResponseDto>();
#endregion
}
}
}

+ 13
- 0
Diligent.WebAPI.Business/MappingProfiles/TechnologyMappingProfile.cs Bestand weergeven

@@ -0,0 +1,13 @@

namespace Diligent.WebAPI.Business.MappingProfiles
{
public class TechnologyMappingProfile : Profile
{
public TechnologyMappingProfile()
{
#region Model to DTO
CreateMap<Technology, TechnologyResponseDto>();
#endregion
}
}
}

+ 60
- 0
Diligent.WebAPI.Business/Services/AdService.cs Bestand weergeven

@@ -0,0 +1,60 @@

namespace Diligent.WebAPI.Business.Services
{
public class AdService : IAdService
{
private readonly DatabaseContext _context;
private readonly IMapper _mapper;

public AdService(DatabaseContext context, IMapper mapper)
{
_context = context;
_mapper = mapper;
}

public async Task<List<AdResponseDto>> GetAllAsync() =>
_mapper.Map<List<AdResponseDto>>(await _context.Ads.ToListAsync());

public async Task<AdResponseDto> GetByIdAsync(int id)
{
var ad = await _context.Ads.FindAsync(id);

if(ad is null)
throw new EntityNotFoundException("Ad not found");

return _mapper.Map<AdResponseDto>(ad);

}

public async Task CreateAsync(AdCreateDto adCreateDto)
{
await _context.Ads.AddAsync(_mapper.Map<Ad>(adCreateDto));

await _context.SaveChangesAsync();
}

public async Task UpdateAsync(int id, AdUpdateDto adUpdateDto)
{
var ad = await _context.Ads.FindAsync(id);

if (ad is null)
throw new EntityNotFoundException("Ad not found");

_mapper.Map(adUpdateDto, ad);

_context.Entry(ad).State = EntityState.Modified;
await _context.SaveChangesAsync();
}

public async Task DeleteAsync(int id)
{
var ad = await _context.Ads.FindAsync(id);

if (ad is null)
throw new EntityNotFoundException("Ad not found");

_context.Ads.Remove(ad);
await _context.SaveChangesAsync();
}
}
}

+ 16
- 0
Diligent.WebAPI.Business/Services/Interfaces/IAdService.cs Bestand weergeven

@@ -0,0 +1,16 @@

namespace Diligent.WebAPI.Business.Services.Interfaces
{
public interface IAdService
{
Task<List<AdResponseDto>> GetAllAsync();

Task<AdResponseDto> GetByIdAsync(int id);

Task CreateAsync(AdCreateDto adCreateDto);

Task UpdateAsync(int id, AdUpdateDto adUpdateDto);

Task DeleteAsync(int id);
}
}

+ 1
- 2
Diligent.WebAPI.Business/Services/Interfaces/IApplicantService.cs Bestand weergeven

@@ -1,5 +1,4 @@
using Diligent.WebAPI.Contracts.DTOs.Applicant;


namespace Diligent.WebAPI.Business.Services.Interfaces
{
public interface IApplicantService

+ 10
- 0
Diligent.WebAPI.Business/Services/Interfaces/ITechnologyService.cs Bestand weergeven

@@ -0,0 +1,10 @@

namespace Diligent.WebAPI.Business.Services.Interfaces
{
public interface ITechnologyService
{
Task<List<TechnologyResponseDto>> GetAllAsync();

Task<TechnologyResponseDto> GetByIdAsync(int id);
}
}

+ 33
- 0
Diligent.WebAPI.Business/Services/TechnologyService.cs Bestand weergeven

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Business.Services
{
public class TechnologyService : ITechnologyService
{
private readonly DatabaseContext _context;
private readonly IMapper _mapper;

public TechnologyService(IMapper mapper, DatabaseContext context)
{
_mapper = mapper;
_context = context;
}

public async Task<List<TechnologyResponseDto>> GetAllAsync() =>
_mapper.Map<List<TechnologyResponseDto>>(await _context.Technologies.ToListAsync());

public async Task<TechnologyResponseDto> GetByIdAsync(int id)
{
var technology = await _context.Technologies.FindAsync(id);

if (technology is null)
throw new EntityNotFoundException("Technology not found");

return _mapper.Map<TechnologyResponseDto>(technology);
}
}
}

+ 3
- 3
Diligent.WebAPI.Business/Services/UserService.cs Bestand weergeven

@@ -224,7 +224,7 @@ namespace Diligent.WebAPI.Business.Services

public async Task<RefreshTokenResultDto> RefreshTokenAsync(RefreshTokenRequestDto model)
{
var validatedToken = GetPrincipalFromToken(model.Token);
var validatedToken = GetPrincipalFromToken(model.Token, false);

if (validatedToken == null)
{
@@ -333,7 +333,7 @@ namespace Diligent.WebAPI.Business.Services
};
}

private ClaimsPrincipal? GetPrincipalFromToken(string token)
private ClaimsPrincipal? GetPrincipalFromToken(string token, bool validateLifetime)
{
var tokenHandler = new JwtSecurityTokenHandler();

@@ -345,7 +345,7 @@ namespace Diligent.WebAPI.Business.Services
ValidateIssuer = false,
ValidateAudience = false,
RequireExpirationTime = false,
ValidateLifetime = true,
ValidateLifetime = validateLifetime,
// set clockskew to zero so tokens expire exactly at token expiration time (instead of 5 minutes later)
//ClockSkew = TimeSpan.Zero
};

+ 3
- 0
Diligent.WebAPI.Business/Usings.cs Bestand weergeven

@@ -9,10 +9,13 @@ global using Diligent.WebAPI.Contracts.DTOs.InsurancePolicy;
global using Diligent.WebAPI.Contracts.DTOs.Insurer;
global using Diligent.WebAPI.Contracts.DTOs.WebhookDefinition;
global using Diligent.WebAPI.Contracts.DTOs.WebhookSubscription;
global using Diligent.WebAPI.Contracts.DTOs.Ad;
global using Diligent.WebAPI.Contracts.DTOs.Auth;
global using Diligent.WebAPI.Contracts.DTOs;
global using Diligent.WebAPI.Contracts.Exceptions;
global using Diligent.WebAPI.Contracts.Models;
global using Diligent.WebAPI.Contracts.DTOs.Applicant;
global using Diligent.WebAPI.Contracts.DTOs.Technology;

global using Microsoft.EntityFrameworkCore;
global using Microsoft.Extensions.Options;

+ 25
- 0
Diligent.WebAPI.Contracts/DTOs/Ad/AdCreateDto.cs Bestand weergeven

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Contracts.DTOs.Ad
{
public class AdCreateDto
{
public string Title { get; set; }

public int MinimumExperience { get; set; }

public DateTime CreatedAt { get; set; }

public DateTime ExpiredAt { get; set; }

public string MainLiabilities { get; set; }

public string Conditions { get; set; }

public string Offer { get; set; }
}
}

+ 27
- 0
Diligent.WebAPI.Contracts/DTOs/Ad/AdResponseDto.cs Bestand weergeven

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Contracts.DTOs.Ad
{
public class AdResponseDto
{
public int Id { get; set; }

public string Title { get; set; }

public int MinimumExperience { get; set; }

public DateTime CreatedAt { get; set; }

public DateTime ExpiredAt { get; set; }

public string MainLiabilities { get; set; }

public string Conditions { get; set; }

public string Offer { get; set; }
}
}

+ 25
- 0
Diligent.WebAPI.Contracts/DTOs/Ad/AdUpdateDto.cs Bestand weergeven

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Contracts.DTOs.Ad
{
public class AdUpdateDto
{
public string Title { get; set; }

public int MinimumExperience { get; set; }

public DateTime CreatedAt { get; set; }

public DateTime ExpiredAt { get; set; }

public string MainLiabilities { get; set; }

public string Conditions { get; set; }

public string Offer { get; set; }
}
}

+ 15
- 0
Diligent.WebAPI.Contracts/DTOs/Technology/TechnologyResponseDto.cs Bestand weergeven

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Contracts.DTOs.Technology
{
public class TechnologyResponseDto
{
public int TechnologyId { get; set; }

public string Name { get; set; }
}
}

+ 1
- 1
Diligent.WebAPI.Contracts/Usings.cs Bestand weergeven

@@ -1,3 +1,3 @@
global using System.Net;
global using Diligent.WebAPI.Contracts.DTOs.InsuranceCompany;
global using System.ComponentModel.DataAnnotations;
global using System.ComponentModel.DataAnnotations;

+ 1
- 0
Diligent.WebAPI.Data/DatabaseContext.cs Bestand weergeven

@@ -10,6 +10,7 @@ public class DatabaseContext : IdentityDbContext<User, AppRole, int>
public DbSet<WebhookSubscription> WebhookSubscriptions { get; set; }
public DbSet<WebhookDefinition> WebhookDefinitions { get; set; }
public DbSet<RefreshToken> RefreshTokens { get; set; }
public DbSet<Ad> Ads { get; set; }
public DbSet<Applicant> Applicants { get; set; }
public DbSet<Technology> Technologies { get; set; }
public DbSet<ApplicantTechnology> ApplicantTechnologies { get; set; }

+ 24
- 0
Diligent.WebAPI.Data/Entities/Ad.cs Bestand weergeven

@@ -0,0 +1,24 @@

namespace Diligent.WebAPI.Data.Entities
{
public class Ad
{
public int Id { get; set; }

public string Title { get; set; }

public int MinimumExperience { get; set; }

public DateTime CreatedAt { get; set; }

public DateTime ExpiredAt { get; set; }

public string MainLiabilities { get; set; }

public string Conditions { get; set; }

public string Offer { get; set; }

public List<Technology> Technologies { get; set; } = new();
}
}

+ 1
- 0
Diligent.WebAPI.Data/Entities/Applicant.cs Bestand weergeven

@@ -15,5 +15,6 @@
public string BitBucketLink { get; set; }
public int Experience { get; set; }
public string ApplicationChannel { get; set; }
public List<ApplicantTechnology> ApplicantTechnologies { get; set; }
}
}

+ 3
- 0
Diligent.WebAPI.Data/Entities/Technology.cs Bestand weergeven

@@ -4,5 +4,8 @@
{
public int TechnologyId { get; set; }
public string Name { get; set; }
public List<ApplicantTechnology> ApplicantTechnologies { get; set; }
public List<Ad> Ads { get; set; } = new();

}
}

+ 788
- 0
Diligent.WebAPI.Data/Migrations/20221103144335_AddedAd.Designer.cs Bestand weergeven

@@ -0,0 +1,788 @@
// <auto-generated />
using System;
using Diligent.WebAPI.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

#nullable disable

namespace Diligent.WebAPI.Data.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20221103144335_AddedAd")]
partial class AddedAd
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 128);

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);

modelBuilder.Entity("AdTechnology", b =>
{
b.Property<int>("AdsId")
.HasColumnType("int");

b.Property<int>("TechnologiesTechnologyId")
.HasColumnType("int");

b.HasKey("AdsId", "TechnologiesTechnologyId");

b.HasIndex("TechnologiesTechnologyId");

b.ToTable("AdTechnology");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Ad", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

b.Property<string>("Conditions")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");

b.Property<DateTime>("ExpiredAt")
.HasColumnType("datetime2");

b.Property<string>("MainLiabilities")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<int>("MinimumExperience")
.HasColumnType("int");

b.Property<string>("Offer")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.HasKey("Id");

b.ToTable("Ads");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Applicant", b =>
{
b.Property<int>("ApplicantId")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ApplicantId"), 1L, 1);

b.Property<string>("ApplicationChannel")
.HasColumnType("nvarchar(max)");

b.Property<string>("BitBucketLink")
.HasColumnType("nvarchar(max)");

b.Property<string>("CV")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<DateTime>("DateOfApplication")
.HasColumnType("datetime2");

b.Property<string>("Email")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");

b.Property<int>("Experience")
.HasColumnType("int");

b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");

b.Property<string>("GithubLink")
.HasColumnType("nvarchar(max)");

b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");

b.Property<string>("LinkedlnLink")
.HasColumnType("nvarchar(max)");

b.Property<string>("PhoneNumber")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");

b.Property<string>("Position")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");

b.HasKey("ApplicantId");

b.ToTable("Applicants");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.ApplicantTechnology", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

b.Property<int>("ApplicantId")
.HasColumnType("int");

b.Property<int>("TechnologyId")
.HasColumnType("int");

b.HasKey("Id");

b.HasIndex("ApplicantId");

b.HasIndex("TechnologyId");

b.ToTable("ApplicantTechnologies");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.AppRole", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");

b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");

b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");

b.HasKey("Id");

b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");

b.ToTable("AspNetRoles", (string)null);
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.InsuranceCompany", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);

b.Property<string>("City")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("Country")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<DateTime>("CreatedAtUtc")
.HasColumnType("datetime2");

b.Property<DateTime?>("DeletedAtUtc")
.HasColumnType("datetime2");

b.Property<string>("Fax")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("LegalAddress")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("LegalEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("PostalCode")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<DateTime?>("UpdatedAtUtc")
.HasColumnType("datetime2");

b.HasKey("Id");

b.ToTable("InsuranceCompanies");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.InsurancePolicy", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);

b.Property<DateTime>("CreatedAtUtc")
.HasColumnType("datetime2");

b.Property<DateTime?>("DeletedAtUtc")
.HasColumnType("datetime2");

b.Property<DateTime>("EndDate")
.HasColumnType("datetime2");

b.Property<long>("InsurerId")
.HasColumnType("bigint");

b.Property<decimal>("Premium")
.HasColumnType("decimal(18,2)");

b.Property<DateTime>("StartDate")
.HasColumnType("datetime2");

b.Property<string>("Type")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<DateTime?>("UpdatedAtUtc")
.HasColumnType("datetime2");

b.HasKey("Id");

b.HasIndex("InsurerId");

b.ToTable("InsurancePolicies");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Insurer", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);

b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("City")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("Country")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<DateTime>("CreatedAtUtc")
.HasColumnType("datetime2");

b.Property<DateTime>("DateOfBirth")
.HasColumnType("datetime2");

b.Property<DateTime?>("DeletedAtUtc")
.HasColumnType("datetime2");

b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<long>("InsuranceCompanyId")
.HasColumnType("bigint");

b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("PostalCode")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<DateTime?>("UpdatedAtUtc")
.HasColumnType("datetime2");

b.HasKey("Id");

b.HasIndex("InsuranceCompanyId");

b.ToTable("Insurers");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.RefreshToken", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");

b.Property<DateTime>("ExpiryDate")
.HasColumnType("datetime2");

b.Property<bool>("Invalidated")
.HasColumnType("bit");

b.Property<string>("JwtId")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("Token")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<bool>("Used")
.HasColumnType("bit");

b.Property<int>("UserId")
.HasColumnType("int");

b.HasKey("Id");

b.HasIndex("UserId");

b.ToTable("RefreshTokens");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Technology", b =>
{
b.Property<int>("TechnologyId")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("TechnologyId"), 1L, 1);

b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");

b.HasKey("TechnologyId");

b.ToTable("Technologies");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

b.Property<int>("AccessFailedCount")
.HasColumnType("int");

b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");

b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");

b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");

b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("LastName")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");

b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");

b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");

b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");

b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");

b.Property<string>("PasswordResetToken")
.HasColumnType("nvarchar(max)");

b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");

b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");

b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");

b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");

b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");

b.HasKey("Id");

b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");

b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");

b.ToTable("AspNetUsers", (string)null);
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.WebhookDefinition", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);

b.Property<DateTime>("CreatedAtUtc")
.HasColumnType("datetime2");

b.Property<DateTime?>("DeletedAtUtc")
.HasColumnType("datetime2");

b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");

b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");

b.Property<DateTime?>("UpdatedAtUtc")
.HasColumnType("datetime2");

b.HasKey("Id");

b.ToTable("WebhookDefinitions");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.WebhookSubscription", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);

b.Property<DateTime>("CreatedAtUtc")
.HasColumnType("datetime2");

b.Property<DateTime?>("DeletedAtUtc")
.HasColumnType("datetime2");

b.Property<bool>("IsActive")
.HasColumnType("bit");

b.Property<DateTime?>("UpdatedAtUtc")
.HasColumnType("datetime2");

b.Property<long>("WebhookDefinitionId")
.HasColumnType("bigint");

b.Property<string>("WebhookURL")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.HasKey("Id");

b.HasIndex("WebhookDefinitionId");

b.ToTable("WebhookSubscriptions");
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");

b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");

b.Property<int>("RoleId")
.HasColumnType("int");

b.HasKey("Id");

b.HasIndex("RoleId");

b.ToTable("AspNetRoleClaims", (string)null);
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");

b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");

b.Property<int>("UserId")
.HasColumnType("int");

b.HasKey("Id");

b.HasIndex("UserId");

b.ToTable("AspNetUserClaims", (string)null);
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(450)");

b.Property<string>("ProviderKey")
.HasColumnType("nvarchar(450)");

b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");

b.Property<int>("UserId")
.HasColumnType("int");

b.HasKey("LoginProvider", "ProviderKey");

b.HasIndex("UserId");

b.ToTable("AspNetUserLogins", (string)null);
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");

b.Property<int>("RoleId")
.HasColumnType("int");

b.HasKey("UserId", "RoleId");

b.HasIndex("RoleId");

b.ToTable("AspNetUserRoles", (string)null);
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.Property<int>("UserId")
.HasColumnType("int");

b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(450)");

b.Property<string>("Name")
.HasColumnType("nvarchar(450)");

b.Property<string>("Value")
.HasColumnType("nvarchar(max)");

b.HasKey("UserId", "LoginProvider", "Name");

b.ToTable("AspNetUserTokens", (string)null);
});

modelBuilder.Entity("AdTechnology", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.Ad", null)
.WithMany()
.HasForeignKey("AdsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.HasOne("Diligent.WebAPI.Data.Entities.Technology", null)
.WithMany()
.HasForeignKey("TechnologiesTechnologyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.ApplicantTechnology", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.Applicant", "Applicant")
.WithMany()
.HasForeignKey("ApplicantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.HasOne("Diligent.WebAPI.Data.Entities.Technology", "Tecnology")
.WithMany()
.HasForeignKey("TechnologyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("Applicant");

b.Navigation("Tecnology");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.InsurancePolicy", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.Insurer", "Insurer")
.WithMany()
.HasForeignKey("InsurerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("Insurer");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Insurer", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.InsuranceCompany", "InsuranceCompany")
.WithMany()
.HasForeignKey("InsuranceCompanyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("InsuranceCompany");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.RefreshToken", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("User");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.WebhookSubscription", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.WebhookDefinition", "WebhookDefinition")
.WithMany()
.HasForeignKey("WebhookDefinitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("WebhookDefinition");
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.AppRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.User", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.User", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.AppRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.HasOne("Diligent.WebAPI.Data.Entities.User", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});

modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.User", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

+ 70
- 0
Diligent.WebAPI.Data/Migrations/20221103144335_AddedAd.cs Bestand weergeven

@@ -0,0 +1,70 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Diligent.WebAPI.Data.Migrations
{
public partial class AddedAd : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Ads",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
MinimumExperience = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
ExpiredAt = table.Column<DateTime>(type: "datetime2", nullable: false),
MainLiabilities = table.Column<string>(type: "nvarchar(max)", nullable: false),
Conditions = table.Column<string>(type: "nvarchar(max)", nullable: false),
Offer = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Ads", x => x.Id);
});

migrationBuilder.CreateTable(
name: "AdTechnology",
columns: table => new
{
AdsId = table.Column<int>(type: "int", nullable: false),
TechnologiesTechnologyId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AdTechnology", x => new { x.AdsId, x.TechnologiesTechnologyId });
table.ForeignKey(
name: "FK_AdTechnology_Ads_AdsId",
column: x => x.AdsId,
principalTable: "Ads",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AdTechnology_Technologies_TechnologiesTechnologyId",
column: x => x.TechnologiesTechnologyId,
principalTable: "Technologies",
principalColumn: "TechnologyId",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_AdTechnology_TechnologiesTechnologyId",
table: "AdTechnology",
column: "TechnologiesTechnologyId");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AdTechnology");

migrationBuilder.DropTable(
name: "Ads");
}
}
}

+ 68
- 0
Diligent.WebAPI.Data/Migrations/DatabaseContextModelSnapshot.cs Bestand weergeven

@@ -22,6 +22,59 @@ namespace Diligent.WebAPI.Data.Migrations

SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);

modelBuilder.Entity("AdTechnology", b =>
{
b.Property<int>("AdsId")
.HasColumnType("int");

b.Property<int>("TechnologiesTechnologyId")
.HasColumnType("int");

b.HasKey("AdsId", "TechnologiesTechnologyId");

b.HasIndex("TechnologiesTechnologyId");

b.ToTable("AdTechnology");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Ad", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);

b.Property<string>("Conditions")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");

b.Property<DateTime>("ExpiredAt")
.HasColumnType("datetime2");

b.Property<string>("MainLiabilities")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<int>("MinimumExperience")
.HasColumnType("int");

b.Property<string>("Offer")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");

b.HasKey("Id");

b.ToTable("Ads");
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.Applicant", b =>
{
b.Property<int>("ApplicantId")
@@ -599,6 +652,21 @@ namespace Diligent.WebAPI.Data.Migrations
b.ToTable("AspNetUserTokens", (string)null);
});

modelBuilder.Entity("AdTechnology", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.Ad", null)
.WithMany()
.HasForeignKey("AdsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.HasOne("Diligent.WebAPI.Data.Entities.Technology", null)
.WithMany()
.HasForeignKey("TechnologiesTechnologyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});

modelBuilder.Entity("Diligent.WebAPI.Data.Entities.ApplicantTechnology", b =>
{
b.HasOne("Diligent.WebAPI.Data.Entities.Applicant", "Applicant")

+ 45
- 0
Diligent.WebAPI.Host/Controllers/V1/AdsController.cs Bestand weergeven

@@ -0,0 +1,45 @@

namespace Diligent.WebAPI.Host.Controllers.V1
{
[ApiVersion("1.0")]
[Route("v{version:apiVersion}/ads")]
[ApiController]
public class AdsController : ControllerBase
{
private readonly IAdService _adService;

public AdsController(IAdService adService)
{
_adService = adService;
}

[HttpGet]
public async Task<IActionResult> GetAll() =>
Ok(await _adService.GetAllAsync());

[HttpGet("{id}")]
public async Task<IActionResult> GetById([FromRoute]int id) =>
Ok(await _adService.GetByIdAsync(id));

[HttpPost]
public async Task<IActionResult> Create([FromBody]AdCreateDto request)
{
await _adService.CreateAsync(request);
return StatusCode((int)HttpStatusCode.Created);
}

[HttpPut("{id}")]
public async Task<IActionResult> Update([FromBody] AdUpdateDto request, [FromRoute]int id)
{
await _adService.UpdateAsync(id, request);
return Ok();
}

[HttpDelete("{id}")]
public async Task<IActionResult> DeleteInsurer([FromRoute]int id)
{
await _adService.DeleteAsync(id);
return NoContent();
}
}
}

+ 23
- 0
Diligent.WebAPI.Host/Controllers/V1/TechnologiesController.cs Bestand weergeven

@@ -0,0 +1,23 @@
namespace Diligent.WebAPI.Host.Controllers.V1
{
[ApiVersion("1.0")]
[Route("v{version:apiVersion}/technologies")]
[ApiController]
public class TechnologiesController : ControllerBase
{
private readonly ITechnologyService _technologyService;

public TechnologiesController(ITechnologyService technologyService)
{
_technologyService = technologyService;
}

[HttpGet]
public async Task<IActionResult> GetAll() =>
Ok(await _technologyService.GetAllAsync());

[HttpGet("{id}")]
public async Task<IActionResult> GetById([FromRoute] int id) =>
Ok(await _technologyService.GetByIdAsync(id));
}
}

+ 2
- 0
Diligent.WebAPI.Host/Extensions/BusinessConfigurationExtension.cs Bestand weergeven

@@ -22,6 +22,8 @@
services.AddScoped<IWebhookPublisherService, WebhookPublisherService>();
services.AddScoped<IWebhookPublisherService, WebhookPublisherService>();
services.AddScoped<IApplicantService, ApplicantService>();
services.AddScoped<IAdService, AdService>();
services.AddScoped<ITechnologyService, TechnologyService>();
}

/// <summary>

+ 1
- 0
Diligent.WebAPI.Host/Usings.cs Bestand weergeven

@@ -19,6 +19,7 @@ global using Diligent.WebAPI.Contracts.DTOs.Insurer;
global using Diligent.WebAPI.Contracts.DTOs.WebhookSubscription;
global using Diligent.WebAPI.Contracts.DTOs.WebhookDefinition;
global using Diligent.WebAPI.Contracts.DTOs.Auth;
global using Diligent.WebAPI.Contracts.DTOs.Ad;
global using Diligent.WebAPI.Contracts.Models;

global using Microsoft.AspNetCore.Mvc;

Laden…
Annuleren
Opslaan