예제 #1
0
        public IActionResult ListCount([FromBody] IncomeSearchDto listParameters)
        {
            try
            {
                if (listParameters == null || !ModelState.IsValid)
                {
                    return(BadRequest("Invalid State"));
                }

                var basic     = _basicIncomeService.From(listParameters.Date, listParameters.Count);
                var recurring = _recurringIncomeService.From(listParameters.Date, listParameters.Count);

                return(Ok(new IncomeListDto
                {
                    Incomes = basic
                              .Concat(recurring)
                              .OrderByDescending(i => i.Date)
                              .Take(listParameters.Count)
                              .Select(t => new IncomeDto(t))
                              .ToList()
                }));
            }
            catch (Exception)
            {
                return(BadRequest("Error while listing incomes"));
            }
        }