Paymeant is done
This commit is contained in:
parent
0cbba88298
commit
c3c37efef6
@ -29,7 +29,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
var record = new ReportPaymeantsViewModel
|
var record = new ReportPaymeantsViewModel
|
||||||
{
|
{
|
||||||
PaymeantID=paymeant.ID,
|
PaymeantID=paymeant.ID,
|
||||||
ProductID=paymeant.ProductID,
|
//ProductID=paymeant.ProductID,
|
||||||
OrderID=paymeant.OrderID,
|
OrderID=paymeant.OrderID,
|
||||||
PayOption=paymeant.PayOption,
|
PayOption=paymeant.PayOption,
|
||||||
SumPayment=paymeant.SumPayment,
|
SumPayment=paymeant.SumPayment,
|
||||||
|
@ -17,5 +17,7 @@ namespace ElectronicsShopContracts.BindingModels
|
|||||||
public double SumPayment { get; set; }
|
public double SumPayment { get; set; }
|
||||||
|
|
||||||
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
|
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
|
||||||
|
|
||||||
|
public int ClientID { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,5 +12,6 @@ namespace ElectronicsShopContracts.SearchModels
|
|||||||
public int? ProductID { get; set; }
|
public int? ProductID { get; set; }
|
||||||
public int? OrderID { get; set; }
|
public int? OrderID { get; set; }
|
||||||
public double? SumPay { get; set; }
|
public double? SumPay { get; set; }
|
||||||
|
public int? ClientID { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@ namespace ElectronicsShopContracts.ViewModels
|
|||||||
public class PaymeantViewModel : IPaymentModel {
|
public class PaymeantViewModel : IPaymentModel {
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
public int ProductID { get; set; }
|
|
||||||
|
|
||||||
public int OrderID { get; set; }
|
public int OrderID { get; set; }
|
||||||
|
|
||||||
[DisplayName("Cумма оплаты продукта")]
|
[DisplayName("Cумма оплаты продукта")]
|
||||||
@ -21,5 +19,8 @@ namespace ElectronicsShopContracts.ViewModels
|
|||||||
|
|
||||||
[DisplayName("Статус оплаты")]
|
[DisplayName("Статус оплаты")]
|
||||||
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
|
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
|
||||||
}
|
|
||||||
|
[DisplayName("Клиент")]
|
||||||
|
public int ClientID { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,11 @@ namespace ElectronicsShopDataBaseImplement.Implements {
|
|||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new Database();
|
using var context = new Database();
|
||||||
|
if (model.ClientID.HasValue) {
|
||||||
|
return context.Paymeants
|
||||||
|
.Where(x => x.ClientID == model.ClientID)
|
||||||
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
return context.Paymeants
|
return context.Paymeants
|
||||||
.Where(x => x.ID == model.ID)
|
.Where(x => x.ID == model.ID)
|
||||||
.Select(x => x.GetViewModel).ToList();
|
.Select(x => x.GetViewModel).ToList();
|
||||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|||||||
namespace ElectronicsShopDataBaseImplement.Migrations
|
namespace ElectronicsShopDataBaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(Database))]
|
[DbContext(typeof(Database))]
|
||||||
[Migration("20240601002930_InitMigration")]
|
[Migration("20240601012156_InitMigration")]
|
||||||
partial class InitMigration
|
partial class InitMigration
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -191,6 +191,9 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("OrderID")
|
b.Property<int>("OrderID")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
@ -112,6 +112,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
|||||||
ID = table.Column<int>(type: "int", nullable: false)
|
ID = table.Column<int>(type: "int", nullable: false)
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
OrderID = table.Column<int>(type: "int", nullable: false),
|
OrderID = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ClientID = table.Column<int>(type: "int", nullable: false),
|
||||||
SumPayment = table.Column<double>(type: "float", nullable: false),
|
SumPayment = table.Column<double>(type: "float", nullable: false),
|
||||||
PayOption = table.Column<int>(type: "int", nullable: false),
|
PayOption = table.Column<int>(type: "int", nullable: false),
|
||||||
PaymentID = table.Column<int>(type: "int", nullable: true)
|
PaymentID = table.Column<int>(type: "int", nullable: true)
|
@ -188,6 +188,9 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
|||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientID")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("OrderID")
|
b.Property<int>("OrderID")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
@ -21,6 +21,9 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
public int OrderID { get; set; }
|
public int OrderID { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
|
public int ClientID { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
public double SumPayment { get; set; }
|
public double SumPayment { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
@ -38,6 +41,7 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
OrderID = model.OrderID,
|
OrderID = model.OrderID,
|
||||||
SumPayment = model.SumPayment,
|
SumPayment = model.SumPayment,
|
||||||
PayOption = model.PayOption,
|
PayOption = model.PayOption,
|
||||||
|
ClientID = model.ClientID,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public void Update(PaymeantBindingModel? model)
|
public void Update(PaymeantBindingModel? model)
|
||||||
@ -57,7 +61,7 @@ namespace ElectronicsShopDataBaseImplement.Models
|
|||||||
OrderID = OrderID,
|
OrderID = OrderID,
|
||||||
SumPayment = SumPayment,
|
SumPayment = SumPayment,
|
||||||
PayOption = PayOption,
|
PayOption = PayOption,
|
||||||
|
ClientID = ClientID,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,5 +13,6 @@ namespace ElectronicsShopDataModels.Models
|
|||||||
int OrderID { get; }
|
int OrderID { get; }
|
||||||
double SumPayment { get; }
|
double SumPayment { get; }
|
||||||
PaymeantOption PayOption { get; }
|
PaymeantOption PayOption { get; }
|
||||||
|
int ClientID { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,5 +66,16 @@ namespace ElectronicsShopRestAPI.Controllers {
|
|||||||
_logger.LogError(ex, "Ошибка создания оплаты");
|
_logger.LogError(ex, "Ошибка создания оплаты");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public List<PaymeantViewModel>? GetPaymeants(int _clientID) {
|
||||||
|
try {
|
||||||
|
return _payLogic.ReadList(new PaymeantSearchModel { ClientID = _clientID });
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
_logger.LogError(ex, $"Ошибка получения списка оплат клиента id = {_clientID}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ namespace ElectronicsShopUserApp.Controllers {
|
|||||||
if (APIClient.Client == null) {
|
if (APIClient.Client == null) {
|
||||||
return Redirect("~/Home/Enter");
|
return Redirect("~/Home/Enter");
|
||||||
}
|
}
|
||||||
return View(APIClient.GetRequset<List<OrderViewModel>>($"api/main/getorders?_clientid={APIClient.Client.ID}"));
|
return View(APIClient.GetRequset<List<PaymeantViewModel>>($"api/client/getpaymeants?_clientid={APIClient.Client.ID}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@ -267,8 +267,9 @@ namespace ElectronicsShopUserApp.Controllers {
|
|||||||
}
|
}
|
||||||
APIClient.PostRequest("api/client/createpaymeant", new PaymeantBindingModel {
|
APIClient.PostRequest("api/client/createpaymeant", new PaymeantBindingModel {
|
||||||
OrderID = id,
|
OrderID = id,
|
||||||
SumPayment = sum,
|
SumPayment = paysum,
|
||||||
PayOption = PayOptionCalc(sum, paysum)
|
PayOption = PayOptionCalc(sum, paysum),
|
||||||
|
ClientID = APIClient.Client.ID
|
||||||
});
|
});
|
||||||
Response.Redirect("Index");
|
Response.Redirect("Index");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
@using ElectronicsShopContracts.ViewModels
|
@using ElectronicsShopContracts.ViewModels
|
||||||
|
|
||||||
@model List<OrderViewModel>
|
@model List<PaymeantViewModel>
|
||||||
|
|
||||||
@{
|
@{
|
||||||
ViewData["Title"] = "Home Page";
|
ViewData["Title"] = "Home Page";
|
||||||
@ -20,14 +20,17 @@
|
|||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>
|
||||||
|
Номер
|
||||||
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Номер заказа
|
Номер заказа
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Дата создания
|
Сумма к оплате
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
Сумма
|
Статус оплаты
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -38,10 +41,13 @@
|
|||||||
@Html.DisplayFor(modelItem => item.ID)
|
@Html.DisplayFor(modelItem => item.ID)
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayFor(modelItem => item.DateCreate)
|
@Html.DisplayFor(modelItem => item.OrderID)
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
@Html.DisplayFor(modelItem => item.Sum)
|
@Html.DisplayFor(modelItem => item.SumPayment)
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
@Html.DisplayFor(modelItem => item.PayOption)
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user