This commit is contained in:
devil_1nc 2023-05-20 09:27:59 +04:00
commit d7ab3a10c4
8 changed files with 127 additions and 17 deletions

View File

@ -52,11 +52,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
var receivings = new List<EquipmentReceivingViewModel>();
// ОШИБКА: int не содержит определения HasValue()
/*
foreach(var supply in supplies)
{
if (supply.ReceivingId.HasValue)
@ -69,7 +64,6 @@ namespace ComputerShopBusinessLogic.BusinessLogics
}
}
*/
var receivingnames = new List<string>();
foreach (var receiving in receivings)

View File

@ -2,8 +2,10 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using System.ComponentModel;
using System.Diagnostics;
namespace ComputerShopClientApp.Controllers
@ -147,6 +149,12 @@ namespace ComputerShopClientApp.Controllers
}
}
[HttpGet]
public IActionResult Enter()
{
return View();
}
[HttpGet]
public IActionResult GetWordFile()
{
@ -158,10 +166,37 @@ namespace ComputerShopClientApp.Controllers
return new PhysicalFileResult("F:\\ReportsCourseWork\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}
[HttpGet]
public IActionResult Enter()
[HttpPost]
public void SetInWork(int id)
{
return View();
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/main/setinwork?id={id}", id);
Response.Redirect("Index");
}
[HttpPost]
public void SetReady(int id)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/main/setready?id={id}", id);
Response.Redirect("Index");
}
[HttpPost]
public void SetDone(int id)
{
if (APIClient.Client == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
APIClient.PostRequest($"api/main/setdone?id={id}", id);
Response.Redirect("Index");
}
[HttpPost]

View File

@ -7,7 +7,7 @@
}
<div class="text-center">
<h1 class="display-4">Заказы</h1>
<h1 class="display-4">Покупки</h1>
</div>
@ -20,7 +20,7 @@
}
<p>
<a asp-action="CreatePurchase">Создать заказ</a>
<a asp-action="CreatePurchase">Создать покупку</a>
</p>
<table class="table">
<thead>
@ -67,6 +67,20 @@
<td>
@Html.DisplayFor(modelItem => item.Status)
</td>
<td>
<form action="SetInWork" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-danger">Выполняется</button>
</form>
<form action="SetReady" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-danger">Выдан</button>
</form>
<form action="SetDone" method="post">
<input type="hidden" name="id" value="@item.Id" />
<button type="submit" class="btn btn-danger">Готов</button>
</form>
</td>
</tr>
}
</tbody>

View File

@ -26,7 +26,7 @@ namespace ComputerShopContracts.ViewModels
[DisplayName("Номер клиента")]
public int ClientId { get; set; }
[DisplayName("Номер получения")]
public int ReceivingId { get; set; }
public int? ReceivingId { get; set; }
public Dictionary<int, IOrderModel> SupplyOrders
{
get;

View File

@ -7,7 +7,7 @@ namespace ComputerShopDataModels.Models
SupplyStatus Status { get; }
DateTime DateCreate { get; }
DateTime? DateImplement { get; }
int ReceivingId { get; }
int? ReceivingId { get; }
Dictionary<int, IOrderModel> SupplyOrders { get; }
}
}

View File

@ -15,7 +15,7 @@ namespace ComputerShopDatabaseImplement
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-QA8P9OJ;Initial Catalog=ComputerShopDatabaseCW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-IRUVF5S\SQLEXPRESS;Initial Catalog=ComputerShopDatabaseCW;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}

View File

@ -26,8 +26,8 @@ namespace ComputerShopDatabaseImplement.Models
public int OrderId { get; set; }
public int ClientId { get; set; }
public int ReceivingId { get; set; }
public virtual EquipmentReceiving? Receiving { get; set; }
public int? ReceivingId { get; set; }
public virtual EquipmentReceiving Receiving { get; set; }
private Dictionary<int, IOrderModel>? _supplyOrders =
null;

View File

@ -1,7 +1,9 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.BusinessLogicContracts;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.StorageContracts;
using ComputerShopContracts.ViewModels;
using DocumentFormat.OpenXml.Presentation;
using Microsoft.AspNetCore.Mvc;
namespace ComputerShopRestApi.Controllers
@ -12,12 +14,14 @@ namespace ComputerShopRestApi.Controllers
{
private readonly ILogger _logger;
private readonly IPurchaseLogic _purchase;
private readonly IPurchaseStorage _purchaseSTR;
private readonly IComponentLogic _component;
public MainController(ILogger<MainController> logger, IPurchaseLogic purchase, IComponentLogic component)
public MainController(ILogger<MainController> logger, IPurchaseLogic purchase, IComponentLogic component, IPurchaseStorage purchaseStorage)
{
_logger = logger;
_purchase = purchase;
_component = component;
_purchaseSTR = purchaseStorage;
}
[HttpGet]
public List<ComponentViewModel>? GetComponentList()
@ -77,5 +81,68 @@ namespace ComputerShopRestApi.Controllers
throw;
}
}
[HttpPost]
public void SetInWork(int id)
{
try
{
var puchase = _purchaseSTR.GetElement(new() { Id = id });
_purchase.TakePurchaseInWork(new()
{
Id = id,
ComponentId = puchase.ComponentId,
Count = puchase.Count,
Sum = puchase.Sum,
Status = puchase.Status
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка изменения закупки");
throw;
}
}
[HttpPost]
public void SetReady(int id)
{
try
{
var puchase = _purchaseSTR.GetElement(new() { Id = id });
_purchase.FinishPurchase(new()
{
Id = id,
ComponentId = puchase.ComponentId,
Count = puchase.Count,
Sum = puchase.Sum,
Status = puchase.Status
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка изменения закупки");
throw;
}
}
[HttpPost]
public void SetDone(int id)
{
try
{
var puchase = _purchaseSTR.GetElement(new() { Id = id });
_purchase.DeliveryPurchase(new()
{
Id = id,
ComponentId = puchase.ComponentId,
Count = puchase.Count,
Sum = puchase.Sum,
Status = puchase.Status
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка изменения закупки");
throw;
}
}
}
}