Commit 042a5e29 authored by TTrueBenji's avatar TTrueBenji

Вынести кнопки в выпадающее меню.

***
- вынес кнопки действий в выпадающее меню на странице со списком смартфонов.
- добавил заготовку под миниатюру в таблице на странице со списком смартфонов.
***

#1
parent 98e48f1d
using System.Diagnostics;
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using PhoneStore.Models;
namespace PhoneStore.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IHostEnvironment _environment;
public HomeController(
ILogger<HomeController> logger,
IHostEnvironment environment)
{
_logger = logger;
_environment = environment;
}
[HttpGet]
public IActionResult Index()
{
return View();
}
[HttpGet]
public IActionResult Test()
{
string filePath = Path.Combine("~/Files/", "test.txt");
string fileType = "application/txt";
return File(filePath, fileType);
}
[HttpGet]
[ActionName("Test2")]
public string Test(Phone phone)
{
return null;
}
[HttpGet]
[ActionName("Test3")]
public string Test(Phone[] phones)
{
return "tets";
}
public IActionResult Privacy()
{
return View();
}
}
}
\ No newline at end of file
...@@ -73,7 +73,7 @@ namespace PhoneStore ...@@ -73,7 +73,7 @@ namespace PhoneStore
{ {
endpoints.MapControllerRoute( endpoints.MapControllerRoute(
name: "default", name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"); pattern: "{controller=Phones}/{action=Index}/{id?}");
}); });
} }
} }
......
...@@ -267,7 +267,7 @@ ...@@ -267,7 +267,7 @@
<h1>@Model.StatusCode</h1> <h1>@Model.StatusCode</h1>
<h2>@Model.Title</h2> <h2>@Model.Title</h2>
<p>@Model.Message</p> <p>@Model.Message</p>
<a asp-action="Index" asp-controller="Home">На главную</a> <a asp-action="Index" asp-controller="Phones">На главную</a>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
ViewBag.Title = "Смартфоны"; ViewBag.Title = "Смартфоны";
Layout = "_Layout"; Layout = "_Layout";
} }
<a asp-action="Create" asp-controller="Phones">Добавить устройство</a>
@if (Model.Count == 0) @if (Model.Count == 0)
{ {
<h2>Список пуст.</h2> <h2>Список пуст.</h2>
...@@ -14,7 +13,7 @@ else ...@@ -14,7 +13,7 @@ else
<h2>Список устройств</h2> <h2>Список устройств</h2>
<table style="width: 100%"> <table style="width: 100%">
<tr> <tr>
<th>Id</th> <th>Минитюра</th>
<th>Наименование</th> <th>Наименование</th>
<th>Компания</th> <th>Компания</th>
<th>Стоимость</th> <th>Стоимость</th>
...@@ -24,44 +23,52 @@ else ...@@ -24,44 +23,52 @@ else
@foreach (var phone in Model) @foreach (var phone in Model)
{ {
<tr> <tr>
<td>@phone.Id</td> <td><img class="phone_img" src="" alt="картинка паламатая"/></td>
<td>@phone.Name</td> <td>@phone.Name</td>
<td>@phone.Company</td> <td>@phone.Company</td>
<td>@phone.Price</td> <td>@phone.Price</td>
<td> <td>
<a asp-route-id="@phone.Id" <div class="dropdown">
asp-action="Add" <button class="btn btn-secondary dropdown-toggle"
asp-controller="Baskets" type="button"
class="btn btn-outline-warning"> id="dropdownMenu2"
В корзину data-toggle="dropdown"
</a> aria-haspopup="true"
</td> aria-expanded="false">
<td> Выполнить...
<a asp-route-phoneId="@phone.Id" </button>
asp-action="Create" <div class="dropdown-menu" aria-labelledby="dropdownMenu2">
asp-controller="Orders" <a class="dropdown-item" asp-route-id="@phone.Id"
class="btn btn-outline-warning"> asp-action="Add"
Заказать asp-controller="Baskets">
</a> В корзину
</td> </a>
<td> <a asp-route-phoneId="@phone.Id"
<a asp-route-phoneId="@phone.Id" asp-action="Create"
asp-action="Edit" asp-controller="Orders"
asp-controller="Phones" class="dropdown-item">
class="btn btn-outline-warning"> Заказать
Изменить </a>
</a> <a asp-route-phoneId="@phone.Id"
</td> asp-action="Edit"
<td> asp-controller="Phones"
<a asp-route-phoneId="@phone.Id" class="dropdown-item">
asp-action="Delete" Изменить
asp-controller="Phones" </a>
class="btn btn-danger"> <a asp-route-phoneId="@phone.Id"
Удалить asp-action="Delete"
</a> asp-controller="Phones"
</td> class="dropdown-item bg-danger">
Удалить
</a>
</div>
</div>
</tr> </tr>
} }
</table> </table>
<div class="d-flex justify-content-end my-5">
<a class="btn btn-outline-info" asp-action="Create" asp-controller="Phones">Добавить устройство</a>
</div>
} }
...@@ -11,19 +11,13 @@ ...@@ -11,19 +11,13 @@
<header> <header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container"> <div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">PhoneStore</a> <a class="navbar-brand" asp-area="" asp-controller="Phones" asp-action="Index">PhoneStore</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation"> aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between"> <div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1"> <ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Phones" asp-action="Index">Смартфоны</a> <a class="nav-link text-dark" asp-area="" asp-controller="Phones" asp-action="Index">Смартфоны</a>
</li> </li>
...@@ -43,7 +37,7 @@ ...@@ -43,7 +37,7 @@
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted">
<div class="container"> <div class="container">
&copy; 2022 - PhoneStore - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a> &copy; 2022 - PhoneStore - Created by Vitaly
</div> </div>
</footer> </footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>
......
...@@ -69,3 +69,8 @@ body { ...@@ -69,3 +69,8 @@ body {
white-space: nowrap; white-space: nowrap;
line-height: 60px; /* Vertically center the text there */ line-height: 60px; /* Vertically center the text there */
} }
.btn-secondary {
color: #fff;
background-color: #6f42c1;
border-color: #6f42c1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment