From 4686845c5cefdc2db5fda8a1ee54c9c373c38e30 Mon Sep 17 00:00:00 2001 From: TypoMustakes Date: Tue, 5 Dec 2023 14:38:11 +0100 Subject: [PATCH] Left out this file accidentally --- .../CustomerController.cs | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 WD7UVN_HFT_2023241.Endpoint/CustomerController.cs diff --git a/WD7UVN_HFT_2023241.Endpoint/CustomerController.cs b/WD7UVN_HFT_2023241.Endpoint/CustomerController.cs new file mode 100644 index 0000000..87fbc81 --- /dev/null +++ b/WD7UVN_HFT_2023241.Endpoint/CustomerController.cs @@ -0,0 +1,48 @@ +using Microsoft.AspNetCore.Mvc; +using WD7UVN_HFT_2023241.Logic; +using WD7UVN_HFT_2023241.Models; + +namespace WD7UVN_HFT_2023241.Endpoint +{ + [ApiController] + [Route("api/database")] + public class CustomerController : ControllerBase + { + public ILogicServices LogicServices { get; set; } + + public CustomerController(ILogicServices LogicServices) + { + this.LogicServices = LogicServices; + } + + [HttpGet()] + public IActionResult ReadAllCustomers() + { + return View(LogicServices.CRUDOperations.ReadAllCustomers()); + } + + [HttpGet("{id}")] + public Customer ReadCustomer(int id) + { + return LogicServices.CRUDOperations.ReadCustomer(id); + } + +[HttpPut()] + public void PutCustomer([FromBody] Customer e) + { + LogicServices.CRUDOperations.CreateCustomer(e); + } + +[HttpPost()] + public void UpdateCustomer([FromBody] Customer e) + { + LogicServices.CRUDOperations.UpdateCustomer(e); + } + + [HttpDelete()] + public void DeleteCustomer([FromBody] int id) + { + LogicServices.CRUDOperations.DeleteCustomer(id); + } + } +}