public SpendSummary GetTotalSpend(int supplierId) { ISupplierInvoice supplierInvoiceFactory = new SupplierInvoiceFactory(); ISpendService spendService = supplierInvoiceFactory.GetSupplierInvoice(supplierId); return(spendService.GetTotalSpend()); //return null; }
public SpendSummary GetTotalSpend(int supplierId) { _logger.LogInformation($"Calling Total spend for {supplierId}"); try { var supplier = _supplierService.GetById(supplierId); _spendService = supplier.IsExternal ? (ISpendService) new ExternalServiceWrapper(_failoverInvoiceService) : new InvoiceRepository(); return(_spendService.GetTotalSpend(supplierId)); } catch (CustomException) { _logger.LogError($"GetTotalSpend is failed to acquire data for external supplier {supplierId} from both locations."); return(null); // sending out null intentionally. } catch (Exception ex) { _logger.LogError($"Error occured. Error message is {ex.Message}"); throw; } }
public SpendSummary Get(int id) { return(spendService.GetTotalSpend(id)); }