вывод списка заявок
This commit is contained in:
parent
fc12c07f70
commit
f0b5b4a6b7
@ -10,5 +10,9 @@ namespace CarServiceContracts.ViewModels
|
|||||||
[DisplayName("Дата создания")]
|
[DisplayName("Дата создания")]
|
||||||
public DateTime DateCreated { get; set; } = DateTime.Now;
|
public DateTime DateCreated { get; set; } = DateTime.Now;
|
||||||
public int VehicleId { get; set; }
|
public int VehicleId { get; set; }
|
||||||
|
public string VehicleName { get; set; } = string.Empty;
|
||||||
|
public string VehiclePlate { get; set; } = string.Empty;
|
||||||
|
public string VehicleVIN { get; set; } = string.Empty;
|
||||||
|
public string CustomerName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,8 @@ namespace CarServiceDatabase.Implements
|
|||||||
{
|
{
|
||||||
using var context = new CarServiceDbContext();
|
using var context = new CarServiceDbContext();
|
||||||
return context.RepairRequests
|
return context.RepairRequests
|
||||||
|
.Include(x => x.Vehicle)
|
||||||
|
.ThenInclude(x => x.Customer)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,11 @@ namespace CarServiceDatabase.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
DateCreated = DateCreated,
|
DateCreated = DateCreated,
|
||||||
VehicleId = VehicleId
|
VehicleId = VehicleId,
|
||||||
|
VehicleName = Vehicle.Name,
|
||||||
|
VehiclePlate = Vehicle.Plate,
|
||||||
|
VehicleVIN = Vehicle.VIN ?? "Отсутствует",
|
||||||
|
CustomerName = Vehicle.Customer.Name + " " + Vehicle.Customer.Surname
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,15 @@ namespace CarServiceWebApp.Controllers
|
|||||||
private readonly IWorkLogic _workLogic;
|
private readonly IWorkLogic _workLogic;
|
||||||
private readonly IWorkerLogic _workerLogic;
|
private readonly IWorkerLogic _workerLogic;
|
||||||
private readonly IItemLogic _itemLogic;
|
private readonly IItemLogic _itemLogic;
|
||||||
|
private readonly IRepairRequestLogic _repairRequestLogic;
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger, IWorkLogic workLogic, IWorkerLogic workerLogic, IItemLogic itemLogic)
|
public HomeController(ILogger<HomeController> logger, IWorkLogic workLogic, IWorkerLogic workerLogic, IItemLogic itemLogic, IRepairRequestLogic repairRequestLogic)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_workLogic = workLogic;
|
_workLogic = workLogic;
|
||||||
_workerLogic = workerLogic;
|
_workerLogic = workerLogic;
|
||||||
_itemLogic = itemLogic;
|
_itemLogic = itemLogic;
|
||||||
|
_repairRequestLogic = repairRequestLogic;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Главная страница
|
/// Главная страница
|
||||||
@ -247,6 +249,21 @@ namespace CarServiceWebApp.Controllers
|
|||||||
}
|
}
|
||||||
return Redirect("~/Home/Items");
|
return Redirect("~/Home/Items");
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult RepairRequests()
|
||||||
|
{
|
||||||
|
if (CurrentUser.UserId < 1)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Index");
|
||||||
|
}
|
||||||
|
var RepairRequests = _repairRequestLogic.ReadList(null);
|
||||||
|
ViewBag.RepairRequests = RepairRequests;
|
||||||
|
if (RepairRequests?.Count == 0)
|
||||||
|
{
|
||||||
|
ViewBag.Exception = "Пока нет заявок";
|
||||||
|
}
|
||||||
|
return View();
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод ошибок
|
/// Вывод ошибок
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -15,6 +15,8 @@ builder.Services.AddTransient<IWorkerLogic, WorkerLogic>();
|
|||||||
builder.Services.AddTransient<IWorkerStorage, WorkerStorage>();
|
builder.Services.AddTransient<IWorkerStorage, WorkerStorage>();
|
||||||
builder.Services.AddTransient<IItemLogic, ItemLogic>();
|
builder.Services.AddTransient<IItemLogic, ItemLogic>();
|
||||||
builder.Services.AddTransient<IItemStorage, ItemStorage>();
|
builder.Services.AddTransient<IItemStorage, ItemStorage>();
|
||||||
|
builder.Services.AddTransient<IRepairRequestLogic, RepairRequestLogic>();
|
||||||
|
builder.Services.AddTransient<IRepairRequestStorage, RepairRequestStorage>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
|
36
CarService/CarServiceWebApp/Views/Home/RepairRequests.cshtml
Normal file
36
CarService/CarServiceWebApp/Views/Home/RepairRequests.cshtml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Заявки на ремонт";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Заявки</h1>
|
||||||
|
@if (ViewBag.RepairRequests.Count != 0)
|
||||||
|
{
|
||||||
|
<center>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Дата создания</th>
|
||||||
|
<th>Транспортное средство</th>
|
||||||
|
<th>VIN-номер</th>
|
||||||
|
<th>Гос. номер</th>
|
||||||
|
<th>Клиент</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var request in ViewBag.RepairRequests)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@request.DateCreated</td>
|
||||||
|
<td>@request.VehicleName</td>
|
||||||
|
<td>@request.VehicleVIN</td>
|
||||||
|
<td>@request.VehiclePlate</td>
|
||||||
|
<td>@request.CustomerName</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</center>
|
||||||
|
}
|
||||||
|
<div>@ViewBag.Exception</div>
|
||||||
|
</div>
|
@ -23,7 +23,7 @@
|
|||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Works">Работы</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Works">Работы</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Заявки</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="RepairRequests">Заявки</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Items">Запчасти</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Items">Запчасти</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user