private static TaskDto TaskToDto(Task task) => new TaskDto { Id = task.Id, Name = task.Name, Date = task.Date, IsComplete = task.IsComplete };
public async Task <ActionResult <TaskDto> > CreateTodoItem(TaskDto taskDto) { var task = new Task { IsComplete = taskDto.IsComplete, Date = taskDto.Date, Name = taskDto.Name }; _context.Tasks.Add(task); await _context.SaveChangesAsync(); return(CreatedAtAction( nameof(GetTask), new { id = task.Id }, TaskToDto(task))); }