예제 #1
0
 public IEnumerable <TodoDto> GetTodoList([FromServices] ITodoListService todoListService, [FromBody] SearchTodosDto condition)
 {
     return(todoListService.GetTodoList(condition));
 }
예제 #2
0
        /// <summary>
        /// 获取待办事项列表
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public IEnumerable <TodoDto> GetTodoList(SearchTodosDto condition)
        {
            var todolist = new List <TodoDto>();

            if (condition.Priority == 0 && condition.StateId == 0)
            {
                if (condition.BeginTime != condition.EndTime)
                {
                    todolist = todoListDbContext.Todos.Where(o => o.StartDate >= condition.BeginTime &&
                                                             o.StartDate <= condition.EndTime && o.UserId == condition.UserId).Select(o => new TodoDto()
                    {
                        Id         = o.Id,
                        Content    = o.Content,
                        StartDate  = o.StartDate,
                        FinishDate = o.FinishDate,
                        Priority   = o.Priority,
                        StateId    = o.StateId,
                    }).ToList();
                }
                else
                {
                    todolist = todoListDbContext.Todos.Where(o => o.StartDate >= condition.BeginTime &&
                                                             o.UserId == condition.UserId).Select(o => new TodoDto()
                    {
                        Id         = o.Id,
                        Content    = o.Content,
                        StartDate  = o.StartDate,
                        FinishDate = o.FinishDate,
                        Priority   = o.Priority,
                        StateId    = o.StateId,
                    }).ToList();
                }
            }
            else if (condition.Priority == 0)
            {
                if (condition.BeginTime != condition.EndTime)
                {
                    todolist = todoListDbContext.Todos.Where(o => o.StartDate >= condition.BeginTime && o.StartDate <= condition.EndTime && o.UserId == condition.UserId && o.StateId == condition.StateId)
                               .Select(o => new TodoDto()
                    {
                        Id         = o.Id,
                        Content    = o.Content,
                        StartDate  = o.StartDate,
                        FinishDate = o.FinishDate,
                        Priority   = o.Priority,
                        StateId    = o.StateId,
                    }).ToList();
                }
                else
                {
                    todolist = todoListDbContext.Todos.Where(o => o.StartDate >= condition.BeginTime && o.UserId == condition.UserId && o.StateId == condition.StateId)
                               .Select(o => new TodoDto()
                    {
                        Id         = o.Id,
                        Content    = o.Content,
                        StartDate  = o.StartDate,
                        FinishDate = o.FinishDate,
                        Priority   = o.Priority,
                        StateId    = o.StateId,
                    }).ToList();
                }
            }
            else if (condition.StateId == 0)
            {
                if (condition.BeginTime != condition.EndTime)
                {
                    todolist = todoListDbContext.Todos.Where(o => o.StartDate >= condition.BeginTime && o.StartDate <= condition.EndTime && o.UserId == condition.UserId && o.Priority == condition.Priority)
                               .Select(o => new TodoDto()
                    {
                        Id         = o.Id,
                        Content    = o.Content,
                        StartDate  = o.StartDate,
                        FinishDate = o.FinishDate,
                        Priority   = o.Priority,
                        StateId    = o.StateId,
                    }).ToList();
                }
                else
                {
                    todolist = todoListDbContext.Todos.Where(o => o.StartDate >= condition.BeginTime &&
                                                             o.UserId == condition.UserId && o.Priority == condition.Priority)
                               .Select(o => new TodoDto()
                    {
                        Id         = o.Id,
                        Content    = o.Content,
                        StartDate  = o.StartDate,
                        FinishDate = o.FinishDate,
                        Priority   = o.Priority,
                        StateId    = o.StateId,
                    }).ToList();
                }
            }
            else
            {
                if (condition.BeginTime != condition.EndTime)
                {
                    todolist = todoListDbContext.Todos.Where(o => o.StartDate >= condition.BeginTime &&
                                                             o.StartDate <= condition.EndTime &&
                                                             o.UserId == condition.UserId && o.StateId == condition.StateId && o.Priority == condition.Priority)
                               .Select(o => new TodoDto()
                    {
                        Id         = o.Id,
                        Content    = o.Content,
                        StartDate  = o.StartDate,
                        FinishDate = o.FinishDate,
                        Priority   = o.Priority,
                        StateId    = o.StateId,
                    }).ToList();
                }
                else
                {
                    todolist = todoListDbContext.Todos.Where(o => o.StartDate >= condition.BeginTime &&
                                                             o.UserId == condition.UserId && o.StateId == condition.StateId && o.Priority == condition.Priority)
                               .Select(o => new TodoDto()
                    {
                        Id         = o.Id,
                        Content    = o.Content,
                        StartDate  = o.StartDate,
                        FinishDate = o.FinishDate,
                        Priority   = o.Priority,
                        StateId    = o.StateId,
                    }).ToList();
                }
            }
            return(todolist);
        }