public TodosQuery(ITodosService todos) { Name = "Query"; Field <ListGraphType <TodoType> >( "todos", arguments: new QueryArguments( new QueryArgument <StringGraphType> { Name = "todoId" }, new QueryArgument <IntGraphType> { Name = "offset" }, new QueryArgument <IntGraphType> { Name = "limit" }), resolve: context => { var todoId = context.GetArgument <string>("todoId"); var offset = context.GetArgument <int>("offset"); var limit = context.GetArgument <int>("limit"); if (todoId == null) { return(todos.GetTodosAsync(offset, limit)); } //TODO: clean this up return(Task.FromResult(new List <Todo> { todos.GetTodoByIdAsync(todoId).Result }.AsEnumerable())); }); }
public TodosMutation(ITodosService todos) { Name = "Mutation"; Field <TodoType>( "createTodo", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <TodoCreateInputType> > { Name = "todo" }), resolve: context => { var todoInput = context.GetArgument <TodoCreateInput>("todo"); var id = Guid.NewGuid().ToString(); var todo = new Todo(id, todoInput.Description, todoInput.Complete); return(todos.CreateAsync(todo)); } ); Field <TodoType>( "updateTodo", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <TodoUpdateInputType> > { Name = "todo" }), resolve: context => { var todoInput = context.GetArgument <TodoUpdateInput>("todo"); var todo = new Todo(todoInput.Id, todoInput.Description, todoInput.Complete); return(todos.UpdateAsync(todo)); } ); FieldAsync <TodoType>( "completeTodo", arguments: new QueryArguments(new QueryArgument <NonNullGraphType <StringGraphType> > { Name = "todoId" }), resolve: async context => { var todoId = context.GetArgument <string>("todoId"); return(await context.TryAsyncResolve(async c => await todos.CompleteAsync(todoId))); } ); }
public TodosController(ITodosService todosService) { _todosService = todosService; }
public TodosController(IMapper mapper, ITodosService todosService, ILogger <TodosController> logger) { _mapper = mapper; _todosService = todosService; _logger = logger; }
public TodoType(ITodosService todos) { Field(x => x.Id); Field(x => x.Description); Field(x => x.Complete); }
public TodosController(ITodosService todos) { _todos = todos; }
public TodosViewModel(ITodosService todosService) { _todosService = todosService; }
public TodosController(ITodosService service) { todosService = service; }
public TodosController(ITodosService todosService) => this.todosService = todosService;
public TodosPresenter(ITodosView view, ITodosService todosService, List <Todo> items = null) { _view = view; _todosService = todosService; Items = items ?? Enumerable.Empty <Todo>().ToList(); }