Skip to content

Commit

Permalink
Change the table name from Register to Person
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed-Ghanam committed Oct 8, 2024
1 parent e4c7c3e commit e64c189
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 195 deletions.
11 changes: 7 additions & 4 deletions src/Altinn.Profile.Integrations/Entities/MailboxSupplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;

namespace Altinn.Profile.Integrations.Entities;

/// <summary>
/// Represents a mailbox supplier entity.
/// Represents a mailbox supplier in the contact and reservation schema.
/// </summary>
[Table("mailbox_supplier", Schema = "contact_and_reservation")]
[Index("OrgNumberAk", Name = "unique_org_number_ak", IsUnique = true)]
public partial class MailboxSupplier
{
/// <summary>
Expand All @@ -20,16 +23,16 @@ public partial class MailboxSupplier
public int MailboxSupplierId { get; set; }

/// <summary>
/// Gets or sets the organization number.
/// Gets or sets the organization number of the mailbox supplier.
/// </summary>
[Required]
[Column("org_number_ak")]
[StringLength(9)]
public string OrgNumberAk { get; set; }

/// <summary>
/// Gets or sets the collection of registers associated with the mailbox supplier.
/// Gets or sets the collection of people associated with the mailbox supplier.
/// </summary>
[InverseProperty("MailboxSupplierIdFkNavigation")]
public virtual ICollection<Register> Registers { get; set; } = new List<Register>();
public virtual ICollection<Person> People { get; set; } = new List<Person>();
}
2 changes: 1 addition & 1 deletion src/Altinn.Profile.Integrations/Entities/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Altinn.Profile.Integrations.Entities;

/// <summary>
/// Represents a metadata entity.
/// Represents metadata in the contact and reservation schema.
/// </summary>
[Table("metadata", Schema = "contact_and_reservation")]
public partial class Metadata
Expand Down
3 changes: 1 addition & 2 deletions src/Altinn.Profile.Integrations/Entities/Person.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#nullable disable

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using Microsoft.EntityFrameworkCore;

namespace Altinn.Profile.Models;
namespace Altinn.Profile.Integrations.Entities;
/// <summary>
/// Represents a person in the contact and reservation schema.
/// </summary>
Expand Down
116 changes: 0 additions & 116 deletions src/Altinn.Profile.Integrations/Entities/Register.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ namespace Altinn.Profile.Integrations.Mappings;
/// <remarks>
/// This profile defines the mapping rules to convert a <see cref="Register"/> object into a <see cref="UserContactInfo"/> instance.
/// </remarks>
public class RegisterToUserContactInfoProfile : AutoMapper.Profile
public class PersonToUserContactInfoProfile : AutoMapper.Profile
{
/// <summary>
/// Initializes a new instance of the <see cref="RegisterToUserContactInfoProfile"/> class
/// Initializes a new instance of the <see cref="PersonToUserContactInfoProfile"/> class
/// and configures the mappings.
/// </summary>
public RegisterToUserContactInfoProfile()
public PersonToUserContactInfoProfile()
{
CreateMap<Register, UserContactInfo>()
CreateMap<Person, UserContactInfo>()
.ForMember(dest => dest.IsReserved, opt => opt.MapFrom(src => src.Reservation))
.ForMember(dest => dest.EmailAddress, opt => opt.MapFrom(src => src.EmailAddress))
.ForMember(dest => dest.LanguageCode, opt => opt.MapFrom(src => src.LanguageCode))
Expand Down
10 changes: 5 additions & 5 deletions src/Altinn.Profile.Integrations/Persistence/ProfiledbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public ProfileDbContext(DbContextOptions<ProfileDbContext> options)
public virtual DbSet<Metadata> Metadata { get; set; }

/// <summary>
/// Gets or sets the <see cref="DbSet{Register}"/> representing the registers.
/// Gets or sets the <see cref="DbSet{Person}"/> representing the people.
/// </summary>
public virtual DbSet<Register> Registers { get; set; }
public virtual DbSet<Person> People { get; set; }

/// <summary>
/// Configures the schema needed for the context.
Expand All @@ -57,16 +57,16 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.LatestChangeNumber).ValueGeneratedNever();
});

