FFFFFFFFFFFFFFFFFFFFFFF

This commit is contained in:
devil_1nc 2023-12-02 06:42:59 +04:00
parent 42f8415d34
commit 96037fbe66
16 changed files with 838 additions and 94 deletions

View File

@ -27,9 +27,17 @@ namespace ComputerShopBusinessLogic.BusinessLogics
public bool CreateOrder(OrderBindingModel model)
{
CheckModel(model);
if (_orderStorage.Insert(model) == null)
if (model.Status != OrderStatus.Неизвестен)
{
_logger.LogWarning("Insert operation failed");
_logger.LogWarning("Order status is incorrect");
return false;
}
model.Status = OrderStatus.Принят;
if (_orderStorage.Insert(model) == null)
{
Console.WriteLine("_orderStorage.Insert(model) == null");
model.Status = OrderStatus.Неизвестен;
_logger.LogWarning("Failed to insert order into a storage");
return false;
}
return true;
@ -82,35 +90,40 @@ namespace ComputerShopBusinessLogic.BusinessLogics
{
return StatusUpdate(model, OrderStatus.Готов);
}
public bool StatusUpdate(OrderBindingModel model, OrderStatus _newStatus)
{
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (viewModel == null)
{
throw new ArgumentNullException(nameof(model));
}
if (viewModel.Status + 1 != _newStatus)
{
_logger.LogWarning("Status update to " + _newStatus.ToString() + " operation failed. Order status incorrect.");
return false;
}
model.Status = _newStatus;
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
else
{
model.DateImplement = viewModel.DateImplement;
}
CheckModel(model, false);
if (_orderStorage.Update(model) == null)
{
model.Status--;
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(OrderBindingModel model, bool withParams = true)
public bool StatusUpdate(OrderBindingModel rawModel, OrderStatus _newStatus)
{
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = rawModel.Id });
if (viewModel == null)
{
_logger.LogWarning("Order model not found");
return false;
}
OrderBindingModel model = new OrderBindingModel
{
Id = viewModel.Id,
ClientId = viewModel.ClientId,
Status = viewModel.Status,
DateCreate = viewModel.DateCreate,
DateImplement = viewModel.DateImplement,
Sum = viewModel.Sum
};
CheckModel(rawModel, false);
if (rawModel.Status + 1 != _newStatus)
{
_logger.LogWarning("Status update to " + _newStatus.ToString() + " operation failed. Order status incorrect.");
return false;
}
if (rawModel.Status == OrderStatus.Выдан) rawModel.DateImplement = DateTime.Now;
if (_orderStorage.Update(rawModel) == null)
{
rawModel.Status--;
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(OrderBindingModel model, bool withParams = true)
{
if (model == null)
{

View File

@ -43,24 +43,32 @@ namespace ComputerShopDatabaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new ComputerShopDatabase();
return context.Orders
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
using var context = new ComputerShopDatabase();
if (model.ClientId.HasValue)
{
return context.Orders
.Include(x => x.Assemblies)
.Include(x => x.Client)
.Where(x => x.ClientId == model.ClientId)
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Include(x => x.Assemblies).Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
}
public List<OrderViewModel> GetFullList()
{
using var context = new ComputerShopDatabase();
return context.Orders
.Select(x => x.GetViewModel)
.ToList();
}
return context.Orders
.Include(x => x.Assemblies).Include(x => x.Client)
.Select(x => x.GetViewModel)
.ToList();
}
public OrderViewModel? Insert(OrderBindingModel model)
{
@ -73,7 +81,7 @@ namespace ComputerShopDatabaseImplement.Implements
using var context = new ComputerShopDatabase();
context.Orders.Add(newOrder);
context.SaveChanges();
return context.Orders.Include(x => x.Assemblies).Include(x => x.ClientId).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
return context.Orders.Include(x => x.Assemblies).Include(x => x.Client).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)

View File

@ -0,0 +1,548 @@
// <auto-generated />
using System;
using ComputerShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
[DbContext(typeof(ComputerShopDatabase))]
[Migration("20231202000001_nullable")]
partial class nullable
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AssemblyName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Assemblies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AssemblyId")
.HasColumnType("int");
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AssemblyId");
b.HasIndex("ComponentId");
b.ToTable("AssemblyComponents");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.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("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Components");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("SupplyId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("SupplyId");
b.ToTable("ComponentSupplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("EquipmentReceivings");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.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<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AssemblyId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AssemblyId");
b.HasIndex("OrderId");
b.ToTable("AssemblyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ComponentId");
b.ToTable("Purchases");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int?>("ComponentId")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int?>("ReceivingId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ComponentId");
b.HasIndex("ReceivingId");
b.ToTable("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", 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>("SupplyId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("SupplyId");
b.ToTable("SupplyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Assemblies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany("Components")
.HasForeignKey("AssemblyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("AssemblyComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Assembly");
b.Navigation("Component");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Components")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("Supplies")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
.WithMany("Components")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("EquipmentReceivings")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.OrderAssembly", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany("Orders")
.HasForeignKey("AssemblyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("Assemblies")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Assembly");
b.Navigation("Order");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Purchases")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("Purchases")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Component");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Supplies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany()
.HasForeignKey("ComponentId");
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies")
.HasForeignKey("ReceivingId");
b.Navigation("Component");
b.Navigation("Receiving");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("SupplyOrders")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
.WithMany("Orders")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
{
b.Navigation("Assemblies");
b.Navigation("Components");
b.Navigation("EquipmentReceivings");
b.Navigation("Orders");
b.Navigation("Purchases");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.Navigation("AssemblyComponents");
b.Navigation("Purchases");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.Navigation("Assemblies");
b.Navigation("SupplyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class nullable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -394,11 +394,13 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("EquipmentReceivings")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>

View File

@ -24,10 +24,10 @@ namespace ComputerShopDatabaseImplement.Models
public DateTime? DateImplement { get; private set; }
[ForeignKey("OrderId")]
public virtual List<SupplyOrder> SupplyOrders { get; set; } = new();
public virtual List<SupplyOrder>? SupplyOrders { get; set; } = new();
[ForeignKey("OrderId")]
public virtual List<OrderAssembly> Assemblies { get; set; } = new();
public virtual List<OrderAssembly>? Assemblies { get; set; } = new();
private Dictionary<int, (IOrderModel, int)>? _assemblyOrders = null;
[NotMapped]
@ -47,7 +47,8 @@ namespace ComputerShopDatabaseImplement.Models
[Required]
public int ClientId { get; set; }
public static Order? Create(OrderBindingModel model)
public virtual Client? Client { get; set; }
public static Order? Create(OrderBindingModel model)
{
if (model == null)
{
@ -63,18 +64,7 @@ namespace ComputerShopDatabaseImplement.Models
ClientId = model.ClientId
};
}
public static Order Create(OrderViewModel model)
{
return new Order
{
Id = model.Id,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement,
ClientId = model.ClientId
};
}
public void Update(OrderBindingModel model)
{
if (model == null)

View File

@ -23,8 +23,8 @@ namespace ComputerShopDatabaseImplement.Models
public DateTime? DateImplement { get; private set; }
public int ClientId { get; set; }
public int? ReceivingId { get; set; }
public virtual Client? Client { get; set; }
public int? ReceivingId { get; set; }
public virtual EquipmentReceiving? Receiving { get; set; }
public int? ComponentId { get; set; }
public virtual Component? Component { get; set; }

View File

@ -1,6 +1,7 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.StorageContracts;
using ComputerShopContracts.ViewModels;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -14,6 +15,7 @@ namespace ComputerShopRestApi.Controllers
{
private readonly ILogger _logger;
private readonly IOrderLogic _order;
private readonly IOrderStorage _orderStorage;
public OrderController(ILogger<MainController> logger, IOrderLogic order, ISupplyLogic supply)
{
@ -77,6 +79,70 @@ namespace ComputerShopRestApi.Controllers
}
}
[HttpPost]
public void FinishOrder(int id)
{
try
{
var order = _orderStorage.GetElement(new() { Id = id });
OrderBindingModel model = new OrderBindingModel()
{
Id = id,
ClientId = order.ClientId,
DateImplement = order.DateImplement,
Status = order.Status
};
_order.FinishOrder(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка изменения закупки");
throw;
}
}
[HttpPost]
public void DeliveryOrder(int id)
{
try
{
var order = _orderStorage.GetElement(new() { Id = id });
OrderBindingModel model = new OrderBindingModel()
{
Id = id,
ClientId = order.ClientId,
DateImplement = order.DateImplement,
Status = order.Status
};
_order.DeliveryOrder(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка изменения закупки");
throw;
}
}
[HttpPost]
public void TakeOrderInWork(int id)
{
try
{
var order = _orderStorage.GetElement(new() { Id = id });
OrderBindingModel model = new OrderBindingModel()
{
Id = id,
ClientId = order.ClientId,
DateImplement = order.DateImplement,
Status = order.Status
};
_order.TakeOrderInWork(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка изменения закупки");
throw;
}
}
[HttpPost]
public void AddAssembly(Tuple<OrderSearchModel, AssemblySearchModel, int> model)
{

View File

@ -43,11 +43,11 @@ namespace ComputerShopRestApi.Controllers
}
[HttpGet]
public List<SupplyViewModel>? GetSupplyList(int componentid)
public List<SupplyViewModel>? GetSupplyList(int clientId)
{
try
{
return _supply.ReadList(new SupplySearchModel { ComponentId = componentid });
return _supply.ReadList(new SupplySearchModel { ClientId = clientId });
}
catch (Exception ex)
{

View File

@ -31,9 +31,9 @@ namespace OrdererClientApp.Controllers
{
if (APIClient.Client == null)
{
return Redirect("~/Order/Enter");
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/order/getorderlist?clientId={APIClient.Client.Id}"));
return View(APIClient.GetRequest<List<OrderViewModel>>($"api/order/GetOrderList?clientId={APIClient.Client.Id}"));
}
public IActionResult Supply()
{
@ -41,7 +41,7 @@ namespace OrdererClientApp.Controllers
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<SupplyViewModel>>($"api/supply/getsupplylist"));
return View(APIClient.GetRequest<List<SupplyViewModel>>($"api/supply/getsupplylist?clientId={APIClient.Client.Id}"));
}
[HttpGet]
@ -185,7 +185,7 @@ namespace OrdererClientApp.Controllers
ClientId = APIClient.Client.Id,
Sum = sum
});
Response.Redirect("Index");
Response.Redirect("Order");
}
[HttpGet]
@ -208,14 +208,14 @@ namespace OrdererClientApp.Controllers
Response.Redirect("Index");
}
public IActionResult AddAssemblyToOrder()
public IActionResult AddAssembly()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
ViewBag.Assemblies = APIClient.GetRequest<List<OrderViewModel>>($"api/order/getorderlist?clientId={APIClient.Client.Id}");
ViewBag.Components = APIClient.GetRequest<List<AssemblyViewModel>>($"api/assembly/getassemblylist?clientId={APIClient.Client.Id}");
ViewBag.Assemblies = APIClient.GetRequest<List<AssemblyViewModel>>($"api/assembly/getassemblylist?clientId={APIClient.Client.Id}");
ViewBag.Orders = APIClient.GetRequest<List<OrderViewModel>>($"api/order/getorderlist?clientId={APIClient.Client.Id}");
return View();
}
@ -227,12 +227,42 @@ namespace OrdererClientApp.Controllers
throw new Exception("Необходима авторизация");
}
APIClient.PostRequest("api/order/AddAssembly", Tuple.Create(
new AssemblySearchModel() { Id = assembly },
new OrderSearchModel() { Id = order },
new AssemblySearchModel() { Id = assembly },
amount
));
Response.Redirect("Order");
}
[HttpPost]
public void FinishOrder(int id)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/order/finishorder?id={id}", id);
Response.Redirect("order");
}
[HttpPost]
public void DeliveryOrder(int id)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/order/deliveryorder?id={id}", id);
Response.Redirect("order");
}
[HttpPost]
public void TakeOrderInWork(int id)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/order/takeorderinwork?id={id}", id);
Response.Redirect("order");
}
[HttpPost]

View File

@ -1,4 +1,4 @@
g ComputerShopContracts.ViewModels;
@using ComputerShopContracts.ViewModels;
@using ComputerShopDataModels.Models;
@{
@ -21,6 +21,10 @@
<select id="assembly" name="assembly" class="form-control" asp-items="@(new SelectList(@ViewBag.Assemblies, "Id", "AssemblyName"))"></select>
</div>
</div>
<div class="row">
<div class="col-4">Количество:</div>
<div class="col-8"><input type="text" name="amount" id="amount" /></div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Добавить заказ" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>

View File

@ -1,24 +1,14 @@
@using ComputerShopContracts.ViewModels;
@using ComputerShopDataModels.Models;

@{
ViewData["Title"] = "CreateOrder";
}
@model Dictionary<int, IAssemblyModel>
<div class="text-center">
<h2 class="display-4">Создание заказа</h2>
</div>
<form method="post">
<div class="u-form-group u-form-name u-label-top">
<label class="u-label u-text-custom-color-1 u-label-1">Выберете сборки для заказа: </label>
<div class="u-input u-input-rectangle">
<select id="assembly" name="assembly" class="form-control" asp-items="@(new SelectList(@ViewBag.Assemblies, "Id", "AssemblyName"))"></select>
</div>
</div>
<div class="u-align-right u-form-group u-form-submit u-label-top">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Добавить заказ" class="u-active-custom-color-6 u-border-none u-btn u-btn-submit u-button-style u-custom-color-1 u-hover-custom-color-2 u-btn-1" /></div>
<div class="row">
<div class="col-4">Цена без учета сборок:</div>
<div class="col-8"><input type="text" name="sum" id="sum" /></div>
</div>
<div class="row">
<div class="col-8"></div>

View File

@ -0,0 +1,21 @@
@using ComputerShopContracts.ViewModels;
@using ComputerShopDataModels.Models;
@{
ViewData["Title"] = "CreateSupply";
}
@model Dictionary<int, IAssemblyModel>
<div class="text-center">
<h2 class="display-4">Создание заказа</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Цена без учета сборок:</div>
<div class="col-8"><input type="text" name="sum" id="sum" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -23,7 +23,7 @@
<a asp-action="CreateOrder">Создать заказ</a>
</p>
<p>
<a asp-action="AddAssemblyToOrder">Добавить сборки к заказу</a>
<a asp-action="AddAssembly">Добавить сборки к заказу</a>
</p>
<table class="table">
@ -65,6 +65,24 @@
<td>
@Html.DisplayFor(modelItem => item.DateImplement)
</td>
<td>
<form action="TakeOrderInWork" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-outline-dark">Выполняется</button>
</form>
</td>
<td>
<form action="DeliveryOrder" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-outline-dark">Выдан</button>
</form>
</td>
<td>
<form action="FinishOrder" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-outline-dark">Готов</button>
</form>
</td>
</tr>
}
</tbody>

View File

@ -7,7 +7,7 @@
}
<div class="text-center">
<h1 class="display-4">Поставка</h1>
<h1 class="display-4">Поставки</h1>
</div>

View File

@ -7,10 +7,42 @@
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/OrdererClientApp.styles.css" asp-append-version="true" />
<style>
header {
background-color: #f8f9fa; /* Цвет фона */
padding: 10px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1); /* Тень */
transition: box-shadow 0.3s ease; /* Анимация тени */
}
.navbar-brand {
font-size: 24px;
font-weight: bold;
text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.1); /* Отражение */
}
.navbar-nav .nav-item {
margin-right: 10px;
}
.navbar-nav .nav-link {
transition: box-shadow 0.3s ease; /* Анимация тени */
}
.navbar-nav .nav-link:hover {
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.2); /* Тень при наведении на кнопку */
}
/* Анимация тени при наведении на шапку */
header:hover {
box-shadow: 0px 5px 20px rgba(0, 0, 0, 0.2); /* Тень при наведении */
}
</style>
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3 container-fluid">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
@ -26,7 +58,7 @@
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Order">Заказы</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Supply">Закупки</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Supply">Поставки</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>