added selecting records by user and partially implemented crud for the site
This commit is contained in:
parent
d4e4e44d4c
commit
40c8117b7f
@ -131,7 +131,7 @@ namespace CanteenBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
_logger.LogInformation("Manager. Login: {Login}. Password: {Password}. PhoneNumber: {PhoneNumber}. Id: {Id}", model.Login, model.Password, model.PhoneNumber, model.Id);
|
_logger.LogInformation("Manager. Login: {Login}. Password: {Password}. PhoneNumber: {PhoneNumber}. Id: {Id}", model.Login, model.Password, model.PhoneNumber, model.Id);
|
||||||
|
|
||||||
var element = _managerStorage.GetElement(new ManagerSearchModel { Login = model.Login , Password = model.Password});
|
var element = _managerStorage.GetElement(new ManagerSearchModel { Login = model.Login, PhoneNumber = model.PhoneNumber });
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Такой менеджер уже есть");
|
throw new InvalidOperationException("Такой менеджер уже есть");
|
||||||
|
@ -10,5 +10,6 @@ namespace CanteenContracts.SearchModel
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? FIO { get; set; }
|
public string? FIO { get; set; }
|
||||||
|
public int? ManagerId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
|
|||||||
public class DishSearchModel
|
public class DishSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public int? ManagerId { get; set; }
|
||||||
public string? DishName { get; set; }
|
public string? DishName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
|
|||||||
public class ProductSearchModel
|
public class ProductSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public int? ManagerId { get; set; }
|
||||||
public string? ProductName { get; set; }
|
public string? ProductName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
|
|||||||
public class TablewareSearchModel
|
public class TablewareSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public int? VisitorId { get; set; }
|
||||||
public string? TablewareName { get; set; }
|
public string? TablewareName { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace CanteenDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-A68O3K0;Initial Catalog=CanteenDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-PA5STI0\SQLEXPRESS;Initial Catalog=CanteenDataBase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using CanteenContracts.StoragesContracts;
|
|||||||
using CanteenContracts.View;
|
using CanteenContracts.View;
|
||||||
using CanteenDatabaseImplement.Models;
|
using CanteenDatabaseImplement.Models;
|
||||||
using CanteenDataModels.Models;
|
using CanteenDataModels.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
@ -32,7 +33,8 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
using var context = new CanteenDatabase();
|
using var context = new CanteenDatabase();
|
||||||
|
|
||||||
return context.Cooks
|
return context.Cooks
|
||||||
.Where(x => !model.Id.HasValue || x.Id == model.Id)
|
.Include(x => x.Manager)
|
||||||
|
.Where(x => (model.Id.HasValue && x.Id == model.Id) || (model.ManagerId.HasValue && model.ManagerId == x.ManagerId))
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
return context.Dishes
|
return context.Dishes
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.Product)
|
.ThenInclude(x => x.Product)
|
||||||
.Where(x => x.DishName == model.DishName).Select(x => x.GetViewModel).ToList();
|
.Where(x => x.DishName == model.DishName || (model.ManagerId.HasValue && model.ManagerId == x.ManagerId)).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DishViewModel> GetFullList()
|
public List<DishViewModel> GetFullList()
|
||||||
|
@ -54,7 +54,10 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
return context.Lunches
|
return context.Lunches
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.Product)
|
.ThenInclude(x => x.Product)
|
||||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateImplement <= model.DateTo)
|
.Where(x =>
|
||||||
|
(x.DateCreate >= model.DateFrom && x.DateImplement <= model.DateTo) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id) ||
|
||||||
|
(model.VisitorId.HasValue && model.VisitorId == x.VisitorId))
|
||||||
.Select(x => x.GetViewModel).ToList();
|
.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
using var context = new CanteenDatabase();
|
using var context = new CanteenDatabase();
|
||||||
|
|
||||||
return context.Managers.FirstOrDefault(x =>
|
return context.Managers.FirstOrDefault(x =>
|
||||||
(!string.IsNullOrEmpty(model.Login) && x.Login == model.Login) || (!string.IsNullOrEmpty(model.Password) && x.Login == model.Password) ||
|
((!string.IsNullOrEmpty(model.Login) && x.Login == model.Login) && (!string.IsNullOrEmpty(model.Password) && x.Password == model.Password)) ||
|
||||||
(model.Id.HasValue && x.Id == model.Id)
|
(model.Id.HasValue && x.Id == model.Id)
|
||||||
)?.GetViewModel;
|
)?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Cooks)
|
.Include(x => x.Cooks)
|
||||||
.ThenInclude(x => x.Cook)
|
.ThenInclude(x => x.Cook)
|
||||||
.Where(x => model.VisitorId.HasValue && (model.VisitorId == x.VisitorId)).Select(x => x.GetViewModel).ToList();
|
.Where(x => (model.Id.HasValue && x.Id == model.Id) || (model.VisitorId.HasValue && model.VisitorId == x.VisitorId)).Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
|
@ -53,7 +53,11 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
|
|
||||||
using var context = new CanteenDatabase();
|
using var context = new CanteenDatabase();
|
||||||
|
|
||||||
return context.Products.Include(x => x.Cooks).ThenInclude(x => x.Cook).Where(x => x.ProductName.Contains(model.ProductName)).Select(x => x.GetViewModel).ToList();
|
return context.Products
|
||||||
|
.Include(x => x.Cooks)
|
||||||
|
.ThenInclude(x => x.Cook)
|
||||||
|
.Where(x => (model.Id.HasValue && x.Id == model.Id) || (model.ManagerId.HasValue && model.ManagerId == x.ManagerId))
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProductViewModel> GetFullList()
|
public List<ProductViewModel> GetFullList()
|
||||||
|
@ -34,7 +34,7 @@ namespace CanteenDatabaseImplement.Implements
|
|||||||
using var context = new CanteenDatabase();
|
using var context = new CanteenDatabase();
|
||||||
|
|
||||||
return context.Tablewares
|
return context.Tablewares
|
||||||
.Where(x => x.TablewareName.Contains(model.TablewareName))
|
.Where(x => (model.Id.HasValue && x.Id == model.Id) || (model.VisitorId.HasValue && model.VisitorId == x.VisitorId))
|
||||||
.Select(x => x.GetViewModel).ToList();
|
.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<Optimize>True</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.13" />
|
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.13" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using CanteenContracts.View;
|
using CanteenContracts.BindingModels;
|
||||||
|
using CanteenContracts.View;
|
||||||
using CanteenManagerApp.Models;
|
using CanteenManagerApp.Models;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -17,13 +18,21 @@ namespace CanteenManagerApp.Controllers
|
|||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Cooks()
|
public IActionResult Cooks()
|
||||||
{
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
ViewBag.Cooks = APIClient.GetRequest<List<CookViewModel>>("api/main/getcooklist");
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
ViewBag.Cooks = APIClient.GetRequest<List<CookViewModel>>($"api/main/getcooklist?managerId={APIClient.Manager.Id}");
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,12 +53,39 @@ namespace CanteenManagerApp.Controllers
|
|||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateCook()
|
public IActionResult CreateCook()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateCook(string FIO, string position)
|
||||||
|
{
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Доступ возможен только авторизованным пользователям");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(FIO))
|
||||||
|
{
|
||||||
|
throw new Exception("ФИО не должно быть пустым");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest("api/main/createcook", new CookBindingModel
|
||||||
|
{
|
||||||
|
ManagerId = APIClient.Manager.Id,
|
||||||
|
FIO = FIO,
|
||||||
|
Position = position
|
||||||
|
});
|
||||||
|
|
||||||
|
Response.Redirect("Cooks");
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult DeleteCook(int CookId)
|
||||||
|
{
|
||||||
|
APIClient.PostRequest("api/main/deletecook", new CookBindingModel { Id = CookId }); ;
|
||||||
|
return Redirect("~/Home/Cooks");
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult CreateProduct()
|
public IActionResult CreateProduct()
|
||||||
@ -64,6 +100,56 @@ namespace CanteenManagerApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Enter()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void Enter(string login, string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
throw new Exception("Введите логин и пароль");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.Manager = APIClient.GetRequest<ManagerViewModel>($"api/manager/login?login={login}&password={password}");
|
||||||
|
if (APIClient.Manager == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Неверный логин/пароль");
|
||||||
|
}
|
||||||
|
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Register()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Register(string login, string password, string fio, string phoneNumber)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio))
|
||||||
|
{
|
||||||
|
throw new Exception("Введите логин, пароль и ФИО");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest("api/manager/register", new ManagerBindingModel
|
||||||
|
{
|
||||||
|
FIO = fio,
|
||||||
|
Login = login,
|
||||||
|
Password = password,
|
||||||
|
PhoneNumber = phoneNumber
|
||||||
|
});
|
||||||
|
|
||||||
|
Response.Redirect("Enter");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public IActionResult Error()
|
public IActionResult Error()
|
||||||
{
|
{
|
||||||
|
@ -4,31 +4,56 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Список поваров</h2>
|
<h2>Список поваров</h2>
|
||||||
<button type="button" class="btn btn-info" onclick="location.href='@Url.Action("CreateCook", "Home")'">Добавить повара</button>
|
<a type="button" class="btn btn-success" href="/Home/CreateCook">Добавить повара</a>
|
||||||
<button type="button" class="btn btn-danger" onclick="location.href='@Url.Action("CreateCook", "Home")'">Удалить повара</button>
|
<button type="submit" class="btn btn-danger" form="selectCookForm">Удалить повара</button>
|
||||||
<button type="button" class="btn btn-warning" onclick="location.href='@Url.Action("CreateCook", "Home")'">Обновить повара</button>
|
<a type="button" class="btn btn-warning" href="/Home/UpdateCook">Обновить повара</a>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Выбрать</th>
|
|
||||||
<th>Номер</th>
|
<th>Номер</th>
|
||||||
<th>ФИО</th>
|
<th>ФИО</th>
|
||||||
<th>Должность</th>
|
<th>Должность</th>
|
||||||
<th>Менеджер</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var cook in ViewBag.Cooks)
|
@foreach (var cook in ViewBag.Cooks)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr onclick="selectCook(this)">
|
||||||
<td><input type="radio" name="selectedProducts" value="@cook.Id" /></td>
|
<td>@cook.Id</td>
|
||||||
<td>@cook.Id</td>
|
<td>@cook.FIO</td>
|
||||||
<td>@cook.FIO</td>
|
<td>@cook.Position</td>
|
||||||
<td>@cook.Position</td>
|
</tr>
|
||||||
<td>@cook.ManagerId</td>
|
|
||||||
</tr>
|
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<form id="selectCookForm" method="post" action="/Home/DeleteCook">
|
||||||
|
<input type="hidden" id="CookId" name="CookId" value="" />
|
||||||
|
</form>
|
||||||
|
<style>
|
||||||
|
.selected-row {
|
||||||
|
background-color: lightgray;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
function selectCook(row) {
|
||||||
|
var CookId = document.getElementById("CookId");
|
||||||
|
var previousValue = CookId.value;
|
||||||
|
var currentValue = row.cells[0].innerText;
|
||||||
|
|
||||||
|
if (previousValue === currentValue) {
|
||||||
|
CookId.value = "";
|
||||||
|
row.classList.remove("selected-row");
|
||||||
|
} else {
|
||||||
|
CookId.value = currentValue;
|
||||||
|
|
||||||
|
var rows = document.getElementsByTagName("tr");
|
||||||
|
for (var i = 0; i < rows.length; i++) {
|
||||||
|
rows[i].classList.remove("selected-row");
|
||||||
|
}
|
||||||
|
|
||||||
|
row.classList.add("selected-row");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -15,7 +15,6 @@
|
|||||||
<div class="col-4">ФИО:</div>
|
<div class="col-4">ФИО:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<input type="text" name="FIO" id="FIO" />
|
<input type="text" name="FIO" id="FIO" />
|
||||||
@* <select id="bouquet" name="bouquet" class="form-control" asp-items="@(new SelectList(@ViewBag.Bouquets, "Id", "BouquetName"))"></select>*@
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
25
Canteen/CanteenManagerApp/Views/Home/DeleteCook.cshtml
Normal file
25
Canteen/CanteenManagerApp/Views/Home/DeleteCook.cshtml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "DeleteCook";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Удаление повара</h2>
|
||||||
|
</div>
|
||||||
|
<style>
|
||||||
|
.row {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Выберите повара</div>
|
||||||
|
<div class="col-8">
|
||||||
|
<select id="cook" name="cook" class="form-control" asp-items="@(new SelectList(@ViewBag.Cooks, "Id"))"></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>
|
20
Canteen/CanteenManagerApp/Views/Home/Enter.cshtml
Normal file
20
Canteen/CanteenManagerApp/Views/Home/Enter.cshtml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Enter";
|
||||||
|
}
|
||||||
|
<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"><input type="text" name="login" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Пароль:</div>
|
||||||
|
<div class="col-8"><input type="password" name="password" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8"></div>
|
||||||
|
<div class="col-4"><input type="submit" value="Вход" class="btn btnprimary" /></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@ -1,6 +1,24 @@
|
|||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Privacy Policy";
|
ViewData["Title"] = "Privacy Policy";
|
||||||
}
|
}
|
||||||
<h1>@ViewData["Title"]</h1>
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Личные данные</h2>
|
||||||
<p>Use this page to detail your site's privacy policy.</p>
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Логин:</div>
|
||||||
|
<div class="col-8"><input type="text" name="login" value="@Model.Login" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Пароль:</div>
|
||||||
|
<div class="col-8"><input type="password" name="password" value="@Model.Password" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">ФИО:</div>
|
||||||
|
<div class="col-8"><input type="text" name="fio" value="@Model.ClientFIO" /></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>
|
||||||
|
29
Canteen/CanteenManagerApp/Views/Home/Register.cshtml
Normal file
29
Canteen/CanteenManagerApp/Views/Home/Register.cshtml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Register";
|
||||||
|
}
|
||||||
|
<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"><input type="text" name="login" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Пароль:</div>
|
||||||
|
<div class="col-8"><input type="password" name="password" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">ФИО:</div><div class="col-8"><input type="text" name="fio" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">Номер телефона:</div>
|
||||||
|
<div class="col-8"><input type="text" name="phoneNumber" /></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>
|
5
Canteen/CanteenManagerApp/Views/Home/UpdateCook.cshtml
Normal file
5
Canteen/CanteenManagerApp/Views/Home/UpdateCook.cshtml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
@*
|
||||||
|
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
|
*@
|
||||||
|
@{
|
||||||
|
}
|
@ -12,7 +12,7 @@
|
|||||||
<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-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">ManagerApp</a>
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Enter">ManagerApp</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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>
|
||||||
@ -28,6 +28,12 @@
|
|||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Dishes">Блюда</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Dishes">Блюда</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Войти</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<Optimize>True</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore" Version="6.1.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using CanteenContracts.BindingModels;
|
using CanteenContracts.BindingModels;
|
||||||
using CanteenContracts.BusinessLogicsContracts;
|
using CanteenContracts.BusinessLogicsContracts;
|
||||||
|
using CanteenContracts.SearchModel;
|
||||||
using CanteenContracts.View;
|
using CanteenContracts.View;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@ -25,11 +26,11 @@ namespace CanteenRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public List<CookViewModel>? GetCookList()
|
public List<CookViewModel>? GetCookList(int managerId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return _cook.ReadList(null);
|
return _cook.ReadList(new CookSearchModel { ManagerId = managerId});
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -63,5 +64,57 @@ namespace CanteenRestApi.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateCook(CookBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_cook.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void DeleteCook(CookBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_cook.Delete(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateDish(DishBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_dish.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateProduct(ProductBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_product.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading list of bouquets");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
68
Canteen/CanteenRestApi/Controllers/ManagerController.cs
Normal file
68
Canteen/CanteenRestApi/Controllers/ManagerController.cs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
using CanteenContracts.BindingModels;
|
||||||
|
using CanteenContracts.BusinessLogicsContracts;
|
||||||
|
using CanteenContracts.SearchModel;
|
||||||
|
using CanteenContracts.View;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace CanteenRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ManagerController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IManagerLogic _logic;
|
||||||
|
|
||||||
|
public ManagerController(IManagerLogic logic, ILogger<ManagerController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public ManagerViewModel? Login(string login, string password)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _logic.ReadElement(new ManagerSearchModel
|
||||||
|
{
|
||||||
|
Login = login,
|
||||||
|
Password = password
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during logging in");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Register(ManagerBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during registration");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateData(ManagerBindingModel model)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during updating");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
@ -6,6 +6,10 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
|
<Optimize>True</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user