72 lines
1.9 KiB
C#
72 lines
1.9 KiB
C#
using AlfaPrentice.Data;
|
|
using AlfaPrentice.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
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 BedrijfController : ControllerBase
|
|
{
|
|
//constructor
|
|
public readonly AlfaPrenticeContext _context;
|
|
|
|
|
|
|
|
public BedrijfController(AlfaPrenticeContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
//getbedrijf
|
|
[HttpGet]
|
|
public async Task<ActionResult<IEnumerable<Bedrijf>>> GetBedrijven()
|
|
{
|
|
return await _context.Bedrijf
|
|
.Select(x => bedrijfData(x))
|
|
.ToListAsync();
|
|
|
|
}
|
|
|
|
// GET: api/<BedrijfController>
|
|
/* [HttpGet]
|
|
public IEnumerable<string> Get()
|
|
{
|
|
return new string[] { "value1", "value2" };
|
|
}
|
|
|
|
// GET api/<BedrijfController>/5
|
|
[HttpGet("{id}")]
|
|
public string Get(int id)
|
|
{
|
|
return "value";
|
|
}
|
|
|
|
// POST api/<BedrijfController>
|
|
[HttpPost]
|
|
public void Post([FromBody] string value)
|
|
{
|
|
}*/
|
|
|
|
private static Bedrijf bedrijfData(Bedrijf bedrijf) =>
|
|
new Bedrijf
|
|
{
|
|
Bedrijf_ID = bedrijf.Bedrijf_ID,
|
|
Adres_ID = bedrijf.Adres_ID,
|
|
Naam = bedrijf.Naam,
|
|
Logo = bedrijf.Logo,
|
|
Beschrijving = bedrijf.Beschrijving,
|
|
Email = bedrijf.Email,
|
|
Telefoon = bedrijf.Telefoon,
|
|
Status = bedrijf.Status
|
|
};
|
|
}
|
|
}
|