From 247ffd3b7435cf662d79ccee6e85dbb21e7818ac Mon Sep 17 00:00:00 2001 From: Yuee Shiness Date: Sat, 13 May 2023 22:45:29 +0400 Subject: [PATCH] RestAPI additions. --- ComputerStoreRestAPI/ComputerStoreRestAPI.csproj | 4 ++++ .../Controllers/MainController.cs | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ComputerStoreRestAPI/ComputerStoreRestAPI.csproj b/ComputerStoreRestAPI/ComputerStoreRestAPI.csproj index 60bf9ea..2c31334 100644 --- a/ComputerStoreRestAPI/ComputerStoreRestAPI.csproj +++ b/ComputerStoreRestAPI/ComputerStoreRestAPI.csproj @@ -10,4 +10,8 @@ + + + + diff --git a/ComputerStoreRestAPI/Controllers/MainController.cs b/ComputerStoreRestAPI/Controllers/MainController.cs index 57d937f..07770b7 100644 --- a/ComputerStoreRestAPI/Controllers/MainController.cs +++ b/ComputerStoreRestAPI/Controllers/MainController.cs @@ -1,5 +1,6 @@ using ComputerStoreContracts.BindingModels; using ComputerStoreContracts.BusinessLogicContracts; +using ComputerStoreContracts.SearchModels; using ComputerStoreContracts.ViewModels; using Microsoft.AspNetCore.Mvc; @@ -38,6 +39,20 @@ namespace ComputerStoreRestAPI.Controllers } } + [HttpGet] + public ComponentViewModel? GetComponent(int id) + { + try + { + return _componentLogic.ReadElement(new ComponentSearchModel { ID = id } ); + } + catch (Exception ex) + { + _logger.LogError(ex, "Receiving list of components error."); + throw; + } + } + [HttpDelete("{id}")] public bool DeleteComponent(int id) {