This commit is contained in:
devil_1nc 2023-05-17 14:20:21 +04:00
commit baf2d84108
15 changed files with 313 additions and 167 deletions

View File

@ -3,6 +3,7 @@ using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.SearchModels; using ComputerShopContracts.SearchModels;
using ComputerShopContracts.StorageContracts; using ComputerShopContracts.StorageContracts;
using ComputerShopContracts.ViewModels; using ComputerShopContracts.ViewModels;
using ComputerShopDataModels.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -16,11 +17,13 @@ namespace ComputerShopBusinessLogic.BusinessLogics
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IAssemblyStorage _assemblyStorage; private readonly IAssemblyStorage _assemblyStorage;
private readonly IComponentStorage _componentStorage;
public AssemblyLogic(ILogger<AssemblyLogic> logger, IAssemblyStorage assemblyStorage) public AssemblyLogic(ILogger<AssemblyLogic> logger, IAssemblyStorage assemblyStorage, IComponentStorage componentStorage)
{ {
_logger = logger; _logger = logger;
_assemblyStorage = assemblyStorage; _assemblyStorage = assemblyStorage;
_componentStorage = componentStorage;
} }
public bool Create(AssemblyBindingModel model) public bool Create(AssemblyBindingModel model)
@ -87,6 +90,38 @@ namespace ComputerShopBusinessLogic.BusinessLogics
return true; return true;
} }
public bool AddComponentToAssembly(AssemblySearchModel model, ComponentSearchModel componentmodel, int amount)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("AddComponentToAssembly. AssemblyName:{AssemblyName}.Id:{ Id}", model.AssemblyName, model.Id);
var element = _assemblyStorage.GetElement(model);
var component = _componentStorage.GetElement(componentmodel);
if (element == null || component == null)
{
return false;
}
_logger.LogInformation("AddComponentToAssembly find. Id:{Id}", element.Id);
element.AssemblyComponents[component.Id] = (component, amount);
_assemblyStorage.Update(new()
{
Id = element.Id,
AssemblyName = element.AssemblyName,
Price = element.Price + component.Cost * amount,
ClientId = element.ClientId,
AssemblyComponents = element.AssemblyComponents,
});
return true;
}
private void CheckModel(AssemblyBindingModel model, bool withParams = true) private void CheckModel(AssemblyBindingModel model, bool withParams = true)
{ {
if (model == null) if (model == null)

View File

@ -24,8 +24,7 @@ namespace ComputerShopBusinessLogic.BusinessLogics
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model) public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
{ {
_logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id); _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id);
var list = model == null ? _componentStorage.GetFullList() : var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model);
_componentStorage.GetFilteredList(model);
if (list == null) if (list == null)
{ {
_logger.LogWarning("ReadList return null list"); _logger.LogWarning("ReadList return null list");

View File

@ -7,78 +7,77 @@ using System.Threading.Tasks;
namespace ComputerShopBusinessLogic.OfficePackage namespace ComputerShopBusinessLogic.OfficePackage
{ {
public class AbstractSaveToExcel public abstract class AbstractSaveToExcel
{ {
public void CreateReport(ExcelInfo info) //public void CreateReport(ExcelInfo info)
{ //{
CreateExcel(info); // CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters // InsertCellInWorksheet(new ExcelCellParameters
{ // {
ColumnName = "A", // ColumnName = "A",
RowIndex = 1, // RowIndex = 1,
Text = info.Title, // Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title // StyleInfo = ExcelStyleInfoType.Title
}); // });
MergeCells(new ExcelMergeParameters // MergeCells(new ExcelMergeParameters
{ // {
CellFromName = "A1", // CellFromName = "A1",
CellToName = "C1" // CellToName = "C1"
}); // });
uint rowIndex = 2; // uint rowIndex = 2;
foreach (var pc in info.DocumentBlanks) // foreach (var pc in info.DocumentBlanks)
{ // {
InsertCellInWorksheet(new ExcelCellParameters // InsertCellInWorksheet(new ExcelCellParameters
{ // {
ColumnName = "A", // ColumnName = "A",
RowIndex = rowIndex, // RowIndex = rowIndex,
Text = pc.DocumentName, // Text = pc.DocumentName,
StyleInfo = ExcelStyleInfoType.Text // StyleInfo = ExcelStyleInfoType.Text
}); // });
rowIndex++; // rowIndex++;
foreach (var (Blank, Count) in pc.Blanks) // foreach (var (Blank, Count) in pc.Blanks)
{ // {
InsertCellInWorksheet(new ExcelCellParameters // InsertCellInWorksheet(new ExcelCellParameters
{ // {
ColumnName = "B", // ColumnName = "B",
RowIndex = rowIndex, // RowIndex = rowIndex,
Text = Blank, // Text = Blank,
StyleInfo = ExcelStyleInfoType.TextWithBorder // StyleInfo = ExcelStyleInfoType.TextWithBorder
}); // });
InsertCellInWorksheet(new ExcelCellParameters // InsertCellInWorksheet(new ExcelCellParameters
{ // {
ColumnName = "C", // ColumnName = "C",
RowIndex = rowIndex, // RowIndex = rowIndex,
Text = Count.ToString(), // Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBorder // StyleInfo = ExcelStyleInfoType.TextWithBorder
}); // });
rowIndex++; // rowIndex++;
} // }
InsertCellInWorksheet(new ExcelCellParameters // InsertCellInWorksheet(new ExcelCellParameters
{ // {
ColumnName = "A", // ColumnName = "A",
RowIndex = rowIndex, // RowIndex = rowIndex,
Text = "Итого", // Text = "Итого",
StyleInfo = ExcelStyleInfoType.Text // StyleInfo = ExcelStyleInfoType.Text
}); // });
InsertCellInWorksheet(new ExcelCellParameters // InsertCellInWorksheet(new ExcelCellParameters
{ // {
ColumnName = "C", // ColumnName = "C",
RowIndex = rowIndex, // RowIndex = rowIndex,
Text = pc.TotalCount.ToString(), // Text = pc.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text // StyleInfo = ExcelStyleInfoType.Text
}); // });
rowIndex++; // rowIndex++;
} // }
SaveExcel(info); // SaveExcel(info);
} //}
/// Создание excel-файла ///// Создание excel-файла
protected abstract void CreateExcel(ExcelInfo info); //protected abstract void CreateExcel(ExcelInfo info);
/// Добавляем новую ячейку в лист ///// Добавляем новую ячейку в лист
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams); //protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
/// Объединение ячеек ///// Объединение ячеек
protected abstract void MergeCells(ExcelMergeParameters excelParams); //protected abstract void MergeCells(ExcelMergeParameters excelParams);
/// Сохранение файла ///// Сохранение файла
protected abstract void SaveExcel(ExcelInfo info); //protected abstract void SaveExcel(ExcelInfo info);
} }
} }
}

