public async Task<HttpResponseMessage> GetRelatorioReceitas(RelatorioFinanceiroSearchViewModel filters) { //var result = _relatorioFinanceiroApp.GetRelatorioReceitas(filters); var list = _relatorioFinanceiroApp.GetRelatorioReceitas(filters); var total = new Dictionary<string, decimal>(); foreach (var item in _tipoPagamentoApp.GetAll()) { var listByTipo = list.Where(e => e.TipoPagamento == item.Descricao); total.Add(item.Descricao, listByTipo.Sum(e => e.ValorTotal)); } var relatorioContainer = new RelatorioContainer() { ListRelatorio = list, TotalByTipoPagamento = total }; var response = Request.CreateResponse(HttpStatusCode.OK, relatorioContainer); var tsc = new TaskCompletionSource<HttpResponseMessage>(); tsc.SetResult(response); return await tsc.Task; }
public async Task<HttpResponseMessage> GetRelatorio(RelatorioFinanceiroSearchViewModel filters) { //if (filters.DataInicio != null) // filters.DataInicio = new DateTime(filters.DataInicio.Value.Year, filters.DataInicio.Value.Month, filters.DataInicio.Value.Day, 01, 00, 00); //if (filters.DataFim != null) // filters.DataFim = new DateTime(filters.DataFim.Value.Year, filters.DataFim.Value.Month, filters.DataFim.Value.Day, 23, 59, 59); //var result = _relatorioFinanceiroApp.GetRelatorio(filters); var list = _relatorioFinanceiroApp.GetRelatorio(filters); var total = new Dictionary<string, decimal>(); foreach (var item in _tipoPagamentoApp.GetAll()) { var listByTipo = list.Where(e => e.TipoPagamento == item.Descricao); total.Add(item.Descricao, listByTipo.Sum(e => e.ValorTotal)); } var relatorioContainer = new RelatorioContainer() { ListRelatorio = list, TotalByTipoPagamento = total }; var response = Request.CreateResponse(HttpStatusCode.OK, relatorioContainer); var tsc = new TaskCompletionSource<HttpResponseMessage>(); tsc.SetResult(response); return await tsc.Task; }