예제 #1
0
        public async Task <IEnumerable <PlayerAttendanceDto> > HandleAsync(PlayerAttendanceQuery query)
        {
            var dateFrom = !string.IsNullOrEmpty(query.DateFrom) ? DateTime.Parse(query.DateFrom)
                : DateTime.MinValue;
            var dateTo = !string.IsNullOrEmpty(query.DateTo) ? DateTime.Parse(query.DateTo)
                : DateTime.MaxValue;
            var playerAttendances = _dbContext.PlayerAttendance.Include(pa => pa.Attendance).Where(p => p.PlayerId == query.PlayerId &&
                                                                                                   p.Attendance.Date >= dateFrom && p.Attendance.Date <= dateTo)
                                    .Select(a => new PlayerAttendanceDto()
            {
                Date     = a.Attendance.Date.ToShortDateString(),
                PlayerId = query.PlayerId,
                GroupId  = a.Attendance.GroupId
            });

            return(await playerAttendances.ToListAsync());
        }
예제 #2
0
        public async Task <ActionResult> GetPlayerAttendance(Guid playerId, [FromQuery] string dateFrom, [FromQuery] string dateTo)
        {
            var query = new PlayerAttendanceQuery()
            {
                PlayerId = playerId,
                DateFrom = dateFrom,
                DateTo   = dateTo
            };
            var results = await _queryDispatcher.QueryAsync <IEnumerable <PlayerAttendanceDto> >(query);

            if (results == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(results));
            }
        }