예제 #1
0
        public Todo Get(int id)
        {
            _logger.LogInformation($"Received GET Request for {id}");
            TodoCounters.IncrementTodoGetRequests();

            return(_todoservice.Get(id));
        }
예제 #2
0
        public IEnumerable <Todo> Get()
        {
            _logger.LogInformation("Received GET Request ");
            TodoCounters.IncrementTodoGetRequests();

            return(_todoservice.Get().ToArray());
        }
예제 #3
0
        public IActionResult Create(Todo todo)
        {
            _logger.LogInformation("Received POST Request ");

            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }
            TodoCounters.IncrementTodoPostRequests();

            _todoservice.Create(todo);

            return(CreatedAtRoute("GetTask", new { id = todo.Id }, todo));
        }
예제 #4
0
        public IActionResult Update(Todo todo)
        {
            _logger.LogInformation("Received PUT Request ");

            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid data."));
            }
            TodoCounters.IncrementTodoUpdateRequests();

            _todoservice.Update(todo);

            return(Ok());
        }