беда
This commit is contained in:
parent
83a2cfe0d7
commit
adaa621ff6
@ -71,8 +71,11 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||
{
|
||||
throw new ArgumentNullException("Сумма оплаты должна быть больше 0", nameof(model.SumPayment));
|
||||
}
|
||||
if (model.PayProductList.Count == 0) {
|
||||
throw new ArgumentNullException("нельзя оплатить пустой заказ", nameof(model.PayProductList));
|
||||
}
|
||||
_logger.LogInformation($"Payment. ID:{model.ID}.Sum:{model.SumPayment}.OrderID:{model.OrderID}" +
|
||||
$".PayOption{model.PayOption}");
|
||||
$".PayOption{model.PayOption}.Products:{model.PayProductList}");
|
||||
}
|
||||
|
||||
public bool SetFullPayment(PaymeantBindingModel model) {
|
||||
|
@ -44,8 +44,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||
List<ReportProductsViewModel>? products = new();
|
||||
|
||||
foreach (var paymeant in paymeants) {
|
||||
var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID });
|
||||
foreach (var product in order.ProductList) {
|
||||
foreach (var product in paymeant.PayProductList) {
|
||||
products.Add(new ReportProductsViewModel {
|
||||
ID = product.Value.Item1.ID,
|
||||
ProductName = product.Value.Item1.ProductName,
|
||||
@ -89,17 +88,11 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||
TotalCount = 0
|
||||
};
|
||||
|
||||
var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID });
|
||||
if (order == null) {
|
||||
continue;
|
||||
foreach (var product in paymeant.PayProductList) {
|
||||
record.Products.Add(new(product.Value.Item1.ProductName, product.Value.Item2));
|
||||
record.TotalCount += product.Value.Item2;
|
||||
}
|
||||
|
||||
foreach (var product in products) {
|
||||
if (order.ProductList.ContainsKey(product.ID)) {
|
||||
record.Products.Add(new(product.ProductName, order.ProductList[product.ID].Item2));
|
||||
record.TotalCount += order.ProductList[product.ID].Item2;
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,7 @@ namespace ElectronicsShopContracts.BindingModels
|
||||
public int ClientID { get; set; }
|
||||
|
||||
public DateTime DatePaymeant { get; set; } = DateTime.Now;
|
||||
}
|
||||
|
||||
public Dictionary<int, (IProductModel, int)> PayProductList { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
using ElectronicsShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopContracts.ViewModels
|
||||
{
|
||||
public class MessageInfoViewModel: IMessageInfoModel
|
||||
{
|
||||
public string MessageID { get; set; } = string.Empty;
|
||||
|
||||
public int? ClientID { get; set; }
|
||||
|
||||
[DisplayName("Отправитель")]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата письма")]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
[DisplayName("Заголовок")]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Текст")]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -24,5 +24,8 @@ namespace ElectronicsShopContracts.ViewModels
|
||||
public int ClientID { get; set; }
|
||||
|
||||
public DateTime DatePaymeant { get; set; }
|
||||
}
|
||||
|
||||
[DisplayName("Список оплаченных товаров")]
|
||||
public Dictionary<int, (IProductModel, int)> PayProductList { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ namespace ElectronicsShopDataBaseImplement.Implements
|
||||
using var context = new Database();
|
||||
if (model.ClientID.HasValue) {
|
||||
return context.Orders
|
||||
.Include(x => x.Payments)
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x._product)
|
||||
.OrderBy(x => x.ID)
|
||||
@ -75,7 +76,8 @@ namespace ElectronicsShopDataBaseImplement.Implements
|
||||
if (model.ID.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Products)
|
||||
.Include(x => x.Payments)
|
||||
.Include(x => x.Products)
|
||||
.ThenInclude(x => x._product)
|
||||
.FirstOrDefault(x => (model.ID.HasValue && x.ID == model.ID))?.GetViewModel;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace ElectronicsShopDataBaseImplement.Implements {
|
||||
return newPayment.GetViewModel;
|
||||
}
|
||||
|
||||
// todo тут должен меняться статус оплаты
|
||||
public PaymeantViewModel? UpdatePay(PaymeantBindingModel model) {
|
||||
using var context = new Database();
|
||||
var paymeant = context.Paymeants.FirstOrDefault(x => x.ID == model.ID);
|
||||
|
285
ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240724085609_05.Designer.cs
generated
Normal file
285
ElectronicsShop/ElectronicsShopDataBaseImplement/Migrations/20240724085609_05.Designer.cs
generated
Normal file
@ -0,0 +1,285 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ElectronicsShopDataBaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(Database))]
|
||||
[Migration("20240724085609_05")]
|
||||
partial class _05
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("CostNum")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("EmployeeID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("CostItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Employee", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("EmployeeFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ClientID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ClientID");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("OrderProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("ClientID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DatePaymeant")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("OrderID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PayOption")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PaymentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("SumPayment")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("PaymentID");
|
||||
|
||||
b.ToTable("Paymeants");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<int>("CostItemID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("ProductName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("CostItemID");
|
||||
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b =>
|
||||
{
|
||||
b.HasOne("ElectronicsShopDataBaseImplement.Models.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ElectronicsShopDataBaseImplement.Models.Client", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b =>
|
||||
{
|
||||
b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", "_order")
|
||||
.WithMany("Products")
|
||||
.HasForeignKey("OrderID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ElectronicsShopDataBaseImplement.Models.Product", "_product")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProductID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("_order");
|
||||
|
||||
b.Navigation("_product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b =>
|
||||
{
|
||||
b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", null)
|
||||
.WithMany("Payments")
|
||||
.HasForeignKey("PaymentID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("ElectronicsShopDataBaseImplement.Models.CostItem", "CostItem")
|
||||
.WithMany()
|
||||
.HasForeignKey("CostItemID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CostItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("Payments");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class _05 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "PaymentID",
|
||||
table: "Paymeants",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Paymeants_PaymentID",
|
||||
table: "Paymeants",
|
||||
column: "PaymentID");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Paymeants_Orders_PaymentID",
|
||||
table: "Paymeants",
|
||||
column: "PaymentID",
|
||||
principalTable: "Orders",
|
||||
principalColumn: "ID");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Paymeants_Orders_PaymentID",
|
||||
table: "Paymeants");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Paymeants_PaymentID",
|
||||
table: "Paymeants");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "PaymentID",
|
||||
table: "Paymeants");
|
||||
}
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Clients", (string)null);
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b =>
|
||||
@ -72,7 +72,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
|
||||
b.HasIndex("EmployeeID");
|
||||
|
||||
b.ToTable("CostItems", (string)null);
|
||||
b.ToTable("CostItems");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Employee", b =>
|
||||
@ -97,7 +97,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Employees", (string)null);
|
||||
b.ToTable("Employees");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
|
||||
@ -121,7 +121,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ClientID");
|
||||
|
||||
b.ToTable("Orders", (string)null);
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.OrderProduct", b =>
|
||||
@ -147,7 +147,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
|
||||
b.ToTable("OrderProducts", (string)null);
|
||||
b.ToTable("OrderProducts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b =>
|
||||
@ -170,12 +170,17 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
b.Property<int>("PayOption")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("PaymentID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("SumPayment")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Paymeants", (string)null);
|
||||
b.HasIndex("PaymentID");
|
||||
|
||||
b.ToTable("Paymeants");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b =>
|
||||
@ -200,7 +205,7 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
|
||||
b.HasIndex("CostItemID");
|
||||
|
||||
b.ToTable("Products", (string)null);
|
||||
b.ToTable("Products");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.CostItem", b =>
|
||||
@ -242,6 +247,13 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
b.Navigation("_product");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Paymeant", b =>
|
||||
{
|
||||
b.HasOne("ElectronicsShopDataBaseImplement.Models.Order", null)
|
||||
.WithMany("Payments")
|
||||
.HasForeignKey("PaymentID");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Product", b =>
|
||||
{
|
||||
b.HasOne("ElectronicsShopDataBaseImplement.Models.CostItem", "CostItem")
|
||||
@ -260,6 +272,8 @@ namespace ElectronicsShopDataBaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("ElectronicsShopDataBaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("Payments");
|
||||
|
||||
b.Navigation("Products");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
|
@ -43,7 +43,10 @@ namespace ElectronicsShopDataBaseImplement.Models
|
||||
[ForeignKey("OrderID")]
|
||||
public virtual List<OrderProduct> Products { get; set; } = new();
|
||||
|
||||
public static Order? Create(Database context ,OrderBindingModel? model)
|
||||
[ForeignKey("PaymentID")]
|
||||
public virtual List<Paymeant> Payments { get; set; } = new();
|
||||
|
||||
public static Order? Create(Database context ,OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -107,5 +110,9 @@ namespace ElectronicsShopDataBaseImplement.Models
|
||||
context.OrderProducts.RemoveRange(orderProducts.Where(rec => !model.ProductList.ContainsKey(rec.ProductID)));
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
public void SumUpdate(double sumDeduct) {
|
||||
Sum -= sumDeduct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,10 @@ namespace ElectronicsShopDataBaseImplement.Models
|
||||
|
||||
public DateTime DatePaymeant { get; set; }
|
||||
|
||||
public static Paymeant? Create(PaymeantBindingModel? model)
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IProductModel, int)> PayProductList { get; set; } = new();
|
||||
|
||||
public static Paymeant? Create(PaymeantBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -44,7 +47,8 @@ namespace ElectronicsShopDataBaseImplement.Models
|
||||
SumPayment = model.SumPayment,
|
||||
PayOption = model.PayOption,
|
||||
ClientID = model.ClientID,
|
||||
DatePaymeant = model.DatePaymeant
|
||||
DatePaymeant = model.DatePaymeant,
|
||||
PayProductList = model.PayProductList
|
||||
};
|
||||
}
|
||||
public void Update(PaymeantBindingModel? model)
|
||||
@ -53,7 +57,6 @@ namespace ElectronicsShopDataBaseImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
OrderID = model.OrderID;
|
||||
SumPayment = model.SumPayment;
|
||||
PayOption = model.PayOption;
|
||||
}
|
||||
@ -64,7 +67,8 @@ namespace ElectronicsShopDataBaseImplement.Models
|
||||
SumPayment = SumPayment,
|
||||
PayOption = PayOption,
|
||||
ClientID = ClientID,
|
||||
DatePaymeant = DatePaymeant
|
||||
DatePaymeant = DatePaymeant,
|
||||
PayProductList = PayProductList
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ElectronicsShopDataModels.Models
|
||||
{
|
||||
public interface IMessageInfoModel
|
||||
{
|
||||
string MessageID { get; }
|
||||
|
||||
int? ClientID { get; }
|
||||
|
||||
string SenderName { get; }
|
||||
|
||||
DateTime DateDelivery { get; }
|
||||
|
||||
string Subject { get; }
|
||||
|
||||
string Body { get; }
|
||||
}
|
||||
}
|
@ -15,5 +15,8 @@ namespace ElectronicsShopDataModels.Models
|
||||
PaymeantOption PayOption { get; }
|
||||
DateTime DatePaymeant { get; }
|
||||
int ClientID { get; }
|
||||
}
|
||||
|
||||
// Список оплаченнх товаров
|
||||
Dictionary<int, (IProductModel, int)> PayProductList { get; }
|
||||
}
|
||||
}
|
||||
|
@ -180,8 +180,6 @@ namespace ElectronicsShopEmployeeApp.Controllers {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Response.Redirect("CostItem");
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ using ElectronicsShopContracts.SearchModels;
|
||||
using ElectronicsShopContracts.ViewModels;
|
||||
using ElectronicsShopDataBaseImplement.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Identity.Client;
|
||||
using MigraDoc.Rendering;
|
||||
|
||||
namespace ElectronicsShopRestAPI.Controllers {
|
||||
@ -21,14 +22,16 @@ namespace ElectronicsShopRestAPI.Controllers {
|
||||
private readonly IClientLogic _logic;
|
||||
private readonly IPaymeantLogic _payLogic;
|
||||
private readonly IReportClientLogic _reportLogic;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
|
||||
public ClientController(ILogger<ClientController> logger, IClientLogic logic, IPaymeantLogic payLogic, IReportClientLogic reportlogic,
|
||||
AbstractMailWorker mailWorker) {
|
||||
IOrderLogic orderLogic, AbstractMailWorker mailWorker) {
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_payLogic = payLogic;
|
||||
_reportLogic = reportlogic;
|
||||
_orderLogic = orderLogic;
|
||||
_mailWorker = mailWorker;
|
||||
}
|
||||
|
||||
@ -71,7 +74,19 @@ namespace ElectronicsShopRestAPI.Controllers {
|
||||
[HttpPost]
|
||||
public void CreatePaymeant (PaymeantBindingModel model) {
|
||||
try {
|
||||
var products = _orderLogic.ReadElement(new OrderSearchModel { ID = model.OrderID })?.ProductList;
|
||||
|
||||
if (products == null) {
|
||||
throw new Exception("Ошибка получения товаров");
|
||||
}
|
||||
|
||||
model.PayProductList = products;
|
||||
_payLogic.CreatePay(model);
|
||||
|
||||
if (model.PayOption == 0) {
|
||||
_orderLogic.Delete(new OrderBindingModel { ID = model.OrderID});
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
_logger.LogError(ex, "Ошибка создания оплаты");
|
||||
|
@ -21,8 +21,6 @@ namespace ElectronicsShopRestAPI.Controllers {
|
||||
private readonly IPaymeantLogic _paymeant;
|
||||
private readonly IReportClientLogic _reportClientLogic;
|
||||
|
||||
//private readonly IMessageInfoLogic _message;
|
||||
|
||||
private Dictionary<int, (IProductModel, int)> _productlist;
|
||||
|
||||
public MainController(ILogger<MainController> logger, IProductLogic product,
|
||||
|
Binary file not shown.
@ -1,48 +0,0 @@
|
||||
@using ElectronicsShopContracts.ViewModels
|
||||
|
||||
@model List<MessageInfoViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Message";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Письма</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Заголовок
|
||||
</th>
|
||||
<th>
|
||||
Тело письма
|
||||
</th>
|
||||
<th>
|
||||
Дата письма
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if (Model != null)
|
||||
{
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<th>
|
||||
<th>
|
||||
@Html.DisplayFor(modelItem => item.Subject)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayFor(modelItem => item.Body)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayFor(modelItem => item.DateDelivery)
|
||||
</th>
|
||||
</th>
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -30,7 +30,7 @@
|
||||
<div class="col-4">Сумма к оплате:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="sum" id="sum" readonly />
|
||||
</divЫ>
|
||||
</div>
|
||||
<input type="submit" value="Оплатить!" class="btn btn-primary" />
|
||||
</div>
|
||||
<table class="table">
|
||||
|
Loading…
Reference in New Issue
Block a user