initial commit
This commit is contained in:
@@ -0,0 +1,275 @@
|
||||
@page "/profile/personal-information"
|
||||
@using System.ComponentModel.DataAnnotations
|
||||
@using MudBlazor
|
||||
@using Indotalent.Features.Profile.PersonalInformation
|
||||
@using Indotalent.Features.Profile.PersonalInformation.Cqrs
|
||||
@using Indotalent.ConfigBackEnd.Interfaces
|
||||
@inject ISnackbar Snackbar
|
||||
@inject PersonalInformationService PersonalInformationService
|
||||
@inject ICurrentUserService CurrentUserService
|
||||
|
||||
<MudPaper Elevation="0" Square="true" Class="pa-6 mb-3 d-flex align-center justify-space-between">
|
||||
<div>
|
||||
<MudText Typo="Typo.h5" Style="font-weight: 900; color: #1a1a1a;">Personal Information</MudText>
|
||||
<MudText Typo="Typo.body2" Style="color: #64748b;">Manage your personal details, contact information, and how others see you.</MudText>
|
||||
</div>
|
||||
|
||||
<div class="d-flex align-center gap-2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Home" Size="Size.Small" Color="Color.Default" />
|
||||
<MudText Typo="Typo.caption" Style="color: #94a3b8;">/</MudText>
|
||||
<MudText Typo="Typo.caption" Style="color: #94a3b8;">Profile</MudText>
|
||||
<MudText Typo="Typo.caption" Style="color: #94a3b8;">/</MudText>
|
||||
<MudText Typo="Typo.caption" Style="font-weight: 600; color: #1a1a1a;">Personal Information</MudText>
|
||||
</div>
|
||||
</MudPaper>
|
||||
|
||||
<MudPaper Elevation="0" Outlined="true" Class="pa-8" Style="border-radius: 0px; background-color: #ffffff;">
|
||||
<MudStack Spacing="8">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="4">
|
||||
<MudText Typo="Typo.h6" Class="fw-bold">Basic Profile</MudText>
|
||||
<MudText Typo="Typo.body2">Your public identity and bio.</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="8">
|
||||
<MudStack Spacing="4">
|
||||
<MudGrid Spacing="2">
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">First Name</MudText>
|
||||
<MudTextField @bind-Value="user.FirstName" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Last Name</MudText>
|
||||
<MudTextField @bind-Value="user.LastName" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<div>
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Short Bio</MudText>
|
||||
<MudTextField @bind-Value="user.Bio" Variant="Variant.Outlined" Lines="3" FullWidth="true" Margin="Margin.Dense" Placeholder="Tell us a little about yourself..." />
|
||||
</div>
|
||||
|
||||
<MudGrid Spacing="2">
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Job Title / Position</MudText>
|
||||
<MudTextField @bind-Value="user.JobTitle" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Date of Birth</MudText>
|
||||
<MudDatePicker @bind-Date="user.DateOfBirth" Variant="Variant.Outlined" Margin="Margin.Dense" Editable="true" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudDivider />
|
||||
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="4">
|
||||
<MudText Typo="Typo.h6" Class="fw-bold">Contact & Location</MudText>
|
||||
<MudText Typo="Typo.body2">How we can reach you and where you're based.</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="8">
|
||||
<MudStack Spacing="4">
|
||||
<MudGrid Spacing="2">
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Email Address</MudText>
|
||||
<MudTextField @bind-Value="user.Contact.Email" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Email" Disabled="true" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Phone Number</MudText>
|
||||
<MudTextField @bind-Value="user.Contact.Phone" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Phone" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<div>
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Residential Address</MudText>
|
||||
<MudTextField @bind-Value="user.Contact.Address" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" Placeholder="Street name, Building, Apartment No." />
|
||||
</div>
|
||||
|
||||
<MudGrid Spacing="2">
|
||||
<MudItem xs="12" sm="4">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">City</MudText>
|
||||
<MudTextField @bind-Value="user.Contact.City" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="4">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Country</MudText>
|
||||
<MudTextField @bind-Value="user.Contact.Country" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="4">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Postal Code</MudText>
|
||||
<MudTextField @bind-Value="user.Contact.PostalCode" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudDivider />
|
||||
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="4">
|
||||
<MudText Typo="Typo.h6" Class="fw-bold">Social Profiles</MudText>
|
||||
<MudText Typo="Typo.body2">Your professional and social networking links.</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="8">
|
||||
<MudStack Spacing="4">
|
||||
<div>
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">LinkedIn Profile</MudText>
|
||||
<MudTextField @bind-Value="user.Socials.LinkedIn" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" Adornment="Adornment.Start" AdornmentIcon="@Icons.Custom.Brands.LinkedIn" Placeholder="https://linkedin.com/in/username" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">GitHub / Portfolio</MudText>
|
||||
<MudTextField @bind-Value="user.Socials.GitHub" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" Adornment="Adornment.Start" AdornmentIcon="@Icons.Custom.Brands.GitHub" Placeholder="https://github.com/username" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">Instagram</MudText>
|
||||
<MudTextField @bind-Value="user.Socials.Instagram" Variant="Variant.Outlined" FullWidth="true" Margin="Margin.Dense" Adornment="Adornment.Start" AdornmentIcon="@Icons.Custom.Brands.Instagram" Placeholder="@("@username")" />
|
||||
</div>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<div class="d-flex justify-end align-center gap-4 mt-4">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="SaveProfile" Disabled="@_isProcessing">
|
||||
@if (_isProcessing)
|
||||
{
|
||||
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true" />
|
||||
<MudText Class="ms-2">Saving...</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText>Save Changes</MudText>
|
||||
}
|
||||
</MudButton>
|
||||
</div>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
|
||||
@code {
|
||||
private bool _isProcessing = false;
|
||||
private UserProfileModel user = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadProfile();
|
||||
}
|
||||
|
||||
private async Task LoadProfile()
|
||||
{
|
||||
var userId = CurrentUserService.UserId;
|
||||
if (string.IsNullOrEmpty(userId)) return;
|
||||
|
||||
_isProcessing = true;
|
||||
|
||||
var response = await PersonalInformationService.GetPersonalInformationByIdAsync(userId);
|
||||
|
||||
if (response != null && response.IsSuccess && response.Value != null)
|
||||
{
|
||||
var profile = response.Value;
|
||||
|
||||
user = new UserProfileModel
|
||||
{
|
||||
FirstName = profile.FirstName ?? string.Empty,
|
||||
LastName = profile.LastName ?? string.Empty,
|
||||
Bio = profile.ShortBio ?? string.Empty,
|
||||
JobTitle = profile.JobTitle ?? string.Empty,
|
||||
DateOfBirth = profile.DateOfBirth,
|
||||
Contact = new ContactModel
|
||||
{
|
||||
Email = profile.Email ?? string.Empty,
|
||||
Phone = profile.PhoneNumber ?? string.Empty,
|
||||
Address = profile.StreetAddress ?? string.Empty,
|
||||
City = profile.City ?? string.Empty,
|
||||
Country = profile.Country ?? string.Empty,
|
||||
PostalCode = profile.ZipCode ?? string.Empty
|
||||
},
|
||||
Socials = new UserSocialModel
|
||||
{
|
||||
LinkedIn = profile.SocialMediaLinkedIn ?? string.Empty,
|
||||
Instagram = profile.SocialMediaInstagram ?? string.Empty,
|
||||
GitHub = profile.SocialMediaX ?? string.Empty
|
||||
}
|
||||
};
|
||||
}
|
||||
_isProcessing = false;
|
||||
}
|
||||
|
||||
private async Task SaveProfile()
|
||||
{
|
||||
var userId = CurrentUserService.UserId;
|
||||
if (string.IsNullOrEmpty(userId))
|
||||
{
|
||||
Snackbar.Add("User session not found.", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_isProcessing = true;
|
||||
|
||||
var updateRequest = new UpdateProfileRequest
|
||||
{
|
||||
Id = userId,
|
||||
FirstName = user.FirstName,
|
||||
LastName = user.LastName,
|
||||
ShortBio = user.Bio,
|
||||
JobTitle = user.JobTitle,
|
||||
DateOfBirth = user.DateOfBirth,
|
||||
PhoneNumber = user.Contact.Phone,
|
||||
StreetAddress = user.Contact.Address,
|
||||
City = user.Contact.City,
|
||||
Country = user.Contact.Country,
|
||||
ZipCode = user.Contact.PostalCode,
|
||||
SocialMediaLinkedIn = user.Socials.LinkedIn,
|
||||
SocialMediaInstagram = user.Socials.Instagram,
|
||||
SocialMediaX = user.Socials.GitHub
|
||||
};
|
||||
|
||||
var result = await PersonalInformationService.UpdatePersonalInformationAsync(updateRequest);
|
||||
await Task.Delay(500);
|
||||
|
||||
if (result != null && result.IsSuccess)
|
||||
{
|
||||
Snackbar.Add("Profile updated! Please re-login to see all changes in the session.", Severity.Success, config =>
|
||||
{
|
||||
config.VisibleStateDuration = 5000;
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(result?.Message ?? "Update failed", Severity.Error);
|
||||
}
|
||||
|
||||
_isProcessing = false;
|
||||
}
|
||||
|
||||
public class UserProfileModel
|
||||
{
|
||||
public string FirstName { get; set; } = string.Empty;
|
||||
public string LastName { get; set; } = string.Empty;
|
||||
public string Bio { get; set; } = string.Empty;
|
||||
public string JobTitle { get; set; } = string.Empty;
|
||||
public DateTime? DateOfBirth { get; set; }
|
||||
public ContactModel Contact { get; set; } = new();
|
||||
public UserSocialModel Socials { get; set; } = new();
|
||||
}
|
||||
|
||||
public class ContactModel
|
||||
{
|
||||
public string Email { get; set; } = string.Empty;
|
||||
public string Phone { get; set; } = string.Empty;
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public string City { get; set; } = string.Empty;
|
||||
public string Country { get; set; } = string.Empty;
|
||||
public string PostalCode { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class UserSocialModel
|
||||
{
|
||||
public string LinkedIn { get; set; } = string.Empty;
|
||||
public string GitHub { get; set; } = string.Empty;
|
||||
public string Instagram { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Profile.PersonalInformation.Cqrs;
|
||||
|
||||
public class GetProfileByIdResponse
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? ShortBio { get; set; }
|
||||
public string? JobTitle { get; set; }
|
||||
public DateTime? DateOfBirth { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? StreetAddress { get; set; }
|
||||
public string? City { get; set; }
|
||||
public string? Country { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
public string? SocialMediaLinkedIn { get; set; }
|
||||
public string? SocialMediaInstagram { get; set; }
|
||||
public string? SocialMediaX { get; set; }
|
||||
}
|
||||
|
||||
public record GetProfileByIdQuery(string Id) : IRequest<GetProfileByIdResponse?>;
|
||||
|
||||
public class GetProfileByIdHandler : IRequestHandler<GetProfileByIdQuery, GetProfileByIdResponse?>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public GetProfileByIdHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<GetProfileByIdResponse?> Handle(GetProfileByIdQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Users
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Id == request.Id)
|
||||
.Select(x => new GetProfileByIdResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
ShortBio = x.ShortBio,
|
||||
JobTitle = x.JobTitle,
|
||||
DateOfBirth = x.DateOfBirth,
|
||||
Email = x.Email,
|
||||
PhoneNumber = x.PhoneNumber,
|
||||
StreetAddress = x.StreetAddress,
|
||||
City = x.City,
|
||||
Country = x.Country,
|
||||
ZipCode = x.ZipCode,
|
||||
SocialMediaLinkedIn = x.SocialMediaLinkedIn,
|
||||
SocialMediaInstagram = x.SocialMediaInstagram,
|
||||
SocialMediaX = x.SocialMediaX
|
||||
})
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Profile.PersonalInformation.Cqrs;
|
||||
|
||||
public class UpdateProfileRequest
|
||||
{
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public string? ShortBio { get; set; }
|
||||
public string? JobTitle { get; set; }
|
||||
public DateTime? DateOfBirth { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? StreetAddress { get; set; }
|
||||
public string? City { get; set; }
|
||||
public string? Country { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
public string? SocialMediaLinkedIn { get; set; }
|
||||
public string? SocialMediaInstagram { get; set; }
|
||||
public string? SocialMediaX { get; set; }
|
||||
}
|
||||
|
||||
public class UpdateProfileResponse
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public string Message { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public record UpdateProfileCommand(UpdateProfileRequest Data) : IRequest<UpdateProfileResponse>;
|
||||
|
||||
public class UpdateProfileHandler : IRequestHandler<UpdateProfileCommand, UpdateProfileResponse>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public UpdateProfileHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<UpdateProfileResponse> Handle(UpdateProfileCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var user = await _context.Users
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Data.Id, cancellationToken);
|
||||
|
||||
if (user == null)
|
||||
return new UpdateProfileResponse { Success = false, Message = "User not found" };
|
||||
|
||||
user.FullName = $"{request.Data.FirstName} {request.Data.LastName}";
|
||||
user.FirstName = request.Data.FirstName;
|
||||
user.LastName = request.Data.LastName;
|
||||
user.ShortBio = request.Data.ShortBio;
|
||||
user.JobTitle = request.Data.JobTitle;
|
||||
user.DateOfBirth = request.Data.DateOfBirth ?? user.DateOfBirth;
|
||||
user.PhoneNumber = request.Data.PhoneNumber;
|
||||
user.StreetAddress = request.Data.StreetAddress;
|
||||
user.City = request.Data.City;
|
||||
user.Country = request.Data.Country;
|
||||
user.ZipCode = request.Data.ZipCode;
|
||||
user.SocialMediaLinkedIn = request.Data.SocialMediaLinkedIn ?? string.Empty;
|
||||
user.SocialMediaInstagram = request.Data.SocialMediaInstagram ?? string.Empty;
|
||||
user.SocialMediaX = request.Data.SocialMediaX ?? string.Empty;
|
||||
user.UpdatedAt = DateTime.Now;
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return new UpdateProfileResponse { Success = true };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using FluentValidation;
|
||||
using Indotalent.Shared.Consts;
|
||||
|
||||
namespace Indotalent.Features.Profile.PersonalInformation.Cqrs;
|
||||
|
||||
public class UpdateProfileValidator : AbstractValidator<UpdateProfileRequest>
|
||||
{
|
||||
public UpdateProfileValidator()
|
||||
{
|
||||
RuleFor(x => x.Id).NotEmpty();
|
||||
|
||||
RuleFor(x => x.FirstName)
|
||||
.NotEmpty().WithMessage("First name is required")
|
||||
.MaximumLength(GlobalConsts.StringLengthShort).WithMessage($"First name cannot exceed {GlobalConsts.StringLengthShort} characters");
|
||||
|
||||
RuleFor(x => x.LastName)
|
||||
.NotEmpty().WithMessage("Last name is required")
|
||||
.MaximumLength(GlobalConsts.StringLengthShort).WithMessage($"Last name cannot exceed {GlobalConsts.StringLengthShort} characters");
|
||||
|
||||
RuleFor(x => x.PhoneNumber)
|
||||
.MaximumLength(GlobalConsts.StringLengthShort).WithMessage($"Phone cannot exceed {GlobalConsts.StringLengthShort} characters");
|
||||
|
||||
RuleFor(x => x.ShortBio)
|
||||
.MaximumLength(GlobalConsts.StringLengthShort).WithMessage($"Bio cannot exceed {GlobalConsts.StringLengthShort} characters");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Indotalent.ConfigBackEnd.Extensions;
|
||||
using Indotalent.Features.Profile.PersonalInformation.Cqrs;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
|
||||
namespace Indotalent.Features.Profile.PersonalInformation;
|
||||
|
||||
public static class PersonalInformationEndpoint
|
||||
{
|
||||
public static void MapPersonalInformationEndpoints(this IEndpointRouteBuilder app)
|
||||
{
|
||||
var group = app.MapGroup("/personal-information").WithTags("Personal Information")
|
||||
.RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
|
||||
.RequireAuthenticatedUser());
|
||||
|
||||
group.MapGet("/{id}", async (string id, IMediator mediator) =>
|
||||
{
|
||||
var result = await mediator.Send(new GetProfileByIdQuery(id));
|
||||
return result.ToApiResponse(result is not null
|
||||
? "Personal information retrieved successfully"
|
||||
: $"User with ID {id} not found");
|
||||
})
|
||||
.WithName("GetPersonalInformationById");
|
||||
|
||||
group.MapPost("/update", async (UpdateProfileRequest request, IMediator mediator) =>
|
||||
{
|
||||
var result = await mediator.Send(new UpdateProfileCommand(request));
|
||||
if (!result.Success)
|
||||
return ((object?)null).ToApiResponse(result.Message ?? "Update failed.", StatusCodes.Status400BadRequest);
|
||||
|
||||
return result.ToApiResponse("Personal information has been updated successfully");
|
||||
})
|
||||
.WithName("UpdatePersonalInformation");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Indotalent.ConfigBackEnd.Interfaces;
|
||||
using Indotalent.ConfigFrontEnd.Common;
|
||||
using Indotalent.Features.Profile.PersonalInformation.Cqrs;
|
||||
using Indotalent.Infrastructure.Authentication.Identity;
|
||||
using Indotalent.Shared.Models;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MudBlazor;
|
||||
using RestSharp;
|
||||
|
||||
namespace Indotalent.Features.Profile.PersonalInformation;
|
||||
|
||||
public class PersonalInformationService : BaseService
|
||||
{
|
||||
private readonly RestClient _client;
|
||||
|
||||
public PersonalInformationService(IHttpClientFactory clientFactory, NavigationManager nav, ISnackbar snackbar, ICurrentUserService currentUserService, TokenProvider tokenProvider)
|
||||
: base(clientFactory, nav, snackbar, currentUserService, tokenProvider)
|
||||
{
|
||||
_client = new RestClient(nav.BaseUri);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<GetProfileByIdResponse>?> GetPersonalInformationByIdAsync(string id)
|
||||
{
|
||||
var request = new RestRequest($"api/personal-information/{id}", Method.Get);
|
||||
return await ExecuteWithResponseAsync<GetProfileByIdResponse>(_client, request);
|
||||
}
|
||||
|
||||
public async Task<ApiResponse<UpdateProfileResponse>?> UpdatePersonalInformationAsync(UpdateProfileRequest data)
|
||||
{
|
||||
var request = new RestRequest("api/personal-information/update", Method.Post);
|
||||
request.AddJsonBody(data);
|
||||
return await ExecuteWithResponseAsync<UpdateProfileResponse>(_client, request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user