View File

@ -1,5 +1,6 @@
using ComputerShopClientApp.Models; using ComputerShopClientApp.Models;
using ComputerShopContracts.BindingModels; using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels; using ComputerShopContracts.ViewModels;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Diagnostics; using System.Diagnostics;
@ -30,7 +31,7 @@ namespace ComputerShopClientApp.Controllers
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponentlist")); return View(APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponentlist?clientId={APIClient.Client.Id}"));
} }
public IActionResult Assembly() public IActionResult Assembly()
{ {
@ -38,7 +39,7 @@ namespace ComputerShopClientApp.Controllers
{ {
return Redirect("~/Home/Enter"); return Redirect("~/Home/Enter");
} }
return View(APIClient.GetRequest<List<AssemblyViewModel>>($"api/assembly/getassemblylist")); return View(APIClient.GetRequest<List<AssemblyViewModel>>($"api/Assembly/getassemblylist?clientId={APIClient.Client.Id}"));
} }
[HttpGet] [HttpGet]
@ -129,7 +130,7 @@ namespace ComputerShopClientApp.Controllers
[HttpGet] [HttpGet]
public IActionResult CreatePurchase() public IActionResult CreatePurchase()
{ {
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentlist"); ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/main/getcomponentlist?clientId={APIClient.Client.Id}");
return View(); return View();
} }
@ -182,7 +183,7 @@ namespace ComputerShopClientApp.Controllers
[HttpGet] [HttpGet]
public IActionResult DeleteComponent() public IActionResult DeleteComponent()
{ {
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentlist"); ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/main/getcomponentlist?clientId={APIClient.Client.Id}");
return View(); return View();
} }
[HttpDelete] [HttpDelete]
@ -202,31 +203,77 @@ namespace ComputerShopClientApp.Controllers
[HttpGet] [HttpGet]
public IActionResult CreateAssembly() public IActionResult CreateAssembly()
{ {
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/component/getcomponentlist"); ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponentlist?clientId={APIClient.Client.Id}");
ViewBag.CurrentComponents = new List<ComponentViewModel>(); ViewBag.CurrentComponents = new List<ComponentViewModel>();
return View(); return View();
} }
[HttpPost] [HttpPost]
public void CreateAssembly(string name, int sum) public void CreateAssembly(string name, int cost)
{ {
if (APIClient.Client == null) if (APIClient.Client == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
if (sum <= 0) APIClient.PostRequest("api/assembly/createassembly", new AssemblyBindingModel
{ {
throw new Exception("Сумма должна быть больше 0"); ClientId = APIClient.Client.Id,
} AssemblyName = name,
//APIClient.PostRequest("api/assembly/createassembly", new AssemblyBindingModel Price = cost,
//{ });
// ClientId = APIClient.Client.Id,
// AssemblyName = name,
// Price = 0,
// AssemblyComponents = new()
//});
System.Diagnostics.Debug.WriteLine("it might work"); System.Diagnostics.Debug.WriteLine("it might work");
Response.Redirect("Index"); Response.Redirect("Assembly");
}
[HttpGet]
public IActionResult DeleteAssembly()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Assemblies = APIClient.GetRequest<List<AssemblyViewModel>>($"api/assembly/GetAssemblyList?clientId={APIClient.Client.Id}");
return View();
}
[HttpPost]
public void DeleteAssembly(int assembly)
{
if (APIClient.Client == null)
{
throw new Exception("Необходима авторизация");
}
APIClient.PostRequest("api/assembly/deleteassembly", new AssemblyBindingModel
{
Id = assembly
});
Response.Redirect("Assembly");
}
public IActionResult AddComponentToAssembly()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Assemblies = APIClient.GetRequest<List<AssemblyViewModel>>($"api/assembly/getassemblylist?clientId={APIClient.Client.Id}");
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponentlist?clientId={APIClient.Client.Id}");
return View();
}
[HttpPost]
public void AddComponentToAssembly(int assembly, int component, int amount)
{
if (APIClient.Client == null)
{
throw new Exception("Необходима авторизация");
}
APIClient.PostRequest("api/assembly/AddComponentToAssembly", Tuple.Create(
new AssemblySearchModel() { Id = assembly },
new ComponentSearchModel() { Id = component },
amount
));
Response.Redirect("Assembly");
} }

View File

@ -0,0 +1,31 @@
@using ComputerShopContracts.ViewModels;
@using ComputerShopDataModels.Models;
@{
ViewData["Title"] = "AddComponentToAssembly";
}
@model Dictionary<int, IComponentModel>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Сборка: </label>
<div class="u-input u-input-rectangle">
<select id="assembly" name="assembly" class="form-control" asp-items="@(new SelectList(@ViewBag.Assemblies, "Id", "AssemblyName"))"></select>
</div>
</div>
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Компонент: </label>
<div class="u-input u-input-rectangle">
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components, "Id", "ComponentName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Количество:</div>
<div class="col-8"><input type="text" name="amount" id="amount" /></div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Добавить компонент" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -22,6 +22,15 @@
<p> <p>
<a asp-action="CreateAssembly">Создать сборку</a> <a asp-action="CreateAssembly">Создать сборку</a>
</p> </p>
<p>
<a asp-action="EditAssembly">Изменить сборку</a>
</p>
<p>
<a asp-action="DeleteAssembly">Удалить сборку</a>
</p>
<p>
<a asp-action="AddComponentToAssembly">Добавить комплектующее к сборке</a>
</p>
<table class="table"> <table class="table">
<thead> <thead>
<tr> <tr>

View File

@ -1,6 +1,4 @@
@using ComputerShopContracts.ViewModels @{
@{
ViewData["Title"] = "CreateAssembly"; ViewData["Title"] = "CreateAssembly";
} }
<div class="text-center"> <div class="text-center">
@ -8,64 +6,15 @@
</div> </div>
<form method="post"> <form method="post">
<div class="row"> <div class="row">
<div class="col-4">Компонент:</div> <div class="col-4">Название:</div>
<div class="col-8"> <div class="col-8"><input type="text" name="name" id="name" /></div>
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"Id", "ComponentName"))"></select>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-4">Количество:</div> <div class="col-4">Цена:</div>
<div class="col-8"><input type="text" name="count" id="count" /></div> <div class="col-8"><input type="text" name="cost" id="cost" /></div>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-8"></div> <div class="col-8"></div>
<div class="col-4"><input type="submit" value="Добавить компонент" class="btn btn-primary" /></div> <div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать сборку" class="btn btn-primary" /></div>
</div> </div>
</form> </form>
<div class="text-center">
<h1 class="display-4">Список компонентов</h1>
</div>
<div class="text-center">
@{
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Компонент
</th>
<th>
Цена
</th>
</tr>
</thead>
<tbody>
@foreach (var item in (ViewBag.CurrentComponents as IEnumerable<ComponentViewModel>))
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.ComponentName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Cost)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -0,0 +1,16 @@
@{
ViewData["Title"] = "DeleteAssembly";
}
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Сборка: </label>
<div class="u-input u-input-rectangle">
<select id="assembly" name="assembly" class="form-control" asp-items="@(new SelectList(@ViewBag.Assemblies, "Id", "AssemblyName"))"></select>
</div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Удалить" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
</div>
</form>

