コード例 #1
0
        public async Task <IActionResult> GetTransactionDatesByUser([FromBody] GetTransactionDatesDTO dto)
        {
            dto.UserId = GetLoggedUserId();
            var existentDates = await _transactionService.GetExistentTransactionsDatesByUser(dto);

            return(Ok(existentDates));
        }
コード例 #2
0
        public async Task <IEnumerable <ExistentTransactionsDatesResponseDTO> > GetExistentTransactionsDatesByUser(GetTransactionDatesDTO dto)
        {
            var dates = await _transactionRepository.GetDatesByUser(dto.UserId, dto.BankaccountId);

            var existentDates = new List <ExistentTransactionsDatesResponseDTO>();

            foreach (var date in dates)
            {
                var existentDate = existentDates.FirstOrDefault(d => d.Year == date.Year);
                if (existentDate == null)
                {
                    existentDate = new ExistentTransactionsDatesResponseDTO()
                    {
                        Year = date.Year,
                    };

                    existentDates.Add(existentDate);
                }
                existentDate.Months.Add(date.Month);
            }

            return(existentDates);
        }