Views changes.

This commit is contained in:
Yuee Shiness 2023-05-13 22:46:59 +04:00
parent c5603b1ceb
commit 2fec7dfdf0
6 changed files with 56 additions and 26 deletions

View File

@ -1,5 +1,6 @@
using ComputerStoreContracts.BindingModels; using ComputerStoreContracts.BindingModels;
using ComputerStoreContracts.ViewModels; using ComputerStoreContracts.ViewModels;
using ComputerStoreDataModels.Models;
using ComputerStoreEmployeeApp.Models; using ComputerStoreEmployeeApp.Models;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -11,10 +12,14 @@ namespace ComputerStoreEmployeeApp.Controllers
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ILogger<HomeController> _logger; private readonly ILogger<HomeController> _logger;
private Dictionary<int, (IComponentModel, int)> _productComponents;
private Dictionary<int, (IComponentModel, int)> _pcComponents;
public HomeController(ILogger<HomeController> logger) public HomeController(ILogger<HomeController> logger)
{ {
_logger = logger; _logger = logger;
_productComponents = new Dictionary<int, (IComponentModel, int)>();
_pcComponents = new Dictionary<int, (IComponentModel, int)>();
} }
public IActionResult Index() public IActionResult Index()
@ -159,11 +164,15 @@ namespace ComputerStoreEmployeeApp.Controllers
} }
[HttpPost] [HttpPost]
public void ProductAdd(string val) public void ProductAdd(string productname, double productprice)
{ {
} }
public double ProductComponents(int id)
{
var component = Task.Run(() => APIClient.GetRequest<ComponentViewModel>("api/main/getcomponent")).Result;
}
[HttpGet] [HttpGet]
public IActionResult ProductUpdate() public IActionResult ProductUpdate()
{ {

View File

@ -14,4 +14,8 @@
<input type="submit" id="componentbtn" value="ADD" class="btn btn-primary" /> <input type="submit" id="componentbtn" value="ADD" class="btn btn-primary" />
</div> </div>
</div> </div>
@if (!string.IsNullOrEmpty(ViewBag.Message))
{
<script>alert("@ViewBag.Message");</script>
}
</form> </form>

View File

@ -11,4 +11,8 @@
<input type="submit" id="componentbtn" value="DELETE" class="btn btn-primary" /> <input type="submit" id="componentbtn" value="DELETE" class="btn btn-primary" />
</div> </div>
</div> </div>
@if (!string.IsNullOrEmpty(ViewBag.Message))
{
<script>alert("@ViewBag.Message");</script>
}
</form> </form>

View File

@ -15,4 +15,8 @@
<input type="submit" id="componentbtn" value="CHANGE" class="btn btn-primary" /> <input type="submit" id="componentbtn" value="CHANGE" class="btn btn-primary" />
</div> </div>
</div> </div>
@if (!string.IsNullOrEmpty(ViewBag.Message))
{
<script>alert("@ViewBag.Message");</script>
}
</form> </form>

View File

@ -0,0 +1,21 @@
@{
ViewData["Title"] = "Add a product";
}
<div class="text-center">
<h2 class="display-4">Add a product</h2>
</div>
<form method="post">
<div class="flex-container" style="flex-direction: row; justify-content: space-between; display: flex; height: 100vh;">
<div class="flex-containerB1" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
<div class="productname" style="text-align: left; font-size: 15px;">Name:</div>
<input type="text" id="productname" name="productname" />
<div class="productprice" style="text-align: left; font-size: 15px;">Price:</div>
<input type="text" id="productprice" name="productprice" />
<input type="submit" id="productbtn" value="ADD" class="btn btn-primary" />
</div>
</div>
@if (!string.IsNullOrEmpty(ViewBag.Message))
{
<script>alert("@ViewBag.Message");</script>
}
</form>

View File

@ -7,38 +7,26 @@
<div class="flex-containerA1" style="flex-direction: column; align-items: center; display: flex; gap: 35px"> <div class="flex-containerA1" style="flex-direction: column; align-items: center; display: flex; gap: 35px">
<h1>What do you want to do with products?</h1> <h1>What do you want to do with products?</h1>
<div class="flex-containerB1" style="display: flex; align-items: center; margin-top: 120px;"> <div class="flex-containerB1" style="display: flex; align-items: center; margin-top: 120px;">
<form method="get" asp-controller="Home" asp-action="ProductAdd">
<input type="submit" id="productadd" value="ADD" class="btn btn-primary" style="font-size: 20pt; width: 130px;" /> <input type="submit" id="productadd" value="ADD" class="btn btn-primary" style="font-size: 20pt; width: 130px;" />
</form>
</div> </div>
<div class="flex-containerB2" style="display: flex; align-items: center;"> <div class="flex-containerB2" style="display: flex; align-items: center;">
<form method="get" asp-controller="Home" asp-action="ProductUpdate">
<input type="submit" id="productupdate" value="UPDATE" class="btn btn-primary" style="font-size: 20pt; width: 130px;" /> <input type="submit" id="productupdate" value="UPDATE" class="btn btn-primary" style="font-size: 20pt; width: 130px;" />
</form>
</div> </div>
<div class="flex-containerB3" style="display: flex; align-items: center;"> <div class="flex-containerB3" style="display: flex; align-items: center;">
<form method="get" asp-controller="Home" asp-action="ProductDelete">
<input type="submit" id="productdel" value="DELETE" class="btn btn-primary" style="font-size: 20pt; width: 130px;" /> <input type="submit" id="productdel" value="DELETE" class="btn btn-primary" style="font-size: 20pt; width: 130px;" />
</form>
</div> </div>
<div class="flex-containerB3" style="display: flex; align-items: center;"> <div class="flex-containerB3" style="display: flex; align-items: center;">
<form method="get" asp-controller="Home" asp-action="ProductCheck">
<input type="submit" id="productcheck" value="STORAGE" class="btn btn-primary" style="font-size: 20pt; width: 130px;" /> <input type="submit" id="productcheck" value="STORAGE" class="btn btn-primary" style="font-size: 20pt; width: 130px;" />
</form>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
<script>
$('#productadd').on('click', function () {
evt.preventDefault();
document.location.href = '@Url.Action("ProductAdd","Home")';
});
$('#productupdate').on('click', function () {
evt.preventDefault();
document.location.href = '@Url.Action("ProductUpdate","Home")';
});
$('#productdel').on('click', function () {
evt.preventDefault();
document.location.href = '@Url.Action("ProductDelete","Home")';
});
$('#productcheck').on('click', function () {
evt.preventDefault();
document.location.href = '@Url.Action("ProductStorage","Home")';
});
</script>
</div> </div>