public Task SendCurrencyToSap(List <CurrencyRateDto> currencyRate) { // if it is friday we must set the currency rates for the weekend and next monday //TODO: We can create a DateTime service for obtains days of the weekend var allCurrenciesRates = _dateTimeProvider.UtcNow.DayOfWeek != DayOfWeek.Friday ? currencyRate : currencyRate .SelectMany(x => new List <CurrencyRateDto> { new CurrencyRateDto { Date = x.Date, CurrencyCode = x.CurrencyCode, CurrencyName = x.CurrencyName, SaleValue = x.SaleValue }, new CurrencyRateDto { Date = x.Date.AddDays(1), CurrencyCode = x.CurrencyCode, CurrencyName = x.CurrencyName, SaleValue = x.SaleValue }, new CurrencyRateDto { Date = x.Date.AddDays(2), CurrencyCode = x.CurrencyCode, CurrencyName = x.CurrencyName, SaleValue = x.SaleValue } }) .ToList(); foreach (var setCurrencyRateTask in allCurrenciesRates.Select(rate => new SapTask { CurrencyRate = CurrencyRateMapper.MapCurrencyRate(rate), TaskType = SapTaskEnum.CurrencyRate })) { _queuingService.AddToTaskQueue(setCurrencyRateTask); } return(Task.CompletedTask); }
public Task CreateOrUpdateBusinessPartner(DopplerUserDto dopplerUser) { var sapSystem = SapSystemHelper.GetSapSystemByBillingSystem(dopplerUser.BillingSystemId); if (!GetValidator(sapSystem).IsValid(dopplerUser, sapSystem, _sapConfig, out var userVerificationError)) { throw new ValidationException(userVerificationError); } _logger.LogInformation($"Add to Task in Queue: {SapTaskEnum.CreateOrUpdateBusinessPartner}"); _queuingService.AddToTaskQueue( new SapTask() { TaskType = SapTaskEnum.CreateOrUpdateBusinessPartner, DopplerUser = dopplerUser } ); return(Task.CompletedTask); }