Example #1
0
        public async Task <List <TaskListDto> > GetAll(GetAllTasksInput input)
        {
            var tasks = await _taskRepository
                        .GetAll()
                        .Include(t => t.AssignedPerson)
                        .WhereIf(input.State.HasValue, o => o.State == input.State.Value)
                        .OrderByDescending(o => o.CreationTime)
                        .ToListAsync();

            return(new List <TaskListDto>(ObjectMapper.Map <List <TaskListDto> >(tasks)));
        }
        public async Task <ListResultOutput <TaskListDto> > GetAll(GetAllTasksInput input)
        {
            var tasks = await _taskRepository
                        .GetAll()
                        .WhereIf(input.State.HasValue, t => t.State == input.State.Value)
                        .OrderByDescending(t => t.CreationTime)
                        .ToListAsync();

            return(new ListResultOutput <TaskListDto>(
                       ObjectMapper.Map <List <TaskListDto> >(tasks)
                       ));
        }
Example #3
0
        public async Task <ListResultDto <TaskListDto> > GetAllAsync(GetAllTasksInput input)
        {
            var tasks = await _taskRepository.GetAll()
                        .Include(t => t.AssignedPerson)//And including the Task.AssignedPerson property to the query. Just added the Include line. Thus, GetAll method will return Assigned person information with the tasks. Since we used AutoMapper, new properties will also be copied to DTO automatically.
                        .WhereIf(input.State.HasValue, t => t.State == input.State.Value)
                        .OrderByDescending(t => t.CreationTime)
                        .ToListAsync();

            return(new ListResultDto <TaskListDto>(ObjectMapper.Map <List <TaskListDto> >(tasks)));

            //var tasks = await _taskRepository
            //   .GetAll()
            //   .WhereIf(input.State.HasValue, t => t.State == input.State.Value)
            //   .OrderByDescending(t => t.CreationTime)
            //   .ToListAsync();

            //return new ListResultDto<TaskListDto>(
            //    ObjectMapper.Map<List<TaskListDto>>(tasks)
            //);
        }