added sollicitatie repo ect
This commit is contained in:
parent
ae2fc02378
commit
3ee6e09d8e
Binary file not shown.
@ -17,48 +17,40 @@ namespace AlfaPrentice.Controllers
|
|||||||
public class BedrijfController : ControllerBase
|
public class BedrijfController : ControllerBase
|
||||||
{
|
{
|
||||||
//constructor
|
//constructor
|
||||||
public readonly AlfaPrenticeContext _context;
|
|
||||||
public IBedrijfRepository bedrijfRepo;
|
public IBedrijfRepository bedrijfRepo;
|
||||||
public BedrijfController(AlfaPrenticeContext context, IBedrijfRepository bedrijfRepo)
|
public BedrijfController(IBedrijfRepository bedrijfRepo)
|
||||||
{
|
{
|
||||||
this.bedrijfRepo = bedrijfRepo;
|
this.bedrijfRepo = bedrijfRepo;
|
||||||
_context = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{Bedrijf_ID}")]
|
[HttpGet]
|
||||||
public IEnumerable<Bedrijf> GetBedrijf(int Bedrijf_ID)
|
public IEnumerable<Bedrijf> GetBedrijf()
|
||||||
{
|
{
|
||||||
var bedrijf =bedrijfRepo.GetBedrijf(Bedrijf_ID);
|
var bedrijven =bedrijfRepo.GetBedrijven();
|
||||||
|
return bedrijven;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//get bedrijf by ID
|
||||||
|
[HttpGet("{Bedrijf_ID}")]
|
||||||
|
public Bedrijf GetBedrijf(int Bedrijf_ID)
|
||||||
|
{
|
||||||
|
var bedrijf = bedrijfRepo.GetBedrijf(Bedrijf_ID);
|
||||||
return bedrijf;
|
return bedrijf;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* //getbedrijf
|
//add geheel bedrijf
|
||||||
[HttpGet("{Bedrijf_ID}")]
|
[HttpPost]
|
||||||
public async Task<IEnumerable<Bedrijf>> GetBedrijf(int Bedrijf_ID)
|
public void AddBedrijf([FromBody] Bedrijf bedrijf)
|
||||||
{
|
{
|
||||||
return await _context.Bedrijf.Where(B => B.Bedrijf_ID == Bedrijf_ID).ToListAsync();
|
bedrijfRepo.AddBedrijf(bedrijf);
|
||||||
// return getBedrijf;
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
// GET: api/<BedrijfController>
|
//update een volledig bedrijf
|
||||||
/* [HttpGet]
|
[HttpPost]
|
||||||
public IEnumerable<string> Get()
|
public void UpdateBedrijf([FromBody] Bedrijf bedrijf)
|
||||||
{
|
{
|
||||||
return new string[] { "value1", "value2" };
|
bedrijfRepo.UpdateBedrijf(bedrijf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET api/<BedrijfController>/5
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public string Get(int id)
|
|
||||||
{
|
|
||||||
return "value";
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST api/<BedrijfController>
|
|
||||||
[HttpPost]
|
|
||||||
public void Post([FromBody] string value)
|
|
||||||
{
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
49
AlfaPrentice/Controllers/SollicitatieController.cs
Normal file
49
AlfaPrentice/Controllers/SollicitatieController.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,7 +8,9 @@ namespace AlfaPrentice.Repositorys.Interfaces
|
|||||||
{
|
{
|
||||||
public interface IBedrijfRepository
|
public interface IBedrijfRepository
|
||||||
{
|
{
|
||||||
|
List<Bedrijf> GetBedrijven();
|
||||||
Bedrijf GetBedrijf(int Bedrijf_ID);
|
Bedrijf GetBedrijf(int Bedrijf_ID);
|
||||||
//drijf GetBedrijf(int Bedrijf_ID);
|
Bedrijf AddBedrijf(Bedrijf bedrijf);
|
||||||
|
Bedrijf UpdateBedrijf(Bedrijf bedrijf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
using AlfaPrentice.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AlfaPrentice.Repositorys.Interfaces
|
||||||
|
{
|
||||||
|
public interface ISollicitatieRepository
|
||||||
|
{
|
||||||
|
List<Sollicitatie> GetSollicitaties();
|
||||||
|
Sollicitatie GetSollicitatie(int Student_ID);
|
||||||
|
Sollicitatie AddSollicitatie(Sollicitatie Sollicitatie);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,10 +16,35 @@ namespace AlfaPrentice.Repositorys.implementaties
|
|||||||
this.db = db;
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//get list of bedrijfven
|
||||||
|
public List<Bedrijf> GetBedrijven()
|
||||||
|
{
|
||||||
|
return db.Bedrijf.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//get bedrijf by ID
|
||||||
public Bedrijf GetBedrijf(int Bedrijf_ID)
|
public Bedrijf GetBedrijf(int Bedrijf_ID)
|
||||||
{
|
{
|
||||||
return db.Bedrijf.Where(B => B.Bedrijf_ID == Bedrijf_ID).FirstOrDefault();
|
return db.Bedrijf.Where(B => B.Bedrijf_ID == Bedrijf_ID).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add geheel bedrijf
|
||||||
|
public Bedrijf AddBedrijf(Bedrijf bedrijf)
|
||||||
|
{
|
||||||
|
db.Bedrijf.Add(bedrijf);
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
return bedrijf;
|
||||||
|
}
|
||||||
|
|
||||||
|
//update a complete bedrijf
|
||||||
|
public Bedrijf UpdateBedrijf(Bedrijf bedrijf)
|
||||||
|
{
|
||||||
|
db.Bedrijf.Update(bedrijf);
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
return bedrijf;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,39 @@
|
|||||||
|
using AlfaPrentice.Data;
|
||||||
|
using AlfaPrentice.Models;
|
||||||
|
using AlfaPrentice.Repositorys.Interfaces;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AlfaPrentice.Repositorys.implementaties
|
||||||
|
{
|
||||||
|
public class SollicitatieRepository : ISollicitatieRepository
|
||||||
|
{
|
||||||
|
AlfaPrenticeContext db;
|
||||||
|
public SollicitatieRepository(AlfaPrenticeContext db)
|
||||||
|
{
|
||||||
|
this.db = db;
|
||||||
|
}
|
||||||
|
//get list of sollicitaties
|
||||||
|
public List<Sollicitatie> GetSollicitaties()
|
||||||
|
{
|
||||||
|
return db.Sollicitatie.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
//get sollicitatie by Student_ID
|
||||||
|
public Sollicitatie GetSollicitatie(int Student_ID)
|
||||||
|
{
|
||||||
|
return db.Sollicitatie.Where(S => S.Student_ID == Student_ID).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Add complete sollicitatie
|
||||||
|
public Sollicitatie AddSollicitatie(Sollicitatie sollicitatie)
|
||||||
|
{
|
||||||
|
db.Sollicitatie.Add(sollicitatie);
|
||||||
|
db.SaveChanges();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -33,7 +33,9 @@ namespace AlfaPrentice
|
|||||||
services.Configure<Models.AppSettings>(Configuration);
|
services.Configure<Models.AppSettings>(Configuration);
|
||||||
services.AddDbContext<AlfaPrenticeContext>(options => options.UseMySQL(Configuration.GetConnectionString("AlfaPrentice")));
|
services.AddDbContext<AlfaPrenticeContext>(options => options.UseMySQL(Configuration.GetConnectionString("AlfaPrentice")));
|
||||||
|
|
||||||
|
//depencies for interface and repos
|
||||||
services.AddTransient<IBedrijfRepository, BedrijfRepository>();
|
services.AddTransient<IBedrijfRepository, BedrijfRepository>();
|
||||||
|
services.AddTransient<ISollicitatieRepository, SollicitatieRepository>();
|
||||||
|
|
||||||
services.AddControllers();
|
services.AddControllers();
|
||||||
services.AddSwaggerGen(c =>
|
services.AddSwaggerGen(c =>
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user