Exemplo n.º 1
0
        public async Task <ActionResult> Complete(CompleteData data)
        {
            _logger.LogInformation($"Completing task {data.Id}");
            var task = await _context.Tasks.FindAsync(data.Id);

            if (task == null)
            {
                _logger.LogError($"Task {data.Id} not found.");
                return(NotFound());
            }

            task.Complete = true;
            _context.Update(task);
            await _context.SaveChangesAsync();

            return(AcceptedAtAction(nameof(GetById), new { id = task.Id }, task));
        }