Fixed issues
This commit is contained in:
@@ -2,15 +2,14 @@
|
|||||||
|
|
||||||
namespace ApplicationLayer.Services.Applicants.Models;
|
namespace ApplicationLayer.Services.Applicants.Models;
|
||||||
|
|
||||||
/// Model of
|
/// Model of <see cref="Applicant" />
|
||||||
/// <see cref="Applicant" />
|
|
||||||
public class ApplicantModel
|
public class ApplicantModel
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="Applicant.Name" />
|
/// <inheritdoc cref="Applicant.Name" />
|
||||||
public Name Name { get; set; } = null!;
|
public NameModel Name { get; set; } = null!;
|
||||||
|
|
||||||
/// <inheritdoc cref="Applicant.Passport" />
|
/// <inheritdoc cref="Applicant.Passport" />
|
||||||
public Passport Passport { get; set; } = null!;
|
public PassportModel Passport { get; set; } = null!;
|
||||||
|
|
||||||
/// <inheritdoc cref="Applicant.BirthDate" />
|
/// <inheritdoc cref="Applicant.BirthDate" />
|
||||||
public DateTime BirthDate { get; set; }
|
public DateTime BirthDate { get; set; }
|
||||||
@@ -34,16 +33,16 @@ public class ApplicantModel
|
|||||||
public MaritalStatus MaritalStatus { get; set; }
|
public MaritalStatus MaritalStatus { get; set; }
|
||||||
|
|
||||||
/// <inheritdoc cref="Applicant.FatherName" />
|
/// <inheritdoc cref="Applicant.FatherName" />
|
||||||
public Name FatherName { get; set; } = null!;
|
public NameModel FatherName { get; set; } = null!;
|
||||||
|
|
||||||
/// <inheritdoc cref="Applicant.MotherName" />
|
/// <inheritdoc cref="Applicant.MotherName" />
|
||||||
public Name MotherName { get; set; } = null!;
|
public NameModel MotherName { get; set; } = null!;
|
||||||
|
|
||||||
/// <inheritdoc cref="Applicant.JobTitle" />
|
/// <inheritdoc cref="Applicant.JobTitle" />
|
||||||
public string JobTitle { get; set; } = null!;
|
public string JobTitle { get; set; } = null!;
|
||||||
|
|
||||||
/// <inheritdoc cref="Applicant.PlaceOfWork" />
|
/// <inheritdoc cref="Applicant.PlaceOfWork" />
|
||||||
public PlaceOfWork PlaceOfWork { get; set; } = null!;
|
public PlaceOfWorkModel PlaceOfWork { get; set; } = null!;
|
||||||
|
|
||||||
/// <inheritdoc cref="Applicant.IsNonResident" />
|
/// <inheritdoc cref="Applicant.IsNonResident" />
|
||||||
public bool IsNonResident { get; set; }
|
public bool IsNonResident { get; set; }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using ApplicationLayer.Services.Users.Requests;
|
using ApplicationLayer.Services.Users.Models;
|
||||||
|
using ApplicationLayer.Services.Users.Requests;
|
||||||
using Domains.Users;
|
using Domains.Users;
|
||||||
|
|
||||||
namespace ApplicationLayer.Services.Users;
|
namespace ApplicationLayer.Services.Users;
|
||||||
@@ -8,7 +9,7 @@ public interface IUsersService
|
|||||||
{
|
{
|
||||||
/// Returns all user accounts with role of approving authority
|
/// Returns all user accounts with role of approving authority
|
||||||
/// <param name="cancellationToken">Cancellation token</param>
|
/// <param name="cancellationToken">Cancellation token</param>
|
||||||
Task<List<User>> GetAuthoritiesAccountsAsync(CancellationToken cancellationToken);
|
Task<List<UserModel>> GetAuthoritiesAccountsAsync(CancellationToken cancellationToken);
|
||||||
|
|
||||||
/// Changes authentication data for an authority account
|
/// Changes authentication data for an authority account
|
||||||
/// <param name="request"> Request object with identifier of user and new authentication data</param>
|
/// <param name="request"> Request object with identifier of user and new authentication data</param>
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Domains;
|
||||||
|
|
||||||
|
namespace ApplicationLayer.Services.Users.Models
|
||||||
|
{
|
||||||
|
public class UserModel
|
||||||
|
{
|
||||||
|
/// Unique Identifier of user
|
||||||
|
[Required]
|
||||||
|
public Guid Id { get; private set; } = Guid.NewGuid();
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[MaxLength(ConfigurationConstraints.EmailLength)]
|
||||||
|
public string Email { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,15 +2,20 @@
|
|||||||
using ApplicationLayer.Services.AuthServices.Common;
|
using ApplicationLayer.Services.AuthServices.Common;
|
||||||
using ApplicationLayer.Services.AuthServices.NeededServices;
|
using ApplicationLayer.Services.AuthServices.NeededServices;
|
||||||
using ApplicationLayer.Services.Users.Exceptions;
|
using ApplicationLayer.Services.Users.Exceptions;
|
||||||
|
using ApplicationLayer.Services.Users.Models;
|
||||||
using ApplicationLayer.Services.Users.Requests;
|
using ApplicationLayer.Services.Users.Requests;
|
||||||
|
using AutoMapper;
|
||||||
using Domains.Users;
|
using Domains.Users;
|
||||||
|
|
||||||
namespace ApplicationLayer.Services.Users;
|
namespace ApplicationLayer.Services.Users;
|
||||||
|
|
||||||
public class UsersService(IUsersRepository users, IUnitOfWork unitOfWork) : IUsersService
|
public class UsersService(IMapper mapper, IUsersRepository users, IUnitOfWork unitOfWork) : IUsersService
|
||||||
{
|
{
|
||||||
async Task<List<User>> IUsersService.GetAuthoritiesAccountsAsync(CancellationToken cancellationToken) =>
|
async Task<List<UserModel>> IUsersService.GetAuthoritiesAccountsAsync(CancellationToken cancellationToken)
|
||||||
await users.GetAllOfRoleAsync(Role.ApprovingAuthority, cancellationToken);
|
{
|
||||||
|
var userList = await users.GetAllOfRoleAsync(Role.ApprovingAuthority, cancellationToken);
|
||||||
|
return mapper.Map<List<UserModel>>(userList);
|
||||||
|
}
|
||||||
|
|
||||||
async Task IUsersService.ChangeAuthorityAuthDataAsync(ChangeUserAuthDataRequest request, CancellationToken cancellationToken)
|
async Task IUsersService.ChangeAuthorityAuthDataAsync(ChangeUserAuthDataRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,11 +9,14 @@ public class ApplicantProfile : Profile
|
|||||||
{
|
{
|
||||||
public ApplicantProfile()
|
public ApplicantProfile()
|
||||||
{
|
{
|
||||||
CreateMap<Applicant, ApplicantModel>(MemberList.Destination);
|
CreateMap<Applicant, ApplicantModel>(MemberList.Destination).ReverseMap();
|
||||||
|
|
||||||
CreateMap<RegisterApplicantRequest, Applicant>(MemberList.Destination)
|
CreateMap<RegisterApplicantRequest, Applicant>(MemberList.Destination)
|
||||||
.ForMember(a => a.UserId, opts => opts.Ignore())
|
.ForMember(a => a.UserId, opts => opts.Ignore())
|
||||||
.ForMember(a => a.Name,
|
.ForMember(a => a.Name,
|
||||||
opts => opts.MapFrom(r => r.ApplicantName));
|
opts => opts.MapFrom(r => r.ApplicantName));
|
||||||
}
|
|
||||||
|
CreateMap<NameModel, Name>().ReverseMap();
|
||||||
|
CreateMap<PassportModel, Passport>().ReverseMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,11 @@ public class PlaceOfWorkProfile : Profile
|
|||||||
{
|
{
|
||||||
public PlaceOfWorkProfile()
|
public PlaceOfWorkProfile()
|
||||||
{
|
{
|
||||||
CreateMap<PlaceOfWorkModel, PlaceOfWork>(MemberList.Destination)
|
CreateMap<PlaceOfWorkModel, PlaceOfWork>(MemberList.Destination)
|
||||||
.ForMember(p => p.Id,
|
.ForMember(p => p.Id,
|
||||||
opts => opts.UseDestinationValue());
|
opts => opts.UseDestinationValue())
|
||||||
}
|
.ReverseMap();
|
||||||
|
|
||||||
|
CreateMap<AddressModel, Address>().ReverseMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using ApplicationLayer.Services.AuthServices.Common;
|
using ApplicationLayer.Services.AuthServices.Common;
|
||||||
|
using ApplicationLayer.Services.Users.Models;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Domains.Users;
|
using Domains.Users;
|
||||||
|
|
||||||
@@ -8,8 +9,10 @@ public class UserProfile : Profile
|
|||||||
{
|
{
|
||||||
public UserProfile()
|
public UserProfile()
|
||||||
{
|
{
|
||||||
CreateMap<AuthData, User>(MemberList.Destination)
|
CreateMap<AuthData, User>(MemberList.Destination)
|
||||||
.ForMember(u => u.Role,
|
.ForMember(u => u.Role,
|
||||||
opts => opts.Ignore());
|
opts => opts.Ignore());
|
||||||
}
|
|
||||||
|
CreateMap<User, UserModel>(MemberList.Destination);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,16 +9,21 @@ public class VisaApplicationProfile : Profile
|
|||||||
{
|
{
|
||||||
public VisaApplicationProfile()
|
public VisaApplicationProfile()
|
||||||
{
|
{
|
||||||
CreateMap<VisaApplication, VisaApplicationModelForApplicant>(MemberList.Destination);
|
CreateMap<VisaApplication, VisaApplicationModelForApplicant>(MemberList.Destination);
|
||||||
|
|
||||||
CreateMap<VisaApplication, VisaApplicationModelForAuthority>(MemberList.Destination)
|
CreateMap<VisaApplication, VisaApplicationModelForAuthority>(MemberList.Destination)
|
||||||
.ForMember(model => model.Applicant,
|
.ForMember(model => model.Applicant,
|
||||||
opts => opts.Ignore());
|
|
||||||
|
|
||||||
CreateMap<VisaApplicationCreateRequest, VisaApplication>(MemberList.Destination)
|
|
||||||
.ForMember(va => va.RequestDate,
|
|
||||||
opts => opts.Ignore())
|
|
||||||
.ForMember(va => va.ApplicantId,
|
|
||||||
opts => opts.Ignore());
|
opts => opts.Ignore());
|
||||||
}
|
|
||||||
|
CreateMap<VisaApplicationCreateRequest, VisaApplication>(MemberList.Destination)
|
||||||
|
.ForMember(va => va.RequestDate,
|
||||||
|
opts => opts.Ignore())
|
||||||
|
.ForMember(va => va.ApplicantId,
|
||||||
|
opts => opts.Ignore());
|
||||||
|
|
||||||
|
CreateMap<PastVisaModel, PastVisa>().ReverseMap();
|
||||||
|
CreateMap<PastVisitModel, PastVisit>().ReverseMap();
|
||||||
|
CreateMap<ReentryPermitModel, ReentryPermit>().ReverseMap();
|
||||||
|
CreateMap<PermissionToDestCountryModel, PermissionToDestCountry>().ReverseMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,8 @@ public class UsersController(
|
|||||||
ILoginService loginService,
|
ILoginService loginService,
|
||||||
IUsersService usersService,
|
IUsersService usersService,
|
||||||
IValidator<RegisterApplicantRequest> registerApplicantRequestValidator,
|
IValidator<RegisterApplicantRequest> registerApplicantRequestValidator,
|
||||||
IValidator<AuthData> authDataValidator) : ControllerBase
|
IValidator<AuthData> authDataValidator,
|
||||||
|
IValidator<RegisterRequest> registerRequestValidator) : ControllerBase
|
||||||
{
|
{
|
||||||
/// <summary> Adds applicant with user account </summary>
|
/// <summary> Adds applicant with user account </summary>
|
||||||
[HttpPost("register")]
|
[HttpPost("register")]
|
||||||
@@ -46,7 +47,7 @@ public class UsersController(
|
|||||||
[Authorize(policy: PolicyConstants.AdminPolicy)]
|
[Authorize(policy: PolicyConstants.AdminPolicy)]
|
||||||
public async Task<IActionResult> RegisterAuthority(RegisterRequest request, CancellationToken cancellationToken)
|
public async Task<IActionResult> RegisterAuthority(RegisterRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await authDataValidator.ValidateAndThrowAsync(request.AuthData, cancellationToken);
|
await registerRequestValidator.ValidateAndThrowAsync(request, cancellationToken);
|
||||||
|
|
||||||
await registerService.RegisterAuthority(request, cancellationToken);
|
await registerService.RegisterAuthority(request, cancellationToken);
|
||||||
return Ok();
|
return Ok();
|
||||||
@@ -56,7 +57,7 @@ public class UsersController(
|
|||||||
[HttpGet("login")]
|
[HttpGet("login")]
|
||||||
[ProducesResponseType<string>(StatusCodes.Status200OK)]
|
[ProducesResponseType<string>(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||||
public async Task<IActionResult> Login(LoginRequest request, CancellationToken cancellationToken)
|
public async Task<IActionResult> Login([FromQuery] LoginRequest request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var result = await loginService.LoginAsync(request, cancellationToken);
|
var result = await loginService.LoginAsync(request, cancellationToken);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
|
|||||||
Reference in New Issue
Block a user