almost done, still confused bout smth
This commit is contained in:
parent
34f803c11e
commit
0f32e361e0
@ -60,23 +60,7 @@ namespace BeautyStudioRestAPI.Controllers
|
||||
logger.LogError(ex, "Ошибка получения списка процедур пользователя");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ProcedureViewModel>? GetMany(int userId, int page)
|
||||
{
|
||||
try
|
||||
{
|
||||
return procedure.ReadList(new ProcedureSearchModel {});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения списка процедур клиента id = {Id}", userId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(ProcedureBindingModel model)
|
||||
|
@ -115,7 +115,7 @@ namespace StoreKeeperWebApp.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateCosmetics(int id, string name, string brand, double price, int laborCost)
|
||||
public void UpdateCosmetics(int id, string name, double price, int laborCost)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
|
@ -0,0 +1,147 @@
|
||||
using BeautyStudioBusinessLogic.BusinessLogic;
|
||||
using BeautyStudioContracts.BindingModels;
|
||||
using BeautyStudioContracts.BusinessLogicContracts;
|
||||
using BeautyStudioContracts.SearchModels;
|
||||
using BeautyStudioContracts.ViewModels;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StoreKeeperWebApp;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
public class ProcedureController : Controller
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
|
||||
private readonly ICosmeticLogic cosmetic;
|
||||
private readonly IProcedureLogic procedure;
|
||||
private readonly IServiceLogic service;
|
||||
|
||||
public ProcedureController(ILogger<ProcedureController> logger, ICosmeticLogic cosmetic, IProcedureLogic procedure)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.cosmetic = cosmetic;
|
||||
this.procedure = procedure;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ProcedureViewModel? GetProcedure(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return procedure.ReadElement(new ProcedureSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "Ошибка получения косметики");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Procedures()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(procedure.ReadList(null));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateProcedures()
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
ViewBag.Procedures = procedure.ReadList(null);
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateProcedures(string name, double cost, string description)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || cost <= 0 || cost <= 0 || string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
procedure.Create(new ProcedureBindingModel
|
||||
{
|
||||
ProcedureName = name,
|
||||
ProcedureCost = cost,
|
||||
ProcedureDescription = description,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Evaluation/Evaluations");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult UpdateProcedures(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(cosmetic.ReadElement(new CosmeticSearchModel
|
||||
{
|
||||
Id = id
|
||||
}));
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateProcedures(int id, string name, double cost, string description)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name) || cost <= 0 || string.IsNullOrEmpty(description))
|
||||
{
|
||||
throw new Exception("Введены не все данные!");
|
||||
}
|
||||
|
||||
procedure.Update(new ProcedureBindingModel
|
||||
{
|
||||
Id = id,
|
||||
ProcedureName = name,
|
||||
ProcedureCost = cost,
|
||||
ProcedureDescription = description,
|
||||
StoreKeeperId = APIStoreKeeper.Storekeeper.Id
|
||||
});
|
||||
|
||||
Response.Redirect("/Evaluation/Evaluations");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteProcedure(int id)
|
||||
{
|
||||
if (APIStoreKeeper.Storekeeper == null)
|
||||
{
|
||||
throw new Exception("Необходимо авторизоваться!");
|
||||
}
|
||||
|
||||
procedure.Delete(new ProcedureBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
Response.Redirect("/Evaluation/Evaluations");
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
<div class="col-4">Трудозатрата:</div>
|
||||
<div class="col-8">
|
||||
<select name="laborCost" id="laborCost" class="form-control">
|
||||
@foreach (var laborCost in ViewBag.LaborCosts)
|
||||
@foreach (var laborCost in ViewBag.LaborCost)
|
||||
{
|
||||
<option value="@laborCost.Id">@laborCost.Id</option>
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание процедур";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание процедуры</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Название -->
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Цена -->
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" name="price" id="price" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Описание -->
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8"><input type="text" name="description" id="description" /></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>
|
||||
|
@ -0,0 +1,70 @@
|
||||
@using BeautyStudioContracts.ViewModels
|
||||
|
||||
@model List<ProcedureViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Процедуры";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Процедуры</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateProcedures">Создать процедуры</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Номер</th>
|
||||
<th>Название</th>
|
||||
<th>Цена</th>
|
||||
<th>Описание</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach (var procedures in Model)
|
||||
{
|
||||
<tr>
|
||||
<th>@procedures.Id</th>
|
||||
<td>@procedures.ProcedureName</td>
|
||||
<td>@procedures.ProcedureCost</td>
|
||||
<td>@procedures.ProcedureDescription</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="location.href='@Url.Action("UpdateProcedures", "/Procedure", new { id = procedures.Id })'">Изменить</button></p>
|
||||
</td>
|
||||
<td>
|
||||
<p><button type="button" class="btn btn-primary" onclick="deleteProcedure(@procedures.Id)">Удалить</button></p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section scripts {
|
||||
<script>
|
||||
function deleteProcedure(id) {
|
||||
if (confirm("Вы уверены, что хотите удалить процедуру?")) {
|
||||
$.post('@Url.Action("deleteProcedure", "/Procedure")' + '/' + id, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
@using BeautyStudioContracts.ViewModels
|
||||
|
||||
@model ProcedureViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Редактирование процедур";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Редактирование процедуры</h2>
|
||||
</div>
|
||||
|
||||
<form method="post" style="margin-top: 50px">
|
||||
<!-- Название -->
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" value="@Model.ProcedureName" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Цена -->
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" name="price" value="@Model.ProcedureCost" /></div>
|
||||
</div>
|
||||
|
||||
<!-- Длительность -->
|
||||
<div class="row">
|
||||
<div class="col-4">Длительность:</div>
|
||||
<div class="col-8"><input type="text" name="Duration" value="@Model.ProcedureDescription" /></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>
|
Loading…
Reference in New Issue
Block a user