Mapping + changed Phone to PhoneNumber
This commit is contained in:
@@ -10,7 +10,7 @@ public class UserModel
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string Occupation { get; set; } = string.Empty;
|
||||
public string Email { get; init; } = string.Empty;
|
||||
public string Phone { get; init; } = string.Empty;
|
||||
public string PhoneNumber { get; init; } = string.Empty;
|
||||
public string BirthDate { get; init; } = string.Empty;
|
||||
public string Country { get; init; } = string.Empty;
|
||||
public string City { get; init; } = string.Empty;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
using Hutopy.Application.Common.Models;
|
||||
using Hutopy.Application.Users.Models;
|
||||
|
||||
namespace Hutopy.Application.Users.Commands;
|
||||
@@ -17,9 +19,18 @@ public class UpdateCurrentUserCommand : IRequest<string>
|
||||
public required string Description { get; init; }
|
||||
public required SocialNetworksModel SocialNetworks { get; init; }
|
||||
public required ProfileColorsModel ProfileColors { get; init; }
|
||||
|
||||
[NotMapped]
|
||||
private class Mapping : Profile
|
||||
{
|
||||
public Mapping()
|
||||
{
|
||||
CreateMap<UpdateCurrentUserCommand, UserModel>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class UpdateCurrentUserCommandHandler(IApplicationDbContext context, IIdentityService identityService) :
|
||||
public class UpdateCurrentUserCommandHandler(IApplicationDbContext context, IIdentityService identityService, IMapper mapper) :
|
||||
IRequestHandler<UpdateCurrentUserCommand, string>
|
||||
{
|
||||
public async Task<string> Handle(UpdateCurrentUserCommand request, CancellationToken cancellationToken)
|
||||
@@ -28,7 +39,10 @@ public class UpdateCurrentUserCommandHandler(IApplicationDbContext context, IIde
|
||||
|
||||
if (identityUser?.Id is null) return string.Empty;
|
||||
|
||||
var result = await identityService.UpdateCurrentUserAsync(identityUser);
|
||||
var userModel = mapper.Map<UserModel>(request);
|
||||
userModel.Id = identityUser.Id;
|
||||
|
||||
var result = await identityService.UpdateCurrentUserAsync(userModel);
|
||||
|
||||
await context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class GetCurrentUserQueryHandler(
|
||||
LastName = identityUser.LastName ?? "",
|
||||
UserName = identityUser.UserName ?? "",
|
||||
Occupation = identityUser.Occupation ?? "",
|
||||
Phone = identityUser.Phone ?? "",
|
||||
PhoneNumber = identityUser.PhoneNumber ?? "",
|
||||
Email = identityUser.Email ?? "",
|
||||
BirthDate = identityUser.BirthDate ?? "",
|
||||
Country = identityUser.Country ?? "",
|
||||
|
||||
@@ -10,7 +10,7 @@ public class UserDto
|
||||
public string UserName { get; init; } = string.Empty;
|
||||
public string Occupation { get; init; } = string.Empty;
|
||||
public string Email { get; init; } = string.Empty;
|
||||
public string Phone { get; init; } = string.Empty;
|
||||
public string PhoneNumber { get; init; } = string.Empty;
|
||||
public string BirthDate { get; init; } = string.Empty;
|
||||
public string Country { get; init; } = string.Empty;
|
||||
public string City { get; init; } = string.Empty;
|
||||
@@ -23,5 +23,4 @@ public class UserDto
|
||||
public List<UserTransactionDto> UserTransactions { get; init; } = [];
|
||||
public IList<string> UserRoles { get; init; } = [];
|
||||
public required decimal TotalBalance { get; init; }
|
||||
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class IdentityService(
|
||||
applicationUser.FirstName = userModel.FirstName;
|
||||
applicationUser.LastName = userModel.LastName;
|
||||
applicationUser.Occupation = userModel.Occupation;
|
||||
applicationUser.PhoneNumber = userModel.Phone;
|
||||
applicationUser.PhoneNumber = userModel.PhoneNumber;
|
||||
applicationUser.BirthDate = userModel.BirthDate;
|
||||
applicationUser.Country = userModel.Country;
|
||||
applicationUser.City = userModel.City;
|
||||
@@ -147,7 +147,7 @@ public class IdentityService(
|
||||
LastName = response.LastName,
|
||||
Email = response.Email ?? string.Empty,
|
||||
Occupation = response.Occupation,
|
||||
Phone = response.PhoneNumber ?? string.Empty,
|
||||
PhoneNumber = response.PhoneNumber ?? string.Empty,
|
||||
BirthDate = response.BirthDate,
|
||||
Country = response.Country,
|
||||
City = response.City,
|
||||
@@ -197,7 +197,7 @@ public class IdentityService(
|
||||
LastName = response.LastName,
|
||||
Email = response.Email ?? string.Empty,
|
||||
Occupation = response.Occupation,
|
||||
Phone = response.PhoneNumber ?? string.Empty,
|
||||
PhoneNumber = response.PhoneNumber ?? string.Empty,
|
||||
BirthDate = response.BirthDate,
|
||||
Country = response.Country,
|
||||
City = response.City,
|
||||
|
||||
Reference in New Issue
Block a user