private async Task notifyFinanceUser(NotifyType type, ExpenseInfo expense, int userId) { var financeUsers = await _userRepository.FindFinanceUser(); var user = await _userRepository.FindAsync(userId); var notifyBody = new NotifyBodyDto() { ExpenseModel = getFormattedExpense(expense), User = user, AbsoluteUrl = getAbsoluteUrl() }; INotifyBodyCreator bodyCreator = _notifyBodyCreatorAccessor(type); var message = bodyCreator.CreateBody(notifyBody); var subject = getNotifySubjectbyType(type); var notifyData = new NotifyDataDto() { To = financeUsers, Message = message, Subject = _localizer.Localize(subject) }; await notifyUser(notifyData); }
private async Task notifyUser(NotifyDataDto notifyData) { var tasks = new List <Task>(); foreach (var notifyUser in notifyData.To) { tasks.Add(_emailService.SendEmailAsync(notifyUser.Email, notifyData.Subject, notifyData.Message)); } await Task.WhenAll(tasks); }