예제 #1
0
        public IActionResult GetExpenses(string category, string description, int offset, int limit)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (string.IsNullOrEmpty(userId))
            {
                return(Unauthorized());
            }

            var userExpenses = _expensesRepository.FindUserExpensesOrderedByDateDesc(new FindUserExpensesQueryParameters
            {
                UserId      = userId,
                Category    = category,
                Description = description,
                Offset      = offset,
                Limit       = limit
            }, out var totalUserExpensesNumber);

            //BART: any reason this is passed in header instead of just an aggregate object? like

            /*
             * Total: int
             * Expenses: List<Expenses>
             */
            Response.Headers.Add("X-Total-Count", totalUserExpensesNumber.ToString());
            return(Ok(_expensesMapper.Map(userExpenses)));
        }
        public IActionResult GetExpenses(string category, string description, int offset, int limit)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (string.IsNullOrEmpty(userId))
            {
                return(Unauthorized());
            }

            var userExpenses = _expensesRepository.FindUserExpensesOrderedByDateDesc(new FindUserExpensesQueryParameters
            {
                UserId      = userId,
                Category    = category,
                Description = description,
                Offset      = offset,
                Limit       = limit
            }, out var totalUserExpensesNumber);

            Response.Headers.Add("X-Total-Count", totalUserExpensesNumber.ToString());
            return(Ok(_expensesMapper.Map(userExpenses)));
        }