<?php

namespace Signteer\Core\Writer;

use Plainwork\Database\Database;
use Plainwork\Database\Query;
use Signteer\Core\Database\SignupTable as Table;

class SignupWriter
{
    public $db = Database::class;

    public function create(int $taskId, int $volunteerId): int
    {
        $q = $this->db->q();

        $q->insertInto(Table::NAME);
        $q->valueInt(Table::COL_TASK_ID, $taskId);
        $q->valueInt(Table::COL_VOLUNTEER_ID, $volunteerId);

        $id = $q->execute();

        return $id;
    }

    public function delete(int $taskId, int $volunteerId)
    {
        $q = $this->db->q();

        $q->deleteFrom(Table::NAME);
        $q->whereInt(Table::COL_TASK_ID, '=', $taskId);
        $q->whereInt(Table::COL_VOLUNTEER_ID, '=', $volunteerId);

        $q->execute();
    }
}
