Enter fix
This commit is contained in:
parent
9d0bccb2f8
commit
6048105937
@ -1,9 +1,9 @@
|
||||
using DinerContracts.ViewModels;
|
||||
using Azure.Core;
|
||||
using DinerContracts.ViewModels;
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.WebSockets;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace DinerClientApp {
|
||||
public class APIClient {
|
||||
@ -11,16 +11,16 @@ namespace DinerClientApp {
|
||||
|
||||
public static ClientViewModel? Client { get; set; } = null;
|
||||
|
||||
public static void Connetc(IConfiguration configuration) {
|
||||
public static void Connect(IConfiguration configuration) {
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
|
||||
public static T? GetRequest<T>(string requsetUrl) {
|
||||
var responce = _client.GetAsync(requsetUrl);
|
||||
var result = responce.Result.Content.ReadAsStringAsync().Result;
|
||||
if (responce.Result.IsSuccessStatusCode) {
|
||||
public static T? GetRequest<T>(string requestUrl) {
|
||||
var response = _client.GetAsync(requestUrl);
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (response.Result.IsSuccessStatusCode) {
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else {
|
||||
@ -28,11 +28,11 @@ namespace DinerClientApp {
|
||||
}
|
||||
}
|
||||
|
||||
public static void PostRequset<T>(string requsetUrl, T model) {
|
||||
public static void PostRequset<T>(string requestUrl, T model) {
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = _client.PostAsync(requsetUrl, data);
|
||||
var response = _client.PostAsync(requestUrl, data);
|
||||
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
if (!response.Result.IsSuccessStatusCode) {
|
||||
|
@ -105,7 +105,7 @@ namespace DinerClientApp.Controllers {
|
||||
}
|
||||
APIClient.PostRequset("api/main/createorder", new OrderBindingModel {
|
||||
ClientID = APIClient.Client.ID,
|
||||
ProductID = product,
|
||||
SnackID = product,
|
||||
Count = count,
|
||||
Sum = Cal(count, product)
|
||||
});
|
||||
@ -113,7 +113,7 @@ namespace DinerClientApp.Controllers {
|
||||
}
|
||||
|
||||
private double Cal(int count, int product) {
|
||||
var prod = APIClient.GetRequest<SnackViewModel>($"api/main/getproduct?productID={product}");
|
||||
var prod = APIClient.GetRequest<SnackViewModel>($"api/main/getproduct?productId={product}");
|
||||
return count * (prod?.Price ?? 1);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DinerContracts\DinerContracts.csproj" />
|
||||
<ProjectReference Include="..\DinerDataBaseImplement\DinerDataBaseImplement.csproj" />
|
||||
<ProjectReference Include="..\DinerRestAPI\DinerRestApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -7,7 +7,7 @@ namespace DinerClientApp {
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
APIClient.Connect(builder.Configuration);
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment()) {
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
@ -24,7 +24,7 @@ namespace DinerClientApp {
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
pattern: "{controller=Home}/{action=Index}/{Id?}");
|
||||
|
||||
app.Run();
|
||||
}
|
||||
|
@ -6,5 +6,5 @@
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "http://localhost:7254/"
|
||||
"IPAddress": "http://localhost:5023/"
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace DinerContracts.BindingModels
|
||||
{
|
||||
public class OrderBindingModel : IOrderModel
|
||||
{
|
||||
public int ProductID { get; set; }
|
||||
public int SnackID { get; set; }
|
||||
|
||||
public int ClientID { get; set; }
|
||||
|
||||
|
@ -10,6 +10,7 @@ namespace DinerContracts.SearchModels
|
||||
{
|
||||
public int? ID { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public int? ClientID { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace DinerContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
public int ProductID { get; set; }
|
||||
public int SnackID { get; set; }
|
||||
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
|
@ -3,6 +3,7 @@ using DinerContracts.SearchModels;
|
||||
using DinerContracts.StoragesContracts;
|
||||
using DinerContracts.ViewModels;
|
||||
using DinerDataBaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -46,13 +47,20 @@ namespace DinerDataBaseImplement.Implements {
|
||||
}
|
||||
|
||||
public ClientViewModel? GetElement(ClientSearchModel model) {
|
||||
if (string.IsNullOrEmpty(model.ClientFIO) && !model.ID.HasValue) {
|
||||
return null;
|
||||
}
|
||||
using var context = new DinerDataBase();
|
||||
return context.Clients.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ClientFIO) &&
|
||||
x.ClientFIO == model.ClientFIO) || model.ID.HasValue &&
|
||||
x.ID == model.ID)?.GetViewModel;
|
||||
if (model.ID.HasValue) {
|
||||
return context.Clients
|
||||
.Include(x => x.Orders)
|
||||
.FirstOrDefault(x => model.ID.HasValue && x.ID == model.ID)
|
||||
?.GetViewModel;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.Email) && !string.IsNullOrEmpty(model.Password)) {
|
||||
return context.Clients
|
||||
.Include(x => x.Orders)
|
||||
.FirstOrDefault(x => (x.Email == model.Email && x.Password == model.Password))
|
||||
?.GetViewModel;
|
||||
}
|
||||
return new();
|
||||
}
|
||||
|
||||
public List<ClientViewModel> GetFilteredList(ClientSearchModel model) {
|
||||
|
@ -82,7 +82,7 @@ namespace DinerDataBaseImplement.Implements
|
||||
using var context = new DinerDataBase();
|
||||
var viewModel = order.GetViewModel;
|
||||
foreach (var pr in context.Products) {
|
||||
if (pr.ID == order.ProductID) {
|
||||
if (pr.ID == order.SnackID) {
|
||||
viewModel.ProductName = pr.ProductName;
|
||||
break;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace DinerDataBaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(DinerDataBase))]
|
||||
[Migration("20240501160144_InitMigration")]
|
||||
[Migration("20240502170545_InitMigration")]
|
||||
partial class InitMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -90,10 +90,7 @@ namespace DinerDataBaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("SnackID")
|
||||
b.Property<int>("SnackID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
@ -145,14 +142,14 @@ namespace DinerDataBaseImplement.Migrations
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
b.Property<int>("SnackID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
b.HasIndex("SnackID");
|
||||
|
||||
b.ToTable("ProductComponents");
|
||||
});
|
||||
@ -165,7 +162,9 @@ namespace DinerDataBaseImplement.Migrations
|
||||
|
||||
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
|
||||
.WithMany()
|
||||
.HasForeignKey("SnackID");
|
||||
.HasForeignKey("SnackID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Snack");
|
||||
});
|
||||
@ -180,7 +179,7 @@ namespace DinerDataBaseImplement.Migrations
|
||||
|
||||
b.HasOne("DinerDataBaseImplement.Models.Snack", "Product")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductID")
|
||||
.HasForeignKey("SnackID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
@ -60,13 +60,12 @@ namespace DinerDataBaseImplement.Migrations
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ProductID = table.Column<int>(type: "int", nullable: false),
|
||||
SnackID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
SnackID = table.Column<int>(type: "int", nullable: true),
|
||||
ClientID = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
@ -81,7 +80,8 @@ namespace DinerDataBaseImplement.Migrations
|
||||
name: "FK_Orders_Products_SnackID",
|
||||
column: x => x.SnackID,
|
||||
principalTable: "Products",
|
||||
principalColumn: "ID");
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -90,7 +90,7 @@ namespace DinerDataBaseImplement.Migrations
|
||||
{
|
||||
ID = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ProductID = table.Column<int>(type: "int", nullable: false),
|
||||
SnackID = table.Column<int>(type: "int", nullable: false),
|
||||
ComponentID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
@ -104,8 +104,8 @@ namespace DinerDataBaseImplement.Migrations
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ProductComponents_Products_ProductID",
|
||||
column: x => x.ProductID,
|
||||
name: "FK_ProductComponents_Products_SnackID",
|
||||
column: x => x.SnackID,
|
||||
principalTable: "Products",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
@ -127,9 +127,9 @@ namespace DinerDataBaseImplement.Migrations
|
||||
column: "ComponentID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ProductComponents_ProductID",
|
||||
name: "IX_ProductComponents_SnackID",
|
||||
table: "ProductComponents",
|
||||
column: "ProductID");
|
||||
column: "SnackID");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
@ -87,10 +87,7 @@ namespace DinerDataBaseImplement.Migrations
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("SnackID")
|
||||
b.Property<int>("SnackID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
@ -142,14 +139,14 @@ namespace DinerDataBaseImplement.Migrations
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductID")
|
||||
b.Property<int>("SnackID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.HasIndex("ComponentID");
|
||||
|
||||
b.HasIndex("ProductID");
|
||||
b.HasIndex("SnackID");
|
||||
|
||||
b.ToTable("ProductComponents", (string)null);
|
||||
});
|
||||
@ -162,7 +159,9 @@ namespace DinerDataBaseImplement.Migrations
|
||||
|
||||
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
|
||||
.WithMany()
|
||||
.HasForeignKey("SnackID");
|
||||
.HasForeignKey("SnackID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Snack");
|
||||
});
|
||||
@ -177,7 +176,7 @@ namespace DinerDataBaseImplement.Migrations
|
||||
|
||||
b.HasOne("DinerDataBaseImplement.Models.Snack", "Product")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductID")
|
||||
.HasForeignKey("SnackID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
|
@ -39,6 +39,15 @@ namespace DinerDataBaseImplement.Models {
|
||||
};
|
||||
}
|
||||
|
||||
public static Client Create(ClientViewModel model) {
|
||||
return new Client {
|
||||
ID = model.ID,
|
||||
ClientFIO = model.ClientFIO,
|
||||
Email = model.Email,
|
||||
Password = model.Password
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ClientBindingModel? model) {
|
||||
if (model == null) {
|
||||
return;
|
||||
|
@ -11,7 +11,7 @@ namespace DinerDataBaseImplement.Models
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
[Required]
|
||||
public int ProductID { get; set; }
|
||||
public int SnackID { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
@ -31,13 +31,13 @@ namespace DinerDataBaseImplement.Models
|
||||
|
||||
public virtual Snack? Snack { get; set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
return new Order()
|
||||
{
|
||||
ID = model.ID,
|
||||
ProductID = model.ProductID,
|
||||
SnackID = model.SnackID,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -54,7 +54,7 @@ namespace DinerDataBaseImplement.Models
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
ID = ID,
|
||||
ProductID = ProductID,
|
||||
SnackID = SnackID,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
|
@ -17,12 +17,12 @@ namespace DinerDataBaseImplement.Models
|
||||
public class Snack : ISnackModel
|
||||
{
|
||||
[Required]
|
||||
public string ProductName { get; private set; } = string.Empty;
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Price { get; private set; }
|
||||
public double Price { get; set; }
|
||||
|
||||
public int ID { get; private set; }
|
||||
public int ID { get; set; }
|
||||
|
||||
private Dictionary<int, (IFoodModel, int)>? _productComponents = null;
|
||||
|
||||
@ -39,7 +39,7 @@ namespace DinerDataBaseImplement.Models
|
||||
return _productComponents;
|
||||
}
|
||||
}
|
||||
[ForeignKey("ProductID")]
|
||||
[ForeignKey("SnackID")]
|
||||
public virtual List<SnackFood> Components { get; set; } = new();
|
||||
public static Snack? Create(DinerDataBase context,SnackBindingModel model)
|
||||
{
|
||||
@ -70,7 +70,7 @@ namespace DinerDataBaseImplement.Models
|
||||
};
|
||||
|
||||
public void UpdateComponents(DinerDataBase context, SnackBindingModel model) {
|
||||
var productComponents = context.ProductComponents.Where(rec => rec.ProductID == model.ID).ToList();
|
||||
var productComponents = context.ProductComponents.Where(rec => rec.SnackID == model.ID).ToList();
|
||||
if (ProductComponents != null && ProductComponents.Count > 0) {
|
||||
context.ProductComponents.RemoveRange(productComponents.Where(rec => !model.ProductComponents.ContainsKey(rec.ComponentID)));
|
||||
context.SaveChanges();
|
||||
|
@ -7,7 +7,7 @@ namespace DinerDataBaseImplement.Models
|
||||
public int ID { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ProductID { get; set; }
|
||||
public int SnackID { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ComponentID { get; set; }
|
||||
|
@ -9,7 +9,7 @@ namespace DinerDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IID
|
||||
{
|
||||
int ProductID { get; }
|
||||
int SnackID { get; }
|
||||
int Count { get; }
|
||||
double Sum { get; }
|
||||
OrderStatus Status { get; }
|
||||
|
@ -67,7 +67,7 @@ namespace DinerListImplement.Implements
|
||||
var viewModel = order.GetViewModel;
|
||||
foreach (var product in _source.Snacks)
|
||||
{
|
||||
if (product.ID == order.ProductID)
|
||||
if (product.ID == order.SnackID)
|
||||
{
|
||||
viewModel.ProductName = product.ProductName;
|
||||
break;
|
||||
|
@ -12,7 +12,7 @@ namespace DinerListImplement.Models
|
||||
{
|
||||
internal class Order : IOrderModel
|
||||
{
|
||||
public int ProductID { get; private set; }
|
||||
public int SnackID { get; private set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
|
||||
@ -31,7 +31,7 @@ namespace DinerListImplement.Models
|
||||
return new Order()
|
||||
{
|
||||
ID = model.ID,
|
||||
ProductID = model.ProductID,
|
||||
SnackID = model.SnackID,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -47,7 +47,7 @@ namespace DinerListImplement.Models
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
ID = ID,
|
||||
ProductID = ProductID,
|
||||
SnackID = SnackID,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
|
@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace DinerRestApi.Controllers {
|
||||
|
||||
[Route("Api/[controller]/[action]")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
|
||||
public class ClientController : Controller {
|
||||
@ -19,8 +19,7 @@ namespace DinerRestApi.Controllers {
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
|
||||
[HttpGet]
|
||||
public ClientViewModel? Login(string login, string password) {
|
||||
try {
|
||||
return _logic.ReadELement(new ClientSearchModel {
|
||||
|
@ -31,12 +31,12 @@ namespace DinerRestApi.Controllers {
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public SnackViewModel? GetProduct(int ProductID) {
|
||||
public SnackViewModel? GetProduct(int SnackID) {
|
||||
try {
|
||||
return _product.ReadElement(new SnackSearchModel { ID = ProductID });
|
||||
return _product.ReadElement(new SnackSearchModel { ID = SnackID });
|
||||
}
|
||||
catch (Exception ex) {
|
||||
_logger.LogError(ex, $"Ошибка получения продуктапо ID={ProductID}");
|
||||
_logger.LogError(ex, $"Ошибка получения продуктапо ID={SnackID}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@ -44,7 +44,7 @@ namespace DinerRestApi.Controllers {
|
||||
[HttpGet]
|
||||
public List<OrderViewModel>? GetOrders(int ClientID) {
|
||||
try {
|
||||
return _order.ReadList(new OrderSearchModel { ID = ClientID });
|
||||
return _order.ReadList(new OrderSearchModel { ClientID = ClientID });
|
||||
}
|
||||
catch (Exception ex) {
|
||||
_logger.LogError(ex, $"Ошибка получения списка закаозов клиента ID={ClientID}");
|
||||
|
@ -32,9 +32,9 @@ namespace DinerRestAPI {
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment()) {
|
||||
if(app.Environment.IsDevelopment()) {
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(x => x.SwaggerEndpoint("/swagger/v1/swagger.json", "DinerRestApi v1"));
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "DinerRestApi v1"));
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
@ -54,7 +54,7 @@ namespace DinerFileImplement.Implements
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
var tmp = from p in _source.Snacks
|
||||
where p.ID == order.ProductID
|
||||
where p.ID == order.SnackID
|
||||
select p.ProductName;
|
||||
viewModel.ProductName = tmp.FirstOrDefault(string.Empty);
|
||||
return viewModel;
|
||||
|
@ -13,7 +13,7 @@ namespace DinerFileImplement.Models
|
||||
{
|
||||
internal class Order : IOrderModel
|
||||
{
|
||||
public int ProductID { get; private set; }
|
||||
public int SnackID { get; private set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
|
||||
@ -34,7 +34,7 @@ namespace DinerFileImplement.Models
|
||||
return new Order()
|
||||
{
|
||||
ID = model.ID,
|
||||
ProductID = model.ProductID,
|
||||
SnackID = model.SnackID,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
Status = model.Status,
|
||||
@ -47,7 +47,7 @@ namespace DinerFileImplement.Models
|
||||
return new Order()
|
||||
{
|
||||
ID = Convert.ToInt32(element.Attribute("ID")!.Value),
|
||||
ProductID = Convert.ToInt32(element.Element("ProductID")!.Value),
|
||||
SnackID = Convert.ToInt32(element.Element("SnackID")!.Value),
|
||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||
@ -55,8 +55,8 @@ namespace DinerFileImplement.Models
|
||||
DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null :
|
||||
Convert.ToDateTime(element.Element("DateImplement")!.Value),
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null) return;
|
||||
Status = model.Status;
|
||||
@ -65,7 +65,7 @@ namespace DinerFileImplement.Models
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
ID = ID,
|
||||
ProductID = ProductID,
|
||||
SnackID = SnackID,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
@ -73,7 +73,7 @@ namespace DinerFileImplement.Models
|
||||
DateImplement = DateImplement,
|
||||
};
|
||||
public XElement GetXElement => new("Order", new XAttribute("ID", ID),
|
||||
new XElement("ProductID", ProductID),
|
||||
new XElement("SnackID", SnackID),
|
||||
new XElement("Count", Count.ToString()),
|
||||
new XElement("Sum", Sum.ToString()),
|
||||
new XElement("Status", Status.ToString()),
|
||||
|
@ -77,7 +77,7 @@ namespace DinerView
|
||||
{
|
||||
var operationResult = _logicOrder.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
ProductID = Convert.ToInt32(comboBoxProduct.SelectedValue),
|
||||
SnackID = Convert.ToInt32(comboBoxProduct.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
Sum = Convert.ToDouble(textBoxSum.Text),
|
||||
|
||||
|
@ -36,7 +36,7 @@ namespace DinerView
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null) {
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ProductID"].Visible = false;
|
||||
dataGridView.Columns["SnackID"].Visible = false;
|
||||
dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
|
@ -66,7 +66,7 @@ namespace DineryBusinessLogic.BusinessLogic {
|
||||
}
|
||||
|
||||
public List<ClientViewModel>? ReadList(ClientSearchModel? model) {
|
||||
_logger.LogInformation($"ReadList. CLiendID:{model?.ID}");
|
||||
_logger.LogInformation($"ReadList. CLientID:{model?.ID}");
|
||||
var list = model == null ? _storage.GetFullList() : _storage.GetFilteredList(model);
|
||||
if (list == null) {
|
||||
_logger.LogWarning("ReadList. return nell list");
|
||||
|
@ -69,9 +69,9 @@ namespace DineryBusinessLogic.BusinessLogic
|
||||
throw new ArgumentNullException("Нет ID заказа", nameof(model.ID));
|
||||
if (model.Sum <= 0)
|
||||
throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum));
|
||||
_logger.LogInformation("Order. ProductID:{ProductID}. Count:{Count}. Sum:{Sum}. Status:{Status}. " +
|
||||
_logger.LogInformation("Order. SnackID:{SnackID}. Count:{Count}. Sum:{Sum}. Status:{Status}. " +
|
||||
"DateCreate:{DateCreate}. DateImplement:{DateImplement}. ID:{ID}",
|
||||
model.ProductID, model.Count, model.Sum, model.Status, model.DateCreate, model.DateImplement, model.ID);
|
||||
model.SnackID, model.Count, model.Sum, model.Status, model.DateCreate, model.DateImplement, model.ID);
|
||||
}
|
||||
private bool StatusUpdate(OrderBindingModel model, OrderStatus newOrderStatus) {
|
||||
CheckModel(model, false);
|
||||
|
@ -38,15 +38,19 @@ namespace DineryBusinessLogic.OfficePackage.Implements
|
||||
fontTittle.Append(new FontName() { Val = "Times New Roman" });
|
||||
fontTittle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
fontTittle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
fonts.Append(fontUsual);
|
||||
fonts.Append(fontTittle);
|
||||
|
||||
var fills = new Fills() { Count = 2U };
|
||||
var fill1 = new Fill();
|
||||
fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||
var fill2 = new Fill();
|
||||
fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||
|
||||
fills.Append(fill1);
|
||||
fills.Append(fill2);
|
||||
|
||||
var borders = new Borders() { Count = 2U };
|
||||
var borderNoBorder = new Border();
|
||||
borderNoBorder.Append(new LeftBorder());
|
||||
@ -55,6 +59,7 @@ namespace DineryBusinessLogic.OfficePackage.Implements
|
||||
borderNoBorder.Append(new BottomBorder());
|
||||
borderNoBorder.Append(new DiagonalBorder());
|
||||
var borderThin = new Border();
|
||||
|
||||
var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||
leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
||||
@ -63,6 +68,7 @@ namespace DineryBusinessLogic.OfficePackage.Implements
|
||||
topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
||||
bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
borderThin.Append(leftBorder);
|
||||
borderThin.Append(rightBorder);
|
||||
borderThin.Append(topBorder);
|
||||
@ -70,6 +76,7 @@ namespace DineryBusinessLogic.OfficePackage.Implements
|
||||
borderThin.Append(new DiagonalBorder());
|
||||
borders.Append(borderNoBorder);
|
||||
borders.Append(borderThin);
|
||||
|
||||
var cellStyleFormats = new CellStyleFormats() { Count = 1U };
|
||||
var cellFormatStyle = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U };
|
||||
cellStyleFormats.Append(cellFormatStyle);
|
||||
|
Loading…
x
Reference in New Issue
Block a user