public DeleteToDoEndPoint(string modulePath, [NotNull] ToDoDataStore dataStore) : base(modulePath) { if (dataStore == null) { throw new ArgumentNullException(nameof(dataStore)); } _dataStore = dataStore; Delete["{id}"] = _ => Handle(this.Bind <DeleteToDoRequest>()); }
private static void CreateRandomToDos(ToDoDataStore dataStore) { foreach (var thingToDo in GetRandomThingsToDo()) { var toDo = dataStore.Create(thingToDo); if (_rnd.NextDouble() < 0.5) { dataStore.Complete(toDo.Id); } } }
public void Initialize(IRegistry registry) { var modulePath = "/api/todos/"; var dataStore = new ToDoDataStore(); CreateRandomToDos(dataStore); registry.RegisterNancyEndPoint(() => new CreateToDoEndPoint(modulePath, dataStore)); registry.RegisterNancyEndPoint(() => new CompleteToDoEndPoint(modulePath, dataStore)); registry.RegisterNancyEndPoint(() => new UpdateToDoEndPoint(modulePath, dataStore)); registry.RegisterNancyEndPoint(() => new DeleteToDoEndPoint(modulePath, dataStore)); registry.RegisterNancyEndPoint(() => new GetToDoesEndPoint(modulePath, dataStore)); }
public GetToDoesEndPoint(string modulePath, [NotNull] ToDoDataStore dataStore) : base(modulePath) { if (dataStore == null) { throw new ArgumentNullException(nameof(dataStore)); } _dataStore = dataStore; Get["{id}"] = _ => GetById(this.Bind <GetByIdRequest>()); Get["/uncompleted"] = _ => GetAllUncompleted(); Get["/completed"] = _ => GetAllCompleted(); }