Delete method for component
This commit is contained in:
parent
63f4dbe428
commit
7487437504
@ -179,6 +179,26 @@ namespace ComputerShopClientApp.Controllers
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult DeleteComponent()
|
||||
{
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentlist");
|
||||
return View();
|
||||
}
|
||||
[HttpDelete]
|
||||
public void DeleteComponent(int component)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
APIClient.PostRequest("api/component/deletecomponent", new ComponentBindingModel
|
||||
{
|
||||
Id = component
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateAssembly()
|
||||
{
|
||||
|
@ -22,6 +22,9 @@
|
||||
<p>
|
||||
<a asp-action="CreateComponent">Создать комплектующее</a>
|
||||
</p>
|
||||
<p>
|
||||
<a asp-action="DeleteComponent">Удалить комплектующее</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -0,0 +1,18 @@
|
||||
@{
|
||||
ViewData["Title"] = "DeleteComponent";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление компонента</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Компонент:</div>
|
||||
<div class="col-8">
|
||||
<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-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Удалить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -43,5 +43,18 @@ namespace ComputerShopRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpDelete]
|
||||
public void DeleteComponent(ComponentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_component.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user