diff --git a/CarService/CarServiceBusinessLogic/BusinessLogics/ReportLogic.cs b/CarService/CarServiceBusinessLogic/BusinessLogics/ReportLogic.cs index 58fe03f..ea1c933 100644 --- a/CarService/CarServiceBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/CarService/CarServiceBusinessLogic/BusinessLogics/ReportLogic.cs @@ -25,7 +25,7 @@ namespace CarServiceBusinessLogic.BusinessLogics public List 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) { diff --git a/CarService/CarServiceDatabase/Implements/WorkStorage.cs b/CarService/CarServiceDatabase/Implements/WorkStorage.cs index 96a9d09..ae460cf 100644 --- a/CarService/CarServiceDatabase/Implements/WorkStorage.cs +++ b/CarService/CarServiceDatabase/Implements/WorkStorage.cs @@ -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(); diff --git a/CarService/CarServiceWebApp/CarServiceWebApp.csproj b/CarService/CarServiceWebApp/CarServiceWebApp.csproj index c78c9c7..b6cf70f 100644 --- a/CarService/CarServiceWebApp/CarServiceWebApp.csproj +++ b/CarService/CarServiceWebApp/CarServiceWebApp.csproj @@ -6,4 +6,15 @@ enable + + + + + + + + + + + diff --git a/CarService/CarServiceWebApp/Controllers/HomeController.cs b/CarService/CarServiceWebApp/Controllers/HomeController.cs index 0f78e44..6e70cb8 100644 --- a/CarService/CarServiceWebApp/Controllers/HomeController.cs +++ b/CarService/CarServiceWebApp/Controllers/HomeController.cs @@ -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 _logger; + private readonly IWorkLogic _workLogic; - public HomeController(ILogger logger) + public HomeController(ILogger 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() { diff --git a/CarService/CarServiceWebApp/Models/CurrentUser.cs b/CarService/CarServiceWebApp/Models/CurrentUser.cs new file mode 100644 index 0000000..8e2bec8 --- /dev/null +++ b/CarService/CarServiceWebApp/Models/CurrentUser.cs @@ -0,0 +1,7 @@ +namespace CarServiceWebApp.Models +{ + public static class CurrentUser + { + public static int UserId = 0; + } +} \ No newline at end of file diff --git a/CarService/CarServiceWebApp/Program.cs b/CarService/CarServiceWebApp/Program.cs index 559dd3a..05a02e7 100644 --- a/CarService/CarServiceWebApp/Program.cs +++ b/CarService/CarServiceWebApp/Program.cs @@ -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(); +builder.Services.AddTransient(); var app = builder.Build(); diff --git a/CarService/CarServiceWebApp/Views/Home/Privacy.cshtml b/CarService/CarServiceWebApp/Views/Home/Privacy.cshtml deleted file mode 100644 index af4fb19..0000000 --- a/CarService/CarServiceWebApp/Views/Home/Privacy.cshtml +++ /dev/null @@ -1,6 +0,0 @@ -@{ - ViewData["Title"] = "Privacy Policy"; -} -

@ViewData["Title"]

- -

Use this page to detail your site's privacy policy.

diff --git a/CarService/CarServiceWebApp/Views/Home/Works.cshtml b/CarService/CarServiceWebApp/Views/Home/Works.cshtml new file mode 100644 index 0000000..be1ff42 --- /dev/null +++ b/CarService/CarServiceWebApp/Views/Home/Works.cshtml @@ -0,0 +1,26 @@ +@{ + ViewData["Title"] = "Работы"; +} + +
+

Работы

+ + + + + + + + + + @foreach (var work in ViewBag.Works) + { + + + + + + } + +
НазваниеЦена (в рублях)Длительность (в часах)
@work.Name@work.Price@work.Duration
+
\ No newline at end of file diff --git a/CarService/CarServiceWebApp/Views/Shared/_Layout.cshtml b/CarService/CarServiceWebApp/Views/Shared/_Layout.cshtml index a3242a5..97e4673 100644 --- a/CarService/CarServiceWebApp/Views/Shared/_Layout.cshtml +++ b/CarService/CarServiceWebApp/Views/Shared/_Layout.cshtml @@ -20,7 +20,7 @@