public GetToDoRs GetToDoById(GetToDoRq request)
        {
            var response    = new GetToDoRs();
            var todoService = IocContainer.Resolve <TODOListApplication.Business.Services.Interfaces.IToDoService>();
            var result      = todoService.GetToDoById(request);

            response = result;
            return(response);
        }
示例#2
0
        public GetToDoRs GetToDoById(GetToDoRq request)
        {
            var response = new GetToDoRs();

            var result = _dbRepository.FirstOrDefault <ToDo>(e => e.Id == request.Id);

            response.Id   = result.Id;
            response.Name = result.Name;
            IQueryable <ToDoTask> toDoTaskList = null;

            if (request.CompletedTask)
            {
                toDoTaskList = _dbRepository.Where <ToDoTask>(e => e.ToDoId == request.Id && e.Completed == true);
            }

            if (request.ExpireDate)
            {
                toDoTaskList = _dbRepository.Where <ToDoTask>(e => e.ToDoId == request.Id && e.ExpireDateTime < DateTime.Now);
            }

            if (!request.ExpireDate && !request.CompletedTask)
            {
                toDoTaskList = _dbRepository.Where <ToDoTask>(e => e.ToDoId == request.Id && e.Completed == false);
            }

            response.ToDoTaskList = new List <ToDoTaskServiceModel>();

            if (toDoTaskList == null)
            {
                return(response);
            }
            foreach (var item in toDoTaskList)
            {
                response.ToDoTaskList.Add(new ToDoTaskServiceModel
                {
                    Id             = item.Id,
                    ExpireDateTime = item.ExpireDateTime,
                    ToDoId         = item.ToDoId,
                    TaskName       = item.TaskName,
                    Completed      = item.Completed,
                    Description    = item.Description
                });
            }


            return(response);
        }