Skip to content

Commit

Permalink
Merge pull request #139 from SWD392-Domus/hotfix/create-quotation
Browse files Browse the repository at this point in the history
Hotfix/create quotation
  • Loading branch information
duykasama authored Mar 17, 2024
2 parents 1c42978 + f2fa630 commit 9624035
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 4 additions & 3 deletions Domus.Service/Implementations/QuotationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,16 @@ public async Task<ServiceActionResult> CreateQuotation(CreateQuotationRequest re

quotation.QuotationRevisions.Add(quotationRevision);
await _quotationRepository.AddAsync(quotation);
var customerImage = (await _userRepository.GetAsync(x => !x.IsDeleted && x.Id == quotation.Customer.Id)).ProfileImage;
var customer = await _userRepository.GetAsync(x => !x.IsDeleted && x.Id == quotation.CustomerId) ?? throw new UserNotFoundException("Customer not found");
await _notificationRepository.AddAsync(new Notification()
{
RecipientId = NotificationHelper.ADMIN_ID,
Content = NotificationHelper.CreateNewQuotationMessage((quotation.Customer.FullName.Equals("N/A") ? quotation.Customer.Email : quotation.Customer.FullName),quotation.Id),
Content = NotificationHelper.CreateNewQuotationMessage((string.IsNullOrEmpty(customer.FullName) || customer.FullName.Equals("N/A") ? customer.Email! : customer.FullName), quotation.Id),
SentAt = DateTime.Now,
Image = customerImage,
Image = customer.ProfileImage ?? string.Empty,
RedirectString = $"staff/quotations/{quotation.Id}"
});

await _unitOfWork.CommitAsync();
return new ServiceActionResult(true);
}
Expand Down
6 changes: 2 additions & 4 deletions Domus.Service/Implementations/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,10 @@ public async Task<ServiceActionResult> GetAllUsers()
// var clientUser = await _userRepository.GetAsync(x => x.Id.Equals(request.ClientId)&& !x.IsDeleted) ??
// throw new Exception($"Not found Client: {request.ClientId}");
// var clientRoles = await _userManager.GetRolesAsync(clientUser);
var users = (await _userRepository.GetAllAsync())
.Where(u => !u.IsDeleted).ToList();
var users = await (await _userRepository.FindAsync(u => !u.IsDeleted)).ToListAsync();
var dtoList = new List<DtoDomusUserWithRole>();
foreach (var dtoDomusUserWithRole in users)
foreach (var user in users)
{
var user = await _userRepository.GetAsync(x => x.Id.Equals(dtoDomusUserWithRole.Id) && !x.IsDeleted);
var userRole = await _userManager.GetRolesAsync(user);
var x = _mapper.Map<DtoDomusUserWithRole>(user);
x.Role = userRole;
Expand Down

0 comments on commit 9624035

Please sign in to comment.