public async Task <IActionResult> UpdateData(int?periodId, int?saleId = null) { List <MLFSSale> sales = new List <MLFSSale>(); if (saleId == null) { if (periodId == null) { return(NotFound()); } MLFSReportingPeriod period = await _periodData.GetPeriodById((int)periodId); if (period == null) { return(NotFound()); } sales = await _salesData.GetSales(period); } else { MLFSSale soleSale = await _salesData.GetSaleById((int)saleId); sales.Add(soleSale); } for (int i = 0; i < sales.Count; i++) { MLFSSale sale = sales[i]; //only interested in clients which haven't been updated already or where we are forcing a particular line //if (saleId != null || (sale.EstimatedOtherIncome == 0)) //{ Console.WriteLine("Client: " + sale.ClientId + ":" + sale.Client + ":" + i.ToString()); MLFSClient client = await _clientData.GetClient(sale.ClientId); List <MLFSIncome> income = await _incomeData.GetIncome(client); sale.AddClientData(client, income); _salesData.Update(sale); //} } return(Ok()); }
public async Task <MLFSClient> GetClient(string clientId) { MLFSClient client = await _clientRepository.GetClient(clientId); return(client); }