Fix: 販売個数は自動計算されるよう修正
This commit is contained in:
parent
b95e89afc4
commit
2aa91cc208
@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using StockingData.Lib.IO.Repositories;
|
||||
using StockingData.Lib.Services;
|
||||
using StockingData.Models;
|
||||
|
||||
namespace StockingData.Controllers;
|
||||
@ -22,13 +23,14 @@ public class GraphController : Controller
|
||||
}
|
||||
|
||||
var records = await this.stockRepository.FetchStockRecordByIdAsync(product.ProductId).ConfigureAwait(false);
|
||||
var transformer = new GraphViewTransformer(records);
|
||||
|
||||
var model = new GraphViewModel()
|
||||
{
|
||||
ProductId = product.ProductId,
|
||||
Title = product.Title,
|
||||
Code = product.Code,
|
||||
Stocks = records,
|
||||
Stocks = transformer.Transform(),
|
||||
};
|
||||
|
||||
return View(model);
|
||||
|
||||
@ -50,6 +50,6 @@ public class StockProductsController : Controller
|
||||
await this.stockRepository.UpdateStockCountAsync(stockId, count).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return RedirectToAction("Register", "SaleProducts");
|
||||
return RedirectToAction("List", "Products");
|
||||
}
|
||||
}
|
||||
|
||||
24
StockingData/Lib/Services/GraphViewTransformer.cs
Normal file
24
StockingData/Lib/Services/GraphViewTransformer.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using StockingData.Lib.Data;
|
||||
|
||||
namespace StockingData.Lib.Services;
|
||||
|
||||
public class GraphViewTransformer
|
||||
{
|
||||
private readonly IEnumerable<StockTable> records;
|
||||
public GraphViewTransformer(IEnumerable<StockTable> records)
|
||||
{
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
public IEnumerable<StockTable> Transform()
|
||||
{
|
||||
var list = new List<StockTable>();
|
||||
foreach (var item in this.records)
|
||||
{
|
||||
item.SaleCount = item.DisplayCount - item.StockCount;
|
||||
list.Add(item);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@ -31,9 +31,6 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="StockProducts" asp-action="Register">在庫数登録</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="SaleProducts" asp-action="Register">販売個数登録</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Products" asp-action="List">商品一覧</a>
|
||||
</li>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user