Merge pull request 'сделал' (#19) from again into main
Reviewed-on: #19
This commit is contained in:
commit
e589c9f37c
@ -17,5 +17,6 @@ namespace CarCenterContracts.BindingModels
|
||||
public double Price { get; set; }
|
||||
public int StorekeeperId { get; set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public Dictionary<int, IPresaleModel> BundlingsPresale { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -23,5 +23,6 @@ namespace CarCenterContracts.ViewModels
|
||||
public double Price { get; set; }
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; }
|
||||
public Dictionary<int, IPresaleModel> BundlingsPresale { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(CarCenterDatabase))]
|
||||
[Migration("20240529143434_preFin")]
|
||||
partial class preFin
|
||||
[Migration("20240529170508_predFin2")]
|
||||
partial class predFin2
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
@ -6,7 +6,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
namespace CarCenterDatabaseImplement.Migrations
|
||||
{
|
||||
public partial class preFin : Migration
|
||||
public partial class predFin2 : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
@ -7,6 +7,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using CarCenterDataModels.Enums;
|
||||
using CarCenterDatabaseImplement.Models;
|
||||
|
||||
namespace CarCenterStorekeeperApp.Controllers
|
||||
{
|
||||
@ -93,6 +94,8 @@ namespace CarCenterStorekeeperApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult CreateBundling(int id)
|
||||
{
|
||||
var presales = _data.GetPresales();
|
||||
ViewBag.AllPresales = presales;
|
||||
if (id != 0)
|
||||
{
|
||||
var value = _data.GetBundling(id);
|
||||
@ -102,18 +105,28 @@ namespace CarCenterStorekeeperApp.Controllers
|
||||
return View(new BundlingViewModel());
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CreateBundling(BundlingBindingModel model)
|
||||
public IActionResult CreateBundling(BundlingBindingModel model, int[] presaleIds)
|
||||
{
|
||||
|
||||
if (model.Id == 0)
|
||||
var presales = _data.GetPresales();
|
||||
if (model.Id == 0)
|
||||
{
|
||||
model.DateCreate = DateTime.Now;
|
||||
model.StorekeeperId = UserStorekeeper.user!.Id;
|
||||
if (_data.CreateBundling(model))
|
||||
for (int i = 0; i < presaleIds.Length; i++)
|
||||
{
|
||||
var presale = presales!.FirstOrDefault(x => x.Id == presaleIds[i])!;
|
||||
model.BundlingsPresale.Add(i, presale);
|
||||
}
|
||||
if (_data.CreateBundling(model))
|
||||
return RedirectToAction("IndexBundling");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < presaleIds.Length; i++)
|
||||
{
|
||||
var presale = presales!.FirstOrDefault(x => x.Id == presaleIds[i])!;
|
||||
model.BundlingsPresale.Add(i, presale);
|
||||
}
|
||||
model.StorekeeperId = UserStorekeeper.user!.Id;
|
||||
if (_data.UpdateBundling(model))
|
||||
return RedirectToAction("IndexBundling");
|
||||
|
@ -2,6 +2,7 @@
|
||||
@using CarCenterDataModels.Enums;
|
||||
@{
|
||||
ViewData["Title"] = "CreateBundling";
|
||||
ViewBag.Presales = Model.BundlingsPresale;
|
||||
}
|
||||
@model BundlingViewModel;
|
||||
<div class="text-center">
|
||||
@ -45,6 +46,43 @@
|
||||
<span id="ToolKiteError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
@if (ViewBag.AllPresales != null && ViewBag.AllPresales.Count != 0)
|
||||
{
|
||||
<div class="container">
|
||||
<div>Комлектации</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="presalesTable" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID комплектации</th>
|
||||
<th> </th>
|
||||
<th>Удалить</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var presale in ViewBag.Presales)
|
||||
{
|
||||
<tr data-presale-id="@presale.Value.Id">
|
||||
<td>
|
||||
<input type="hidden" name="presaleIds" value="@presale.Value.Id" />@presale.Value.Id
|
||||
</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deletePresale" data-presale-id="@presale.Value.Id">Удалить</button></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<select id="presaleSelect" class="form-control">
|
||||
<option value="">Выберите предпродажную работу</option>
|
||||
@foreach (var presale in ViewBag.AllPresales)
|
||||
{
|
||||
<option value="@presale.Id" data-price="@presale.Price">Предпродажная работа @presale.Id</option>
|
||||
}
|
||||
</select>
|
||||
<button type="button" id="addPresale" class="btn btn-secondary">Добавить предпродажную работу</button>
|
||||
</div>
|
||||
}
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8">
|
||||
@ -61,6 +99,49 @@
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('#addPresale').click(function () {
|
||||
var selectedPresale = $('#presaleSelect option:selected');
|
||||
if (selectedPresale.val()) {
|
||||
var presaleId = selectedPresale.val();
|
||||
var exists = false;
|
||||
$('#presalesTable tbody tr').each(function () {
|
||||
if ($(this).data('presale-id') == presaleId) {
|
||||
exists = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (exists) {
|
||||
alert('Эта комплектация уже добавлена.');
|
||||
return;
|
||||
}
|
||||
|
||||
var presaleName = selectedPresale.text();
|
||||
|
||||
var newRow = `
|
||||
<tr data-presale-id="${presaleId}">
|
||||
<td>
|
||||
<input type="hidden" name="presaleIds" value="${presaleId}" />
|
||||
${presaleId}
|
||||
</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deletePresale" data-presale-id="${presaleId}">Удалить</button></td>
|
||||
</tr>
|
||||
`;
|
||||
$('#presalesTable tbody').append(newRow);
|
||||
|
||||
$('.deletePresale').off('click').on('click', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
|
||||
$('#presaleSelect').val('');
|
||||
|
||||
updateSum();
|
||||
} else {
|
||||
alert('Выберите комплектацию для добавления');
|
||||
}
|
||||
});
|
||||
$('#bundlinglForm').submit(function (event) {
|
||||
var EquipmentPackage = $('#EquipmentPackage').val();
|
||||
var TirePackage = $('#TirePackage').val();
|
||||
|
@ -3,7 +3,7 @@
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Вход в приложение</h2>
|
||||
<h2 class="display-4">Вход в приложение Кладовщика</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
|
@ -3,7 +3,8 @@
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Главное меню</h1>
|
||||
<h2 class="display-4">Главное меню</h2>
|
||||
<h1>Добро пожаловать на страницу Кладовщика</h1>
|
||||
<div class="list-group">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexBundling">Комплектации</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexFeature">Особенности</a>
|
||||
|
@ -3,6 +3,8 @@
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2>Добро пожаловать на сайт Кладовщика</h2>
|
||||
<h2>Войдите или зарегистрируйтесь</h2>
|
||||
<div class="list-group">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
|
@ -2,7 +2,7 @@
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Личные данные</h2>
|
||||
<h2 class="display-4">Личные данные Кладовщика</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
|
@ -2,7 +2,7 @@
|
||||
ViewData["Title"] = "Register";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Регистрация</h2>
|
||||
<h2 class="display-4">Регистрация Кладовщика</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
|
Loading…
Reference in New Issue
Block a user