modelBuilder.Entity<Register>(entity =>
modelBuilder.Entity<Person>(entity =>
{
entity.HasKey(e => e.ContactAndReservationUserId).HasName("register_pkey");
entity.HasKey(e => e.ContactAndReservationUserId).HasName("person_pkey");
entity.Property(e => e.ContactAndReservationUserId).UseIdentityAlwaysColumn();
entity.Property(e => e.FnumberAk).IsFixedLength();
entity.Property(e => e.LanguageCode).IsFixedLength();
entity.HasOne(d => d.MailboxSupplierIdFkNavigation)
.WithMany(p => p.Registers)
.WithMany(p => p.People)
.HasConstraintName("fk_mailbox_supplier");
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Altinn.Profile.Integrations.Repositories;
/// <summary>
/// Repository for handling register data.
/// </summary>
public interface IPersonRepository : IRepository<Register>
public interface IPersonRepository : IRepository<Person>
{
/// <summary>
/// Asynchronously retrieves the register data for multiple users by their national identity numbers.
Expand All @@ -19,5 +19,5 @@ public interface IPersonRepository : IRepository<Register>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains a collection of register data for the users.
/// </returns>
Task<ImmutableList<Register>> GetUserContactInfoAsync(IEnumerable<string> nationalIdentityNumbers);
Task<ImmutableList<Person>> GetUserContactInfoAsync(IEnumerable<string> nationalIdentityNumbers);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Altinn.Profile.Integrations.Repositories;
/// Repository for handling register data.
/// </summary>
/// <seealso cref="IPersonRepository" />
internal class PersonRepository : ProfileRepository<Register>, IPersonRepository
internal class PersonRepository : ProfileRepository<Person>, IPersonRepository
{
private readonly ProfileDbContext _context;

Expand All @@ -35,11 +35,11 @@ public PersonRepository(ProfileDbContext context)
/// A task that represents the asynchronous operation. The task result contains a collection of register data for the users.
/// </returns>
/// <exception cref="ArgumentNullException">Thrown when the <paramref name="nationalIdentityNumbers"/> is null.</exception>
public async Task<ImmutableList<Register>> GetUserContactInfoAsync(IEnumerable<string> nationalIdentityNumbers)
public async Task<ImmutableList<Person>> GetUserContactInfoAsync(IEnumerable<string> nationalIdentityNumbers)
{
ArgumentNullException.ThrowIfNull(nationalIdentityNumbers);

var registers = await _context.Registers.Where(e => nationalIdentityNumbers.Contains(e.FnumberAk)).ToListAsync();
var registers = await _context.People.Where(e => nationalIdentityNumbers.Contains(e.FnumberAk)).ToListAsync();

return registers.ToImmutableList();
}
Expand Down
54 changes: 0 additions & 54 deletions src/Altinn.Profile/efpt.config.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class RegisterRepositoryTests : IDisposable
{
private readonly ProfileDbContext _context;
private readonly PersonRepository _registerRepository;
private readonly List<Register> _personContactAndReservationTestData;
private readonly List<Person> _personContactAndReservationTestData;

public RegisterRepositoryTests()
{
Expand All @@ -34,7 +34,7 @@ public RegisterRepositoryTests()

_personContactAndReservationTestData = [.. PersonTestData.GetContactAndReservationTestData()];

_context.Registers.AddRange(_personContactAndReservationTestData);
_context.People.AddRange(_personContactAndReservationTestData);
_context.SaveChanges();
}

Expand Down Expand Up @@ -109,7 +109,7 @@ public async Task GetUserContactInfoAsync_ReturnsEmpty_WhenNotFound()
Assert.Empty(result);
}

private static void AssertRegisterProperties(Register expected, Register actual)
private static void AssertRegisterProperties(Person expected, Person actual)
{
Assert.Equal(expected.FnumberAk, actual.FnumberAk);
Assert.Equal(expected.Description, actual.Description);
Expand Down
2 changes: 1 addition & 1 deletion test/Altinn.Profile.Tests/Testdata/PersonTestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class PersonTestData
/// Gets a list of test registers with predefined contact and reservation data.
/// </summary>
/// <returns>A list of <see cref="Register"/> objects containing test data.</returns>
public static List<Register> GetContactAndReservationTestData()
public static List<Person> GetContactAndReservationTestData()
{
return
[
Expand Down

0 comments on commit e64c189

Please sign in to comment.