View File

@ -1,6 +1,7 @@
using ComputerShopContracts.BindingModels; using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels; using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels; using ComputerShopContracts.ViewModels;
using ComputerShopDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -16,5 +17,6 @@ namespace ComputerShopContracts.BusinessLogicContracts
bool Create(AssemblyBindingModel model); bool Create(AssemblyBindingModel model);
bool Update(AssemblyBindingModel model); bool Update(AssemblyBindingModel model);
bool Delete(AssemblyBindingModel model); bool Delete(AssemblyBindingModel model);
bool AddComponentToAssembly(AssemblySearchModel model, ComponentSearchModel componentmodel, int amount);
} }
} }

View File

@ -10,5 +10,6 @@ namespace ComputerShopContracts.SearchModels
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string? AssemblyName { get; set; } public string? AssemblyName { get; set; }
public int? ClientId { get; set; }
} }
} }

View File

@ -10,5 +10,6 @@ namespace ComputerShopContracts.SearchModels
{ {
public int? Id { get; set; } public int? Id { get; set; }
public string? ComponentName { get; set; } public string? ComponentName { get; set; }
public int? ClientId { get; set; }
} }
} }

View File

@ -27,18 +27,29 @@ namespace ComputerShopDatabaseImplement.Implements
} }
public List<AssemblyViewModel> GetFilteredList(AssemblySearchModel model) public List<AssemblyViewModel> GetFilteredList(AssemblySearchModel model)
{ {
if (string.IsNullOrEmpty(model.AssemblyName)) if (string.IsNullOrEmpty(model.AssemblyName) && model.ClientId == null)
{ {
return new(); return new();
} }
using var context = new ComputerShopDatabase(); using var context = new ComputerShopDatabase();
return context.Assemblies if (model.ClientId != null)
.Include(x => x.Components) return context.Assemblies
.ThenInclude(x => x.Component) .Include(x => x.Components)
.Where(x => x.AssemblyName.Contains(model.AssemblyName)) .ThenInclude(x => x.Component)
.ToList() .Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel) .ToList()
.ToList(); .Select(x => x.GetViewModel)
.ToList();
else
{
return context.Assemblies
.Include(x => x.Components)
.ThenInclude(x => x.Component)
.Where(x => x.AssemblyName.Contains(model.AssemblyName))
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
} }
public AssemblyViewModel? GetElement(AssemblySearchModel model) public AssemblyViewModel? GetElement(AssemblySearchModel model)
{ {

View File

@ -23,15 +23,25 @@ namespace ComputerShopDatabaseImplement.Implements
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
model) model)
{ {
if (string.IsNullOrEmpty(model.ComponentName)) if (string.IsNullOrEmpty(model.ComponentName) && model.ClientId == null)
{ {
return new(); return new();
} }
using var context = new ComputerShopDatabase(); using var context = new ComputerShopDatabase();
return context.Components if (!string.IsNullOrEmpty(model.ComponentName))
.Where(x => x.ComponentName.Contains(model.ComponentName)) {
.Select(x => x.GetViewModel) return context.Components
.ToList(); .Where(x => x.ComponentName.Contains(model.ComponentName))
.Select(x => x.GetViewModel)
.ToList();
}
else
{
return context.Components
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
} }
public ComponentViewModel? GetElement(ComponentSearchModel model) public ComponentViewModel? GetElement(ComponentSearchModel model)
{ {

View File

@ -1,6 +1,8 @@
using ComputerShopContracts.BindingModels; using ComputerShopContracts.BindingModels;
using ComputerShopContracts.BusinessLogicContracts; using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels; using ComputerShopContracts.ViewModels;
using ComputerShopDataModels.Models;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
namespace ComputerShopRestApi.Controllers namespace ComputerShopRestApi.Controllers
@ -19,11 +21,14 @@ namespace ComputerShopRestApi.Controllers
_component = component; _component = component;
} }
[HttpGet] [HttpGet]
public List<AssemblyViewModel>? GetAssemblyList() public List<AssemblyViewModel>? GetAssemblyList(int clientId)
{ {
try try
{ {
return _assembly.ReadList(null); return _assembly.ReadList(new AssemblySearchModel
{
ClientId = clientId,
});
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -57,5 +62,32 @@ namespace ComputerShopRestApi.Controllers
throw; throw;
} }
} }
[HttpPost]
public void DeleteAssembly(AssemblyBindingModel model)
{
try
{
_assembly.Delete(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления сборки");
throw;
}
}
[HttpPost]
public void AddComponentToAssembly(Tuple<AssemblySearchModel, ComponentSearchModel, int> model)
{
try
{
_assembly.AddComponentToAssembly(model.Item1, model.Item2, model.Item3);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка добавления компонента в сборку.");
throw;
}
}
} }
} }

View File

@ -3,6 +3,7 @@ using ComputerShopContracts.BindingModels;
using ComputerShopContracts.BusinessLogicContracts; using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.SearchModels; using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels; using ComputerShopContracts.ViewModels;
using System.Reflection;
namespace ComputerShopRestApi.Controllers namespace ComputerShopRestApi.Controllers
{ {
@ -18,11 +19,14 @@ namespace ComputerShopRestApi.Controllers
_component = component; _component = component;
} }
[HttpGet] [HttpGet]
public List<ComponentViewModel>? GetComponentList() public List<ComponentViewModel>? GetComponentList(int clientId)
{ {
try try
{ {
return _component.ReadList(null); return _component.ReadList(new ComponentSearchModel
{
ClientId = clientId,
});
} }
catch (Exception ex) catch (Exception ex)
{ {