Skip to content

Commit

Permalink
add: QualificationType Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nixhantb committed Mar 19, 2024
1 parent c2d0cb1 commit 0dce94f
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using JobLeet.WebApi.JobLeet.Api.Logging;
using JobLeet.WebApi.JobLeet.Api.Models.Common.V1;
using JobLeet.WebApi.JobLeet.Core.Interfaces.Common.V1;
using Microsoft.AspNetCore.Components;

namespace JobLeet.WebApi.JobLeet.Api.Controllers.Common.V1
{
[Route("api/v1/qualification-types")]
public class QualificationController : BaseApiController<QualificationModel, IQualificationTypeRepository>
{
public QualificationController(IQualificationTypeRepository qualificationTypeRepository, ILoggerManagerV1 logger)
: base(qualificationTypeRepository, logger)
{

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ public BaseDBContext(DbContextOptions<BaseDBContext> options) : base(options)
public virtual DbSet<Email> Emails { get; set; }
public virtual DbSet<Skill> Skills { get; set; }
public virtual DbSet<PersonName> PersonNames { get; set; }
// public virtual DbSet<Qualification> Qualifications { get; set; }
public virtual DbSet<Qualification> Qualifications { get; set; }
public virtual DbSet<Experience> Experiences { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new EmailConfiguration());
modelBuilder.ApplyConfiguration(new SkillConfiguration());
modelBuilder.ApplyConfiguration(new PersonNameConfiguration());
modelBuilder.ApplyConfiguration(new ExperienceConfiguration());
modelBuilder.ApplyConfiguration(new QualificationConfiguration());
base.OnModelCreating(modelBuilder);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using JobLeet.WebApi.JobLeet.Core.Entities.Common.V1;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace JobLeet.WebApi.JobLeet.Infrastructure.Data.Contexts.V1
{
public class QualificationConfiguration : IEntityTypeConfiguration<Qualification>
{
public void Configure(EntityTypeBuilder<Qualification> builer)
{
builer.ToTable("Qualification");
builer.HasKey(e => e.Id);
builer.Property(e => e.Id).HasColumnName("qualification_id");
builer.Property(e => e.QualificationType).HasColumnName("qualification_type");
builer.Property(e => e.QualificationInformation).HasColumnName("qualification_information");
builer.OwnsOne(qualification => qualification.MetaData);

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ namespace JobLeet.WebApi.JobLeet.Infrastructure.Repositories.Common.V1
{
public class ExperienceRepository : IExperienceRepository
{
#region Initialization
// <returns>The list of initializations</returns>
private readonly BaseDBContext _dbContext;
public ExperienceRepository(BaseDBContext dbContext)
{
_dbContext = dbContext;
}
#endregion
public Task AddAsync(ExperienceModel entity)
{
throw new NotImplementedException();
Expand All @@ -23,6 +26,10 @@ public Task DeleteAsync(int id)
throw new NotImplementedException();
}

#region Retrieve Experience Asynchronously
/// <returns>The list of experiences.</returns>
/// <exception cref="Exception">Thrown when there is an error while fetching data from the database.</exception>
/// <remarks>This method fetches all experiences from the database using Entity Framework Core.</remarks>
public Task<List<ExperienceModel>> GetAllAsync()
{
try
Expand All @@ -40,12 +47,17 @@ public Task<List<ExperienceModel>> GetAllAsync()
throw new Exception("Error while fetching the database. Please try again later " + ex.Message);
}
}
#endregion

#region Retrieve Experience ID Asynchronously
/// <returns>The list of experience Id's.</returns>
/// <exception cref="Exception">Thrown when there is an error while fetching data from the database.</exception>
/// <remarks>This method fetches all experience Id's from the database using Entity Framework Core.</remarks>
public Task<ExperienceModel> GetByIdAsync(int id)
{
throw new NotImplementedException();
}

#endregion
public Task UpdateAsync(ExperienceModel entity)
{
throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ namespace JobLeet.WebApi.JobLeet.Infrastructure.Repositories.Common.V1
public class QualificationTypeRepository : IQualificationTypeRepository
{
private readonly BaseDBContext _dbContext;
public QualificationTypeRepository(BaseDBContext dbContext)
{
_dbContext = dbContext;
}
public Task AddAsync(QualificationModel entity)
{
throw new NotImplementedException();
Expand All @@ -20,22 +24,23 @@ public Task DeleteAsync(int id)

public async Task<List<QualificationModel>> GetAllAsync()
{
/*
try
{
var result = await _dbContext.Qualifications
.Select(e => new QualificationModel
{ Id = e.Id,
QualificationType = (QualificationCategory)e.QualificationType,
}).ToListAsync();
.Select(e => new QualificationModel
{
Id = e.Id,
QualificationType = e.QualificationType.Select(x => (QualificationCategory)x).ToList(),
QualificationInformation = e.QualificationInformation
})
.ToListAsync();

return result;
}
catch(DbUpdateException ex)
catch (DbUpdateException ex)
{
throw new Exception("Error while fetching the database. Please try again later"+ ex.Message);
throw new Exception("Error while fetching the database. Please try again later" + ex.Message);
}
*/
throw new NotImplementedException();
}

public Task<QualificationModel> GetByIdAsync(int id)
Expand Down
1 change: 1 addition & 0 deletions JobLeet.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
builder.Services.AddScoped<ISkillRepository, SkillRepository>();
builder.Services.AddScoped<IPersonNameRepository, PersonNameRepository>();
builder.Services.AddScoped<IExperienceRepository, ExperienceRepository>();
builder.Services.AddScoped<IQualificationTypeRepository, QualificationTypeRepository>();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
Expand Down

0 comments on commit 0dce94f

Please sign in to comment.