Фикс привязки + валидация форм

This commit is contained in:
abazov73 2023-05-20 12:09:12 +04:00
parent 4b0808ed46
commit 7d05fffe40
6 changed files with 11 additions and 9 deletions

View File

@ -8,6 +8,7 @@ using BankDataModels.Models;
using MailKit;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata;
using MigraDoc.DocumentObjectModel.Tables;
using OperatorApp.Models;
using System.Diagnostics;
@ -236,7 +237,7 @@ namespace OperatorApp.Controllers
return View();
}
[HttpPost]
public void CreateTransfer(string amount, int payment)
public void CreateTransfer(int amount, int payment)
{
if (HomeController.Operator == null)
{
@ -375,8 +376,9 @@ namespace OperatorApp.Controllers
var currency = _currencyLogic.ReadElement(new CurrencySearchModel { Id = currencyId });
if (currency != null) updCurrencies.Add(currencyId, currency);
}
_paymentLogic.Update(new PaymentBindingModel { Id = paymentModel.Id, PaymentDate = paymentModel.PaymentDate, CurrencyPayments = updCurrencies });
Response.WriteAsync($"<script language=\"javascript\">alert('Success!');window.location.replace('/Home/Enter');</script>");
Dictionary<int, IDealModel> DealPayments = paymentModel.DealPayments;
_paymentLogic.Update(new PaymentBindingModel { Id = paymentModel.Id, PaymentDate = paymentModel.PaymentDate, CurrencyPayments = updCurrencies, DealPayments = DealPayments });
Response.WriteAsync($"<script language=\"javascript\">alert('Success!');window.location.replace('/');</script>");
Redirect("/");
}
}

View File

@ -7,7 +7,7 @@
<form method="post">
<div class="row">
<div class="col-4">ID клиента:</div>
<div class="col-8"><input type="text" name="clientid" id="clientid" required/></div>
<div class="col-8"><input required type="number" name="clientid" id="clientid" required/></div>
</div>
<div class="row">
<div class="col-8"></div>

View File

@ -8,7 +8,7 @@
<div class="row">
<div class="col-4">Сделки:</div>
<div class="col-8">
<select id="deals" name="deals" class="form-control" multiple asp-items="@(new SelectList(@ViewBag.Deals,"Id", "DealDate"))"></select>
<select required id="deals" name="deals" class="form-control" multiple asp-items="@(new SelectList(@ViewBag.Deals,"Id", "DealDate"))"></select>
</div>
</div>
<div class="row">

View File

@ -8,12 +8,12 @@
<div class="row">
<div class="col-4">Выплата:</div>
<div class="col-8">
<select id="payment" name="payment" class="form-control" asp-items="@(new SelectList(@ViewBag.Payments,"Id", "Id"))"></select>
<select required id="payment" name="payment" class="form-control" asp-items="@(new SelectList(@ViewBag.Payments,"Id", "Id"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Сумма:</div>
<div class="col-8"><input type="text" name="amount" id="amount" /></div>
<div class="col-8"><input required type="number" min="1" name="amount" id="amount" /></div>
</div>
<div class="row">
<div class="col-8"></div>

View File

@ -8,7 +8,7 @@
<div class="row">
<div class="col-4">Выплаты:</div>
<div class="col-8">
<select id="payments" name="payments" class="form-control" multiple asp-items="@(new SelectList(@ViewBag.Payments,"Id", "Id"))"></select>
<select required id="payments" name="payments" class="form-control" multiple asp-items="@(new SelectList(@ViewBag.Payments,"Id", "Id"))"></select>
</div>
</div>
<div class="row">

View File

@ -31,7 +31,7 @@
</div>
<div class="row">
<div class="col-4">email:</div>
<div class="col-8"><input type="text" name="email" id="email" /></div>
<div class="col-8"><input type="email" name="email" id="email" /></div>
</div>
<div class="row">
<div class="col-4">Имя файла (необязательно):</div>