using AlfaPrentice.Data;
using AlfaPrentice.Models;
using AlfaPrentice.Repositorys.Interfaces;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace AlfaPrentice.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SollicitatieController : ControllerBase
    {
        //constructor
        public ISollicitatieRepository sollicitatieRepo;
        public SollicitatieController(ISollicitatieRepository sollicitatieRepo)
        {
            this.sollicitatieRepo = sollicitatieRepo;
        }

        //get list sollicitaties
        [HttpGet]
        public IEnumerable<Sollicitatie> GetSollicitaties()
        {
            var sollicitaties = sollicitatieRepo.GetSollicitaties();
            return sollicitaties;
        }

        //get sollicitatie by student_ID
        [HttpGet("{Student_ID}")]
        public Sollicitatie GetSollicitatie(int Student_ID)
        {
            var sollicitatie = sollicitatieRepo.GetSollicitatie(Student_ID);
            return sollicitatie;
        }

        // POST api/<SollicitatieController>
        [HttpPost]
        public void Post([FromBody] Sollicitatie sollicitatie)
        {
            sollicitatieRepo.AddSollicitatie(sollicitatie);
        }

    }
}
