Added profile ProfileColors and Profile images
This commit is contained in:
@@ -3,4 +3,6 @@
|
||||
public static class CommonFileNames
|
||||
{
|
||||
public static string ProfilePicture = "profilePicture";
|
||||
public static string BannerPicture = "bannerPicture";
|
||||
public static string WebsiteIcon = "websiteIcon";
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ public interface IIdentityService
|
||||
Task<Result<string>> CreateUserAsync(Userinfo userInfo);
|
||||
Task<Result<string>> CreateUserAsync(string email, string userName, string firstName, string lastName, string password);
|
||||
Task<UserModel?> GetCurrentUserAsync();
|
||||
Task<Result<string>> UpdateCurrentUserAsync(string id, string firstName, string lastName, string occupation,
|
||||
string phoneNumber, string birthDate, string country, string city, string address, string about,
|
||||
string description,
|
||||
SocialNetworksModel socialNetworks);
|
||||
Task<Result> UpdateCurrentUserBannerPictureUrlAsync(string url);
|
||||
Task<Result> UpdateCurrentUserProfilePictureUrlAsync(string url);
|
||||
Task<Result> UpdateCurrentUserWebsiteIconUrlAsync(string url);
|
||||
Task<Result<string>> UpdateCurrentUserAsync(UserModel userModel);
|
||||
Task<IList<string>> GetCurrentUserRolesAsync();
|
||||
Task<UserModel?> FindUserByIdAsync(string id);
|
||||
Task<UserModel?> FindUserByEmailAsync(string email);
|
||||
|
||||
@@ -19,25 +19,26 @@ public class Result(
|
||||
}
|
||||
|
||||
public class Result<T>(
|
||||
T? value,
|
||||
bool succeeded,
|
||||
IEnumerable<string> errors)
|
||||
{
|
||||
public bool Succeeded { get; init; } = succeeded;
|
||||
public string[] Errors { get; init; } = errors.ToArray();
|
||||
public T? Value { get; set; }
|
||||
public T? Value { get; set; } = value;
|
||||
|
||||
public T GetValueOrDefault()
|
||||
{
|
||||
return Value ?? default(T)!;
|
||||
}
|
||||
|
||||
public static Result<T> Success()
|
||||
public static Result<T> Success(T value)
|
||||
{
|
||||
return new Result<T>(true, Array.Empty<string>());
|
||||
return new Result<T>(value, true, Array.Empty<string>());
|
||||
}
|
||||
|
||||
public static Result<T> Failure(IEnumerable<string> errors)
|
||||
public static Result<T> Failure(T value, IEnumerable<string> errors)
|
||||
{
|
||||
return new Result<T>(false, errors);
|
||||
return new Result<T>(value, false, errors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,22 @@ using Hutopy.Application.Users.Models;
|
||||
|
||||
namespace Hutopy.Application.Common.Models;
|
||||
|
||||
// TODO: Review nullable affectation here
|
||||
public class UserModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? UserName { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? Occupation { get; set; }
|
||||
public string? Email { get; init; } = String.Empty;
|
||||
public string? Phone { 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;
|
||||
public string? Address { get; init; } = String.Empty;
|
||||
public string? About { get; init; } = String.Empty;
|
||||
public string? Description { get; init; } = String.Empty;
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string UserName { get; set; } = string.Empty;
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
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 BirthDate { get; init; } = string.Empty;
|
||||
public string Country { get; init; } = string.Empty;
|
||||
public string City { get; init; } = string.Empty;
|
||||
public string Address { get; init; } = string.Empty;
|
||||
public string About { get; init; } = string.Empty;
|
||||
public string Description { get; init; } = string.Empty;
|
||||
public SocialNetworksModel SocialNetworks { get; init; } = new();
|
||||
public string? PortraitUrl { get; set; }
|
||||
public ProfileColorsModel ProfileColors { get; init; } = new();
|
||||
public string ProfilePictureUrl { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
@@ -17,29 +17,29 @@ public class Data
|
||||
|
||||
public class Object
|
||||
{
|
||||
public string Id { get; set; } = String.Empty;
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public int Amount { get; set; }
|
||||
public BillingDetails Billing_details { get; set; } = new();
|
||||
public string Calculated_statement_descriptor { get; set; } = String.Empty;
|
||||
public string Currency { get; set; } = String.Empty;
|
||||
public string Calculated_statement_descriptor { get; set; } = string.Empty;
|
||||
public string Currency { get; set; } = string.Empty;
|
||||
public bool Paid { get; set; }
|
||||
public string Payment_intent { get; set; } = String.Empty;
|
||||
public string Payment_method { get; set; } = String.Empty;
|
||||
public string Receipt_url { get; set; } = String.Empty;
|
||||
public string Status { get; set; } = String.Empty;
|
||||
public string Failure_message { get; set; } = String.Empty;
|
||||
public string Payment_intent { get; set; } = string.Empty;
|
||||
public string Payment_method { get; set; } = string.Empty;
|
||||
public string Receipt_url { get; set; } = string.Empty;
|
||||
public string Status { get; set; } = string.Empty;
|
||||
public string Failure_message { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class BillingDetails
|
||||
{
|
||||
public string Email { get; set; } = String.Empty;
|
||||
public string Name { get; set; } = String.Empty;
|
||||
public string Phone { get; set; } = String.Empty;
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class Request
|
||||
{
|
||||
public string Id { get; set; } = String.Empty;
|
||||
public string Id { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class ConfirmStripeTransactionCommandHandler(
|
||||
|
||||
@@ -16,6 +16,7 @@ public class UpdateCurrentUserCommand : IRequest<string>
|
||||
public required string About { get; init; }
|
||||
public required string Description { get; init; }
|
||||
public required SocialNetworksModel SocialNetworks { get; init; }
|
||||
public required ProfileColorsModel ProfileColors { get; init; }
|
||||
}
|
||||
|
||||
public class UpdateCurrentUserCommandHandler(IApplicationDbContext context, IIdentityService identityService) :
|
||||
@@ -27,10 +28,7 @@ public class UpdateCurrentUserCommandHandler(IApplicationDbContext context, IIde
|
||||
|
||||
if (identityUser?.Id is null) return string.Empty;
|
||||
|
||||
var result = await identityService.UpdateCurrentUserAsync(identityUser.Id, request.FirstName, request.LastName,
|
||||
request.Occupation, request.PhoneNumber, request.BirthDate,
|
||||
request.Country, request.City, request.Address, request.About,
|
||||
request.Description, request.SocialNetworks);
|
||||
var result = await identityService.UpdateCurrentUserAsync(identityUser);
|
||||
|
||||
await context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
|
||||
27
src/Application/Users/Commands/UploadBannerPicture.cs
Normal file
27
src/Application/Users/Commands/UploadBannerPicture.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Hutopy.Application.AzureBlobStorage.Constants;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
|
||||
namespace Hutopy.Application.Users.Commands;
|
||||
|
||||
public class UploadBannerPictureCommand : IRequest<string>
|
||||
{
|
||||
public required Stream BannerPicture { get; init; }
|
||||
}
|
||||
|
||||
public class UploadBannerPictureCommandHandler(IIdentityService identityService, IAzureBlobStorageService azureBlobStorageService) : IRequestHandler<UploadBannerPictureCommand, string>
|
||||
{
|
||||
public async Task<string> Handle(UploadBannerPictureCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var identityUser = await identityService.GetCurrentUserAsync();
|
||||
var currentUserId = new Guid(identityUser?.Id ?? "").ToString();
|
||||
|
||||
var blobName = $"{currentUserId}/{SubDirectoryNames.Profile}/{CommonFileNames.BannerPicture}";
|
||||
|
||||
var url = await azureBlobStorageService.UploadFileAsync(ContainerNames.Users, blobName, request.BannerPicture);
|
||||
|
||||
await identityService.UpdateCurrentUserBannerPictureUrlAsync(url);
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ public class UploadProfilePictureCommandHandler(IIdentityService identityService
|
||||
|
||||
var url = await azureBlobStorageService.UploadFileAsync(ContainerNames.Users, blobName, request.ProfilePicture);
|
||||
|
||||
await identityService.UpdateCurrentUserProfilePictureUrlAsync(url);
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
27
src/Application/Users/Commands/UploadWebsiteIcon.cs
Normal file
27
src/Application/Users/Commands/UploadWebsiteIcon.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Hutopy.Application.AzureBlobStorage.Constants;
|
||||
using Hutopy.Application.Common.Interfaces;
|
||||
|
||||
namespace Hutopy.Application.Users.Commands;
|
||||
|
||||
public class UploadWebsiteIconCommand : IRequest<string>
|
||||
{
|
||||
public required Stream WebsiteIcon { get; init; }
|
||||
}
|
||||
|
||||
public class UploadWebsiteIconCommandHandler(IIdentityService identityService, IAzureBlobStorageService azureBlobStorageService) : IRequestHandler<UploadWebsiteIconCommand, string>
|
||||
{
|
||||
public async Task<string> Handle(UploadWebsiteIconCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var identityUser = await identityService.GetCurrentUserAsync();
|
||||
var currentUserId = new Guid(identityUser?.Id ?? "").ToString();
|
||||
|
||||
var blobName = $"{currentUserId}/{SubDirectoryNames.Profile}/{CommonFileNames.WebsiteIcon}";
|
||||
|
||||
var url = await azureBlobStorageService.UploadFileAsync(ContainerNames.Users, blobName, request.WebsiteIcon);
|
||||
|
||||
await identityService.UpdateCurrentUserWebsiteIconUrlAsync(url);
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
9
src/Application/Users/Models/ProfileColorsModel.cs
Normal file
9
src/Application/Users/Models/ProfileColorsModel.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Hutopy.Application.Users.Models;
|
||||
|
||||
public class ProfileColorsModel
|
||||
{
|
||||
public string BannerTop { get; init; } = String.Empty;
|
||||
public string BannerBottom { get; init; } = String.Empty;
|
||||
public string Accent { get; init; } = String.Empty;
|
||||
public string Menu { get; init; } = String.Empty;
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
public class SocialNetworksModel
|
||||
{
|
||||
public string FacebookUrl { get; init; } = String.Empty;
|
||||
public string InstagramUrl { get; init; } = String.Empty;
|
||||
public string XUrl { get; init; } = String.Empty;
|
||||
public string LinkedInUrl { get; init; } = String.Empty;
|
||||
public string TikTokUrl { get; init; } = String.Empty;
|
||||
public string YoutubeUrl { get; init; } = String.Empty;
|
||||
public string RedditUrl { get; init; } = String.Empty;
|
||||
public string YourWebsiteUrl { get; init; } = String.Empty;
|
||||
public string FacebookUrl { get; init; } = string.Empty;
|
||||
public string InstagramUrl { get; init; } = string.Empty;
|
||||
public string XUrl { get; init; } = string.Empty;
|
||||
public string LinkedInUrl { get; init; } = string.Empty;
|
||||
public string TikTokUrl { get; init; } = string.Empty;
|
||||
public string YoutubeUrl { get; init; } = string.Empty;
|
||||
public string RedditUrl { get; init; } = string.Empty;
|
||||
public string YourWebsiteUrl { get; init; } = string.Empty;
|
||||
}
|
||||
|
||||
@@ -7,16 +7,16 @@ public class UserDto
|
||||
public Guid Id { get; init; }
|
||||
public required string FirstName { get; init; }
|
||||
public required string LastName { get; init; }
|
||||
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 BirthDate { get; init; } = String.Empty;
|
||||
public string Country { get; init; } = String.Empty;
|
||||
public string City { get; init; } = String.Empty;
|
||||
public string Address { get; init; } = String.Empty;
|
||||
public string About { get; init; } = String.Empty;
|
||||
public string Description { get; init; } = String.Empty;
|
||||
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 BirthDate { get; init; } = string.Empty;
|
||||
public string Country { get; init; } = string.Empty;
|
||||
public string City { get; init; } = string.Empty;
|
||||
public string Address { get; init; } = string.Empty;
|
||||
public string About { get; init; } = string.Empty;
|
||||
public string Description { get; init; } = string.Empty;
|
||||
public SocialNetworksModel SocialNetworks { get; init; } = new();
|
||||
public List<UserTransactionDto> UserTransactions { get; init; } = [];
|
||||
public IList<string> UserRoles { get; init; } = [];
|
||||
|
||||
Reference in New Issue
Block a user