начало работы с веб
This commit is contained in:
parent
191fd514aa
commit
6073dbda35
@ -25,7 +25,7 @@ namespace CarServiceBusinessLogic.BusinessLogics
|
||||
public List<ReportWorksWithPaymentsViewModel> GetPayments(ReportBindingModel model)
|
||||
{
|
||||
_logger.LogInformation("Reading payments by works in requests");
|
||||
return _workPaymentStorage.GetPaymentsByWorks(new() {DateFrom = model.DateFrom, DateTo = model.DateTo });
|
||||
return _workPaymentStorage.GetPaymentsByWorks(new() { DateFrom = model.DateFrom, DateTo = model.DateTo });
|
||||
}
|
||||
public void SaveComponentsToWordFile(ReportBindingModel model)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ namespace CarServiceDatabase.Implements
|
||||
{
|
||||
using var context = new CarServiceDbContext();
|
||||
return context.Works
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Where(x => x.WorkerId == model.Id)
|
||||
.Include(x => x.Worker)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
@ -6,4 +6,15 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="log4net" Version="2.0.15" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CarServiceBusinessLogic\CarServiceBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\CarServiceContracts\CarServiceContracts.csproj" />
|
||||
<ProjectReference Include="..\CarServiceDatabase\CarServiceDatabase.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,4 +1,6 @@
|
||||
using CarServiceWebApp.Models;
|
||||
using CarServiceBusinessLogic.BusinessLogics;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceWebApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
|
||||
@ -7,22 +9,34 @@ namespace CarServiceWebApp.Controllers
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IWorkLogic _workLogic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
public HomeController(ILogger<HomeController> logger, IWorkLogic workLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_workLogic = workLogic;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (CurrentUser.UserId < 1)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Works()
|
||||
{
|
||||
ViewBag.Works = _workLogic.ReadList(new() { Id = 1 });
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
|
7
CarService/CarServiceWebApp/Models/CurrentUser.cs
Normal file
7
CarService/CarServiceWebApp/Models/CurrentUser.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace CarServiceWebApp.Models
|
||||
{
|
||||
public static class CurrentUser
|
||||
{
|
||||
public static int UserId = 0;
|
||||
}
|
||||
}
|
@ -1,7 +1,16 @@
|
||||
using CarServiceBusinessLogic.BusinessLogics;
|
||||
using CarServiceContracts.BusinessLogicsContracts;
|
||||
using CarServiceContracts.StorageContracts;
|
||||
using CarServiceDatabase.Implements;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||
builder.Logging.AddLog4Net("log4net.config");
|
||||
builder.Services.AddControllersWithViews();
|
||||
builder.Services.AddTransient<IWorkLogic, WorkLogic>();
|
||||
builder.Services.AddTransient<IWorkStorage, WorkStorage>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
26
CarService/CarServiceWebApp/Views/Home/Works.cshtml
Normal file
26
CarService/CarServiceWebApp/Views/Home/Works.cshtml
Normal file
@ -0,0 +1,26 @@
|
||||
@{
|
||||
ViewData["Title"] = "Работы";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Работы</h1>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
<th>Цена (в рублях)</th>
|
||||
<th>Длительность (в часах)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var work in ViewBag.Works)
|
||||
{
|
||||
<tr>
|
||||
<td>@work.Name</td>
|
||||
<td>@work.Price</td>
|
||||
<td>@work.Duration</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
@ -20,7 +20,7 @@
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<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">Работы</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Works">Работы</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Заявки</a>
|
||||
|
16
CarService/CarServiceWebApp/log4net.config
Normal file
16
CarService/CarServiceWebApp/log4net.config
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<log4net>
|
||||
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
||||
<file value="c:/BlacksmithWorkshopRestApi.log"/>
|
||||
<appendToFile value="true"/>
|
||||
<maximumFileSize value="100KB"/>
|
||||
<maxSizeRollBackups value="2"/>
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="%date %5level %logger.%method [%line] - MESSAGE: %message%newline %exception"/>
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="TRACE"/>
|
||||
<appender-ref ref="RollingFile"/>
|
||||
</root>
|
||||
</log4net>
|
Loading…
Reference in New Issue
Block a user