Initial code commit.

This commit is contained in:
2026-02-03 10:44:31 +08:00
parent 8927c5ae0e
commit d69fe2cc1f
99 changed files with 10839 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using AutoMapper;
using MediatR;
using Sufi.Demo.PeopleDirectory.Application.Contracts.Repositories;
using Sufi.Demo.PeopleDirectory.Application.Contracts.Services;
using Sufi.Demo.PeopleDirectory.Domain.Entities.Misc;
using Sufi.Demo.PeopleDirectory.Shared.Wrapper;
namespace Sufi.Demo.PeopleDirectory.Application.Features.Contacts.Queries.GetAll
{
public class GetAllContactsQuery : IRequest<IResult<List<GetAllContactsResponse>>>
{
}
public class GetAllContactsQueryHandler(
IUnitOfWork<int> unitOfWork,
IMapper mapper,
IAppCache appCache
) : IRequestHandler<GetAllContactsQuery, IResult<List<GetAllContactsResponse>>>
{
public async Task<IResult<List<GetAllContactsResponse>>> Handle(GetAllContactsQuery request, CancellationToken cancellationToken)
{
Task<List<Contact>> allContactsFunc() => unitOfWork.Repository<Contact>().GetAllAsync();
var allContacts = await appCache.GetOrAddAsync(
"contact_all",
async token => await allContactsFunc(),
absoluteExpireTime: TimeSpan.FromMinutes(2),
tags: ["contacts"]
);
var mappedContacts = mapper.Map<List<GetAllContactsResponse>>(allContacts);
return await Result<List<GetAllContactsResponse>>.SuccessAsync(mappedContacts);
}
}
}

View File

@@ -0,0 +1,12 @@
namespace Sufi.Demo.PeopleDirectory.Application.Features.Contacts.Queries.GetAll
{
public record GetAllContactsResponse
{
public int Id { get; set; }
public string UserName { get; set; } = null!;
public string Phone { get; set; } = null!;
public string Email { get; set; } = null!;
public string SkillSets { get; set; } = null!;
public string Hobby { get; set; } = null!;
}
}