public IEnumerable <TodoModel> FetchTodos(string login) { var user = _applicationContext.Users.Include(u => u.Todos) .ThenInclude(t => t.Tags).FirstOrDefault(u => u.Login == login); return(user.Todos.Select(t => _todoConverter.GetModelByEntity(t))); }
public IEnumerable <TodolistModel> GetTodolist(string login) { var todolist = _applicationContext.Users.Include(t => t.ToDoLists).ThenInclude(t => t.Tags) .FirstOrDefault(u => u.Login == login) .ToDoLists.Select(x => TDconverter.GetModelByEntity(x)) .OrderBy(d => d.Date).OrderBy(x => x.IsDone); return(todolist); }
public TodoModel GetModelByEntity(Todo entity) { if (entity == null) { return(null); } return(new TodoModel { Id = entity.Id, Name = entity.Name, Description = entity.Description, Completed = entity.Completed, Date = entity.Date, Tags = entity.Tags?.Select(t => _tagConverter.GetModelByEntity(t)).ToList() }); }