Skip to content

Commit

Permalink
Merge pull request #142 from SWD392-Domus/hotfix/finalize-features
Browse files Browse the repository at this point in the history
Hotfix/finalize features
  • Loading branch information
duykasama authored Mar 19, 2024
2 parents 6779edc + 5b7c77b commit 39d34b6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Domus.Domain/Dtos/Quotations/DtoQuotationFullDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class DtoQuotationFullDetails

public DateTime? ExpireAt { get; set; }

public DtoPackage? Package { get; set; }

[JsonPropertyName("products")]
public ICollection<DtoProductDetailQuotationRevision> ProductDetailQuotations { get; set; } = new List<DtoProductDetailQuotationRevision>();

Expand Down
5 changes: 4 additions & 1 deletion Domus.Service/Implementations/AdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ public class AdminService : IAdminService
{
private readonly IContractRepository _contractRepository;
private readonly IQuotationRevisionRepository _quotationRevisionRepository;
private readonly IUserRepository _userRepository;

public AdminService(IContractRepository contractRepository, IQuotationRevisionRepository quotationRevisionRepository)
public AdminService(IContractRepository contractRepository, IQuotationRevisionRepository quotationRevisionRepository, IUserRepository userRepository)
{
_contractRepository = contractRepository;
_quotationRevisionRepository = quotationRevisionRepository;
_userRepository = userRepository;
}

public async Task<ServiceActionResult> GetDashboardInfo(GetDashboardInfoRequest request)
Expand Down Expand Up @@ -47,6 +49,7 @@ public async Task<ServiceActionResult> GetDashboardInfo(GetDashboardInfoRequest
});
}

dashboardResponse.NewUsersCount = await (await _userRepository.FindAsync(u => !u.IsDeleted && u.EmailConfirmed)).CountAsync();
dashboardResponse.TotalRevenue = dashboardResponse.RevenueByMonths.Select(rbm => rbm.Revenue).Sum();

return new ServiceActionResult(true) { Data = dashboardResponse };
Expand Down
18 changes: 10 additions & 8 deletions Domus.Service/Implementations/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,16 @@ public async Task<ServiceActionResult> UpdatePassword(UpdateUserPasswordRequest

public async Task<ServiceActionResult> GetAllStaff()
{
var staffList = new List<DtoDomusUser>();
foreach (var user in _userManager.Users.ToList())
{
if (await _userManager.IsInRoleAsync(user, UserRoleConstants.STAFF) && !await _userManager.IsInRoleAsync(user, UserRoleConstants.ADMIN))
staffList.Add(_mapper.Map<DtoDomusUser>(user));
}

return new ServiceActionResult(true) { Data = staffList };
var users = (await (await _userRepository.FindAsync(u => !u.IsDeleted && u.EmailConfirmed))
.ToListAsync())
.Where(u =>
{
var roles = _userManager.GetRolesAsync(u).Result;
return roles.Contains(UserRoleConstants.STAFF) &&
!roles.Contains(UserRoleConstants.ADMIN);
});

return new ServiceActionResult(true) { Data = _mapper.Map<IEnumerable<DtoDomusUser>>(users) };
}

public async Task<ServiceActionResult> SearchUsersUsingGet(SearchUsingGetRequest request)
Expand Down

0 comments on commit 39d34b6

Please sign in to